@@ -170,6 +170,7 @@ private static List<Fix> analyzeImpl(CompilationInfo info, String diagnosticKey,
170170 TreePath parent = null ;
171171 TreePath firstClass = null ;
172172 TreePath firstMethod = null ;
173+ TreePath firstLambda = null ;
173174 TreePath firstVar = null ;
174175 TreePath firstInitializer = null ;
175176 TreePath methodInvocation = null ;
@@ -194,6 +195,9 @@ private static List<Fix> analyzeImpl(CompilationInfo info, String diagnosticKey,
194195 firstClass = path ;
195196 if (leafKind == Kind .METHOD && firstMethod == null && firstClass == null )
196197 firstMethod = path ;
198+ if (leafKind == Kind .LAMBDA_EXPRESSION && firstMethod == null &&
199+ firstClass == null && firstLambda == null && firstInitializer == null )
200+ firstLambda = path ;
197201 //static/dynamic initializer:
198202 if ( leafKind == Kind .BLOCK && TreeUtilities .CLASS_TREE_KINDS .contains (path .getParentPath ().getLeaf ().getKind ())
199203 && firstMethod == null && firstClass == null )
@@ -495,7 +499,7 @@ private static List<Fix> analyzeImpl(CompilationInfo info, String diagnosticKey,
495499 int identifierPos = (int ) info .getTrees ().getSourcePositions ().getStartPosition (info .getCompilationUnit (), errorPath .getLeaf ());
496500 if (ee != null && fixTypes .contains (ElementKind .PARAMETER ) && !Utilities .isMethodHeaderInsideGuardedBlock (info , (MethodTree ) firstMethod .getLeaf ()))
497501 result .add (new AddParameterOrLocalFix (info , type , simpleName , ElementKind .PARAMETER , identifierPos ).toEditorFix ());
498- if ((firstMethod != null || firstInitializer != null ) && fixTypes .contains (ElementKind .LOCAL_VARIABLE ) && ErrorFixesFakeHint .enabled (ErrorFixesFakeHint .FixKind .CREATE_LOCAL_VARIABLE ))
502+ if ((firstMethod != null || firstInitializer != null || firstLambda != null ) && fixTypes .contains (ElementKind .LOCAL_VARIABLE ) && ErrorFixesFakeHint .enabled (ErrorFixesFakeHint .FixKind .CREATE_LOCAL_VARIABLE ))
499503 result .add (new AddParameterOrLocalFix (info , type , simpleName , ElementKind .LOCAL_VARIABLE , identifierPos ).toEditorFix ());
500504 if (fixTypes .contains (ElementKind .RESOURCE_VARIABLE ))
501505 result .add (new AddParameterOrLocalFix (info , type , simpleName , ElementKind .RESOURCE_VARIABLE , identifierPos ).toEditorFix ());
0 commit comments