@@ -887,6 +887,33 @@ public static LocalVariable toLocalVariable(SingleVariableDeclaration parameter,
887887 return toLocalVariable (parameter , parent , parameter .getParent () instanceof MethodDeclaration );
888888 }
889889
890+ public static LocalVariable toLocalVariable (VariableDeclarationFragment fragment , JavaElement parent ) {
891+ if (fragment .getParent () instanceof VariableDeclarationStatement variableDeclaration ) {
892+ return new LocalVariable (parent ,
893+ fragment .getName ().getIdentifier (),
894+ variableDeclaration .getStartPosition (),
895+ variableDeclaration .getStartPosition () + variableDeclaration .getLength () - 1 ,
896+ fragment .getName ().getStartPosition (),
897+ fragment .getName ().getStartPosition () + fragment .getName ().getLength () - 1 ,
898+ Util .getSignature (variableDeclaration .getType ()),
899+ null , // I don't think we need this, also it's the ECJ's annotation node
900+ toModelFlags (variableDeclaration .getModifiers (), false ),
901+ false );
902+ } else if (fragment .getParent () instanceof VariableDeclarationExpression variableDeclaration ) {
903+ return new LocalVariable (parent ,
904+ fragment .getName ().getIdentifier (),
905+ variableDeclaration .getStartPosition (),
906+ variableDeclaration .getStartPosition () + variableDeclaration .getLength () - 1 ,
907+ fragment .getName ().getStartPosition (),
908+ fragment .getName ().getStartPosition () + fragment .getName ().getLength () - 1 ,
909+ Util .getSignature (variableDeclaration .getType ()),
910+ null , // I don't think we need this, also it's the ECJ's annotation node
911+ toModelFlags (variableDeclaration .getModifiers (), false ),
912+ false );
913+ }
914+ return null ;
915+ }
916+
890917 private static LocalVariable toLocalVariable (SingleVariableDeclaration parameter , JavaElement parent , boolean isParameter ) {
891918 return new LocalVariable (parent ,
892919 parameter .getName ().getIdentifier (),
0 commit comments