@@ -770,13 +770,10 @@ final class DefinitionFinder : ASTVisitor
770770
771771 override void visit (const FunctionDeclaration dec)
772772 {
773- if (! dec.functionBody || ! dec.functionBody.specifiedFunctionBody
774- || ! dec.functionBody.specifiedFunctionBody.blockStatement)
775- return ;
776773 auto def = makeDefinition(dec.name.text, dec.name.line, " f" , context,
777774 [
778- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. startLocation,
779- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. endLocation
775+ cast (int ) dec.functionBody.startLocation,
776+ cast (int ) dec.functionBody.endLocation
780777 ]);
781778 def.attributes[" signature" ] = paramsToString(dec);
782779 if (dec.returnType ! is null )
@@ -786,27 +783,21 @@ final class DefinitionFinder : ASTVisitor
786783
787784 override void visit (const Constructor dec)
788785 {
789- if (! dec.functionBody || ! dec.functionBody.specifiedFunctionBody
790- || ! dec.functionBody.specifiedFunctionBody.blockStatement)
791- return ;
792786 auto def = makeDefinition(" this" , dec.line, " f" , context,
793787 [
794- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. startLocation,
795- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. endLocation
788+ cast (int ) dec.functionBody.startLocation,
789+ cast (int ) dec.functionBody.endLocation
796790 ]);
797791 def.attributes[" signature" ] = paramsToString(dec);
798792 definitions ~= def;
799793 }
800794
801795 override void visit (const Destructor dec)
802796 {
803- if (! dec.functionBody || ! dec.functionBody.specifiedFunctionBody
804- || ! dec.functionBody.specifiedFunctionBody.blockStatement)
805- return ;
806797 definitions ~= makeDefinition(" ~this" , dec.line, " f" , context,
807798 [
808- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. startLocation,
809- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. endLocation
799+ cast (int ) dec.functionBody.startLocation,
800+ cast (int ) dec.functionBody.endLocation
810801 ]);
811802 }
812803
@@ -815,13 +806,10 @@ final class DefinitionFinder : ASTVisitor
815806 if (! verbose)
816807 return ;
817808
818- if (! dec.functionBody || ! dec.functionBody.specifiedFunctionBody
819- || ! dec.functionBody.specifiedFunctionBody.blockStatement)
820- return ;
821809 definitions ~= makeDefinition(" this(this)" , dec.line, " f" , context,
822810 [
823- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. startLocation,
824- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. endLocation
811+ cast (int ) dec.functionBody.startLocation,
812+ cast (int ) dec.functionBody.endLocation
825813 ]);
826814 }
827815
@@ -1043,13 +1031,10 @@ final class DefinitionFinder : ASTVisitor
10431031 if (! verbose)
10441032 return ;
10451033
1046- if (! dec.functionBody || ! dec.functionBody.specifiedFunctionBody
1047- || ! dec.functionBody.specifiedFunctionBody.blockStatement)
1048- return ;
10491034 definitions ~= makeDefinition(CtorNames[i], dec.line, CtorTypes[i], context,
10501035 [
1051- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. startLocation,
1052- cast (int ) dec.functionBody.specifiedFunctionBody.blockStatement. endLocation
1036+ cast (int ) dec.functionBody.startLocation,
1037+ cast (int ) dec.functionBody.endLocation
10531038 ]);
10541039 }
10551040 }
@@ -1171,3 +1156,13 @@ unittest
11711156 assert (defs == expectedDefinitions);
11721157 });
11731158}
1159+
1160+ size_t startLocation (const FunctionBody b)
1161+ {
1162+ return b.tokens.length > 0 ? b.tokens[0 ].index : 0 ;
1163+ }
1164+
1165+ size_t endLocation (const FunctionBody b)
1166+ {
1167+ return b.tokens.length > 0 ? (b.tokens[$ - 1 ].index + b.tokens[$ - 1 ].tokenText.length) : 0 ;
1168+ }
0 commit comments