@@ -81,8 +81,8 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
8181
8282 public InferNullityAnnotationsAction () {
8383 super (
84- JavaLocalize .actionInfernullityText (),
85- JavaLocalize .actionInfernullityDescription (),
84+ JavaLocalize .actionInferNullityText (),
85+ JavaLocalize .actionInferNullityDescription (),
8686 LocalizeValue .localizeTODO ("Infer Nullity" ),
8787 INFER_NULLITY_ANNOTATIONS
8888 );
@@ -91,8 +91,8 @@ public InferNullityAnnotationsAction() {
9191 @ Override
9292 @ RequiredUIAccess
9393 protected void analyze (@ Nonnull Project project , @ Nonnull AnalysisScope scope ) {
94- boolean annotateLocaVars = myAnnotateLocalVariablesCb .getValueOrError ();
95- ApplicationPropertiesComponent .getInstance ().setValue (ANNOTATE_LOCAL_VARIABLES , annotateLocaVars );
94+ boolean annotateLocalVars = myAnnotateLocalVariablesCb .getValueOrError ();
95+ ApplicationPropertiesComponent .getInstance ().setValue (ANNOTATE_LOCAL_VARIABLES , annotateLocalVars );
9696 myAnnotateLocalVariablesCb = null ;
9797
9898 ProgressManager progressManager = ProgressManager .getInstance ();
@@ -150,16 +150,16 @@ else if (javaPsiFacade.findClass(
150150 return ;
151151 }
152152 PsiDocumentManager .getInstance (project ).commitAllDocuments ();
153- UsageInfo [] usageInfos = findUsages (annotateLocaVars , project , scope , fileCount [0 ]);
153+ UsageInfo [] usageInfos = findUsages (annotateLocalVars , project , scope , fileCount [0 ]);
154154 if (usageInfos == null ) {
155155 return ;
156156 }
157157
158- processUsages (annotateLocaVars , project , scope , usageInfos );
158+ processUsages (annotateLocalVars , project , scope , usageInfos );
159159 }
160160
161161 protected void processUsages (
162- boolean annotateLocaVars ,
162+ boolean annotateLocalVars ,
163163 @ Nonnull Project project ,
164164 @ Nonnull AnalysisScope scope ,
165165 @ Nonnull UsageInfo [] usageInfos
@@ -168,7 +168,7 @@ protected void processUsages(
168168 applyRunnable (project , () -> usageInfos ).run ();
169169 }
170170 else {
171- showUsageView (annotateLocaVars , project , usageInfos , scope );
171+ showUsageView (annotateLocalVars , project , usageInfos , scope );
172172 }
173173 }
174174
@@ -185,7 +185,7 @@ public static boolean addAnnotationsDependency(
185185 message += StringUtil .join (modulesWithoutAnnotations , Module ::getName , ", " );
186186 message += (modulesWithoutAnnotations .size () == 1 ? " doesn't" : " don't" );
187187 message += " refer to the existing '" + annotationsLib .getName () + "' library" +
188- " with Consulo nullity annotations. Would you like to add the dependenc " ;
188+ " with Consulo nullity annotations. Would you like to add the dependency " ;
189189 message += (modulesWithoutAnnotations .size () == 1 ? "y" : "ies" ) + " now?" ;
190190 if (Messages .showOkCancelDialog (project , message , title .get (), UIUtil .getErrorIcon ()) == Messages .OK ) {
191191 project .getApplication ().runWriteAction (() ->
@@ -199,26 +199,37 @@ public static boolean addAnnotationsDependency(
199199 return false ;
200200 }
201201
202- /*if (Messages.showOkCancelDialog(project, "It is required that JetBrains annotations" + " be available in all your project sources.\n\nYou will need to add annotations.jar as a library. " +
203- "It is possible to configure custom JAR\nin e.g. Constant Conditions & Exceptions inspection or use JetBrains annotations available in installation. " + "\nIntelliJ IDEA nullity " +
204- "annotations are freely usable and redistributable under the Apache 2.0 license.\nWould you like to do it now?", title, Messages.getErrorIcon()) == Messages.OK)
205- {
206- Module firstModule = modulesWithoutAnnotations.iterator().next();
207- JavaProjectModelModificationService.getInstance(project).addDependency(modulesWithoutAnnotations, JetBrainsAnnotationsExternalLibraryResolver.getAnnotationsLibraryDescriptor(firstModule)
208- , DependencyScope.COMPILE);
209- return true;
210- } */
202+ /*
203+ if (Messages.showOkCancelDialog(
204+ project,
205+ "It is required that JetBrains annotations be available in all your project sources.\n\n" +
206+ "You will need to add annotations.jar as a library. It is possible to configure custom JAR\n" +
207+ "in e.g. Constant Conditions & Exceptions inspection or use JetBrains annotations available in installation.\n" +
208+ "IntelliJ IDEA nullity annotations are freely usable and redistributable under the Apache 2.0 license.\n" +
209+ "Would you like to do it now?",
210+ title,
211+ Messages.getErrorIcon()
212+ ) == Messages.OK) {
213+ Module firstModule = modulesWithoutAnnotations.iterator().next();
214+ JavaProjectModelModificationService.getInstance(project).addDependency(
215+ modulesWithoutAnnotations,
216+ JetBrainsAnnotationsExternalLibraryResolver.getAnnotationsLibraryDescriptor(firstModule),
217+ DependencyScope.COMPILE
218+ );
219+ return true;
220+ }
221+ */
211222 return false ;
212223 }
213224
214225 @ Nullable
215226 protected UsageInfo [] findUsages (
216- boolean annotateLocaVars ,
227+ boolean annotateLocalVars ,
217228 @ Nonnull Project project ,
218229 @ Nonnull AnalysisScope scope ,
219230 int fileCount
220231 ) {
221- NullityInferrer inferrer = new NullityInferrer (annotateLocaVars , project );
232+ NullityInferrer inferrer = new NullityInferrer (annotateLocalVars , project );
222233 PsiManager psiManager = PsiManager .getInstance (project );
223234 Runnable searchForUsages = () -> scope .accept (new PsiElementVisitor () {
224235 int myFileCount ;
@@ -235,7 +246,7 @@ public void visitFile(PsiFile file) {
235246 ProgressIndicator progressIndicator = ProgressManager .getInstance ().getProgressIndicator ();
236247 if (progressIndicator != null ) {
237248 progressIndicator .setText2 (ProjectUtil .calcRelativeToProjectPath (virtualFile , project ));
238- progressIndicator .setFraction (((double )myFileCount ) / fileCount );
249+ progressIndicator .setFraction (((double ) myFileCount ) / fileCount );
239250 }
240251 if (file instanceof PsiJavaFile ) {
241252 inferrer .collect (file );
@@ -309,7 +320,7 @@ protected void restartAnalysis(Project project, AnalysisScope scope) {
309320 }
310321
311322 private void showUsageView (
312- boolean annotateLocaVars ,
323+ boolean annotateLocalVars ,
313324 @ Nonnull Project project ,
314325 UsageInfo [] usageInfos ,
315326 @ Nonnull AnalysisScope scope
@@ -334,19 +345,20 @@ private void showUsageView(
334345 presentation .setTabText ("Infer Nullity Preview" );
335346 presentation .setShowReadOnlyStatusAsRed (true );
336347 presentation .setShowCancelButton (true );
337- presentation .setUsagesString (RefactoringLocalize .usageviewUsagestext (). get () );
348+ presentation .setUsagesString (RefactoringLocalize .usageviewUsagestext ());
338349
339350 UsageView usageView =
340- UsageViewManager .getInstance (project ).showUsages (targets , usages , presentation , rerunFactory (annotateLocaVars , project , scope ));
351+ UsageViewManager .getInstance (project ).showUsages (targets , usages , presentation , rerunFactory (annotateLocalVars , project , scope ));
341352
342353 Runnable refactoringRunnable = applyRunnable (project , () ->
343354 {
344355 Set <UsageInfo > infos = UsageViewUtil .getNotExcludedUsageInfos (usageView );
345356 return infos .toArray (new UsageInfo [infos .size ()]);
346357 });
347358
348- String canNotMakeString =
349- "Cannot perform operation.\n There were changes in code after usages have been found.\n Please perform operation search again." ;
359+ String canNotMakeString = "Cannot perform operation.\n " +
360+ "There were changes in code after usages have been found.\n " +
361+ "Please perform operation search again." ;
350362
351363 usageView .addPerformOperationAction (
352364 refactoringRunnable ,
@@ -359,7 +371,7 @@ private void showUsageView(
359371
360372 @ Nonnull
361373 private Supplier <UsageSearcher > rerunFactory (
362- boolean annotateLocaVars ,
374+ boolean annotateLocalVars ,
363375 @ Nonnull Project project ,
364376 @ Nonnull AnalysisScope scope
365377 ) {
@@ -368,7 +380,7 @@ private Supplier<UsageSearcher> rerunFactory(
368380 @ Override
369381 protected UsageInfo [] findUsages () {
370382 return ObjectUtil .notNull (
371- InferNullityAnnotationsAction .this .findUsages (annotateLocaVars , project , scope , scope .getFileCount ()),
383+ InferNullityAnnotationsAction .this .findUsages (annotateLocalVars , project , scope , scope .getFileCount ()),
372384 UsageInfo .EMPTY_ARRAY
373385 );
374386 }
@@ -380,8 +392,8 @@ public void generate(@Nonnull Predicate<Usage> processor) {
380392 };
381393 }
382394
383- @ RequiredUIAccess
384395 @ Override
396+ @ RequiredUIAccess
385397 protected void extendMainLayout (BaseAnalysisActionDialog dialog , VerticalLayout layout , Project project ) {
386398 myAnnotateLocalVariablesCb =
387399 CheckBox .create (LocalizeValue .localizeTODO ("Annotate local variables" ));
0 commit comments