Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@ActionImpl(id = "GenerateConstructor")
public class GenerateConstructorAction extends BaseGenerateAction {
public GenerateConstructorAction() {
super(new GenerateConstructorHandler(), JavaLocalize.actionGenerateconstructorText());
super(new GenerateConstructorHandler(), JavaLocalize.actionGenerateConstructorText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@ActionImpl(id = "GenerateCreateUI")
public class GenerateCreateUIAction extends BaseGenerateAction {
public GenerateCreateUIAction() {
super(new GenerateCreateUIHandler(), JavaLocalize.actionGeneratecreateuiText());
super(new GenerateCreateUIHandler(), JavaLocalize.actionGenerateCreateUIText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@ActionImpl(id = "GenerateEquals")
public class GenerateEqualsAction extends BaseGenerateAction {
public GenerateEqualsAction() {
super(new GenerateEqualsHandler(), JavaLocalize.actionGenerateequalsText());
super(new GenerateEqualsHandler(), JavaLocalize.actionGenerateEqualsText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
@ActionImpl(id = "GenerateGetter")
public class GenerateGetterAction extends GenerateGetterSetterBaseAction {
public GenerateGetterAction() {
super(new GenerateGetterHandler(), JavaLocalize.actionGenerategetterText());
super(new GenerateGetterHandler(), JavaLocalize.actionGenerateGetterText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
@ActionImpl(id = "GenerateGetterAndSetter")
public class GenerateGetterAndSetterAction extends GenerateGetterSetterBaseAction {
public GenerateGetterAndSetterAction() {
super(new GenerateGetterAndSetterHandler(), JavaLocalize.actionGenerategetterandsetterText());
super(new GenerateGetterAndSetterHandler(), JavaLocalize.actionGenerateGetterAndSetterText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
@ActionImpl(id = "GenerateSetter")
public class GenerateSetterAction extends GenerateGetterSetterBaseAction {
public GenerateSetterAction() {
super(new GenerateSetterHandler(), JavaLocalize.actionGeneratesetterText());
super(new GenerateSetterHandler(), JavaLocalize.actionGenerateSetterText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {

public InferNullityAnnotationsAction() {
super(
JavaLocalize.actionInfernullityText(),
JavaLocalize.actionInfernullityDescription(),
JavaLocalize.actionInferNullityText(),
JavaLocalize.actionInferNullityDescription(),
LocalizeValue.localizeTODO("Infer Nullity"),
INFER_NULLITY_ANNOTATIONS
);
Expand All @@ -91,8 +91,8 @@ public InferNullityAnnotationsAction() {
@Override
@RequiredUIAccess
protected void analyze(@Nonnull Project project, @Nonnull AnalysisScope scope) {
boolean annotateLocaVars = myAnnotateLocalVariablesCb.getValueOrError();
ApplicationPropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, annotateLocaVars);
boolean annotateLocalVars = myAnnotateLocalVariablesCb.getValueOrError();
ApplicationPropertiesComponent.getInstance().setValue(ANNOTATE_LOCAL_VARIABLES, annotateLocalVars);
myAnnotateLocalVariablesCb = null;

ProgressManager progressManager = ProgressManager.getInstance();
Expand Down Expand Up @@ -150,16 +150,16 @@ else if (javaPsiFacade.findClass(
return;
}
PsiDocumentManager.getInstance(project).commitAllDocuments();
UsageInfo[] usageInfos = findUsages(annotateLocaVars, project, scope, fileCount[0]);
UsageInfo[] usageInfos = findUsages(annotateLocalVars, project, scope, fileCount[0]);
if (usageInfos == null) {
return;
}

processUsages(annotateLocaVars, project, scope, usageInfos);
processUsages(annotateLocalVars, project, scope, usageInfos);
}

protected void processUsages(
boolean annotateLocaVars,
boolean annotateLocalVars,
@Nonnull Project project,
@Nonnull AnalysisScope scope,
@Nonnull UsageInfo[] usageInfos
Expand All @@ -168,7 +168,7 @@ protected void processUsages(
applyRunnable(project, () -> usageInfos).run();
}
else {
showUsageView(annotateLocaVars, project, usageInfos, scope);
showUsageView(annotateLocalVars, project, usageInfos, scope);
}
}

Expand All @@ -185,7 +185,7 @@ public static boolean addAnnotationsDependency(
message += StringUtil.join(modulesWithoutAnnotations, Module::getName, ", ");
message += (modulesWithoutAnnotations.size() == 1 ? " doesn't" : " don't");
message += " refer to the existing '" + annotationsLib.getName() + "' library" +
" with Consulo nullity annotations. Would you like to add the dependenc";
" with Consulo nullity annotations. Would you like to add the dependency";
message += (modulesWithoutAnnotations.size() == 1 ? "y" : "ies") + " now?";
if (Messages.showOkCancelDialog(project, message, title.get(), UIUtil.getErrorIcon()) == Messages.OK) {
project.getApplication().runWriteAction(() ->
Expand All @@ -199,26 +199,37 @@ public static boolean addAnnotationsDependency(
return false;
}

/*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. " +
"It is possible to configure custom JAR\nin e.g. Constant Conditions & Exceptions inspection or use JetBrains annotations available in installation. " + "\nIntelliJ IDEA nullity " +
"annotations are freely usable and redistributable under the Apache 2.0 license.\nWould you like to do it now?", title, Messages.getErrorIcon()) == Messages.OK)
{
Module firstModule = modulesWithoutAnnotations.iterator().next();
JavaProjectModelModificationService.getInstance(project).addDependency(modulesWithoutAnnotations, JetBrainsAnnotationsExternalLibraryResolver.getAnnotationsLibraryDescriptor(firstModule)
, DependencyScope.COMPILE);
return true;
} */
/*
if (Messages.showOkCancelDialog(
project,
"It is required that JetBrains annotations be available in all your project sources.\n\n" +
"You will need to add annotations.jar as a library. It is possible to configure custom JAR\n" +
"in e.g. Constant Conditions & Exceptions inspection or use JetBrains annotations available in installation.\n" +
"IntelliJ IDEA nullity annotations are freely usable and redistributable under the Apache 2.0 license.\n" +
"Would you like to do it now?",
title,
Messages.getErrorIcon()
) == Messages.OK) {
Module firstModule = modulesWithoutAnnotations.iterator().next();
JavaProjectModelModificationService.getInstance(project).addDependency(
modulesWithoutAnnotations,
JetBrainsAnnotationsExternalLibraryResolver.getAnnotationsLibraryDescriptor(firstModule),
DependencyScope.COMPILE
);
return true;
}
*/
return false;
}

@Nullable
protected UsageInfo[] findUsages(
boolean annotateLocaVars,
boolean annotateLocalVars,
@Nonnull Project project,
@Nonnull AnalysisScope scope,
int fileCount
) {
NullityInferrer inferrer = new NullityInferrer(annotateLocaVars, project);
NullityInferrer inferrer = new NullityInferrer(annotateLocalVars, project);
PsiManager psiManager = PsiManager.getInstance(project);
Runnable searchForUsages = () -> scope.accept(new PsiElementVisitor() {
int myFileCount;
Expand All @@ -235,7 +246,7 @@ public void visitFile(PsiFile file) {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
if (progressIndicator != null) {
progressIndicator.setText2(ProjectUtil.calcRelativeToProjectPath(virtualFile, project));
progressIndicator.setFraction(((double)myFileCount) / fileCount);
progressIndicator.setFraction(((double) myFileCount) / fileCount);
}
if (file instanceof PsiJavaFile) {
inferrer.collect(file);
Expand Down Expand Up @@ -309,7 +320,7 @@ protected void restartAnalysis(Project project, AnalysisScope scope) {
}

private void showUsageView(
boolean annotateLocaVars,
boolean annotateLocalVars,
@Nonnull Project project,
UsageInfo[] usageInfos,
@Nonnull AnalysisScope scope
Expand All @@ -334,19 +345,20 @@ private void showUsageView(
presentation.setTabText("Infer Nullity Preview");
presentation.setShowReadOnlyStatusAsRed(true);
presentation.setShowCancelButton(true);
presentation.setUsagesString(RefactoringLocalize.usageviewUsagestext().get());
presentation.setUsagesString(RefactoringLocalize.usageviewUsagestext());

UsageView usageView =
UsageViewManager.getInstance(project).showUsages(targets, usages, presentation, rerunFactory(annotateLocaVars, project, scope));
UsageViewManager.getInstance(project).showUsages(targets, usages, presentation, rerunFactory(annotateLocalVars, project, scope));

Runnable refactoringRunnable = applyRunnable(project, () ->
{
Set<UsageInfo> infos = UsageViewUtil.getNotExcludedUsageInfos(usageView);
return infos.toArray(new UsageInfo[infos.size()]);
});

String canNotMakeString =
"Cannot perform operation.\nThere were changes in code after usages have been found.\nPlease perform operation search again.";
String canNotMakeString = "Cannot perform operation.\n" +
"There were changes in code after usages have been found.\n" +
"Please perform operation search again.";

usageView.addPerformOperationAction(
refactoringRunnable,
Expand All @@ -359,7 +371,7 @@ private void showUsageView(

@Nonnull
private Supplier<UsageSearcher> rerunFactory(
boolean annotateLocaVars,
boolean annotateLocalVars,
@Nonnull Project project,
@Nonnull AnalysisScope scope
) {
Expand All @@ -368,7 +380,7 @@ private Supplier<UsageSearcher> rerunFactory(
@Override
protected UsageInfo[] findUsages() {
return ObjectUtil.notNull(
InferNullityAnnotationsAction.this.findUsages(annotateLocaVars, project, scope, scope.getFileCount()),
InferNullityAnnotationsAction.this.findUsages(annotateLocalVars, project, scope, scope.getFileCount()),
UsageInfo.EMPTY_ARRAY
);
}
Expand All @@ -380,8 +392,8 @@ public void generate(@Nonnull Predicate<Usage> processor) {
};
}

@RequiredUIAccess
@Override
@RequiredUIAccess
protected void extendMainLayout(BaseAnalysisActionDialog dialog, VerticalLayout layout, Project project) {
myAnnotateLocalVariablesCb =
CheckBox.create(LocalizeValue.localizeTODO("Annotate local variables"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
@ActionImpl(id = "JavaNewClass", parents = @ActionParentRef(value = @ActionRef(id = "NewGroup1"), anchor = ActionRefAnchor.FIRST))
public class CreateClassAction extends JavaCreateTemplateInPackageAction<PsiClass> implements DumbAware {
public CreateClassAction() {
super(LocalizeValue.empty(), LocalizeValue.empty(), PlatformIconGroup.nodesClass(), true);
super(JavaLocalize.actionNewClassText(), JavaLocalize.actionNewClassDescription(), PlatformIconGroup.nodesClass(), true);
}

@Override
Expand Down Expand Up @@ -100,14 +100,14 @@ public String getErrorText(String inputString) {
return null;
}

@RequiredUIAccess
@Override
@RequiredUIAccess
public boolean checkInput(String inputString) {
return true;
}

@RequiredUIAccess
@Override
@RequiredUIAccess
public boolean canClose(String inputString) {
return !StringUtil.isEmptyOrSpaces(inputString) && getErrorText(inputString) == null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public final class GenerateJavadocAction extends BaseAnalysisAction {

public GenerateJavadocAction() {
super(
JavaLocalize.actionGeneratejavadocText(),
JavaLocalize.actionGeneratejavadocDescription(),
JavaLocalize.actionGenerateJavadocText(),
JavaLocalize.actionGenerateJavadocDescription(),
JavadocLocalize.javadocGenerateTitle(),
JavadocLocalize.javadocGenerateTitle()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@ActionImpl(id = "InvertBoolean")
public class InvertBooleanAction extends BaseRefactoringAction {
public InvertBooleanAction() {
super(JavaLocalize.actionInvertbooleanText(), JavaLocalize.actionInvertbooleanText());
super(JavaLocalize.actionInvertBooleanText(), JavaLocalize.actionInvertBooleanDescription());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@ActionImpl(id = "MakeStatic")
public class MakeStaticAction extends BaseRefactoringAction {
public MakeStaticAction() {
super(JavaLocalize.actionMakestaticText(), JavaLocalize.actionMakestaticDescription());
super(JavaLocalize.actionMakeStaticText(), JavaLocalize.actionMakeStaticDescription());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SliceBackwardAction extends CodeInsightAction {
private final SliceHandler myHandler = new SliceHandler(true);

public SliceBackwardAction() {
super(JavaLocalize.actionSlicebackwardText(), JavaLocalize.actionSlicebackwardDescription());
super(JavaLocalize.actionSliceBackwardText(), JavaLocalize.actionSliceBackwardDescription());
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SliceForwardAction extends CodeInsightAction {
private final SliceHandler myHandler = new SliceForwardHandler();

public SliceForwardAction() {
super(JavaLocalize.actionSliceforwardText(), JavaLocalize.actionSliceforwardDescription());
super(JavaLocalize.actionSliceForwardText(), JavaLocalize.actionSliceForwardDescription());
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@ActionImpl(id = "GenerateDataMethod")
public class GenerateDataMethodAction extends BaseGenerateTestSupportMethodAction {
public GenerateDataMethodAction() {
super(TestIntegrationUtils.MethodKind.DATA, JavaLocalize.actionGeneratedatamethodText());
super(TestIntegrationUtils.MethodKind.DATA, JavaLocalize.actionGenerateDataMethodText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@ActionImpl(id = "GenerateSetUpMethod")
public class GenerateSetUpMethodAction extends BaseGenerateTestSupportMethodAction {
public GenerateSetUpMethodAction() {
super(TestIntegrationUtils.MethodKind.SET_UP, JavaLocalize.actionGeneratesetupmethodText());
super(TestIntegrationUtils.MethodKind.SET_UP, JavaLocalize.actionGenerateSetUpMethodText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@ActionImpl(id = "GenerateTearDownMethod")
public class GenerateTearDownMethodAction extends BaseGenerateTestSupportMethodAction {
public GenerateTearDownMethodAction() {
super(TestIntegrationUtils.MethodKind.TEAR_DOWN, JavaLocalize.actionGenerateteardownmethodText());
super(TestIntegrationUtils.MethodKind.TEAR_DOWN, JavaLocalize.actionGenerateTearDownMethodText());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
@ActionImpl(id = "GenerateTestMethod")
public class GenerateTestMethodAction extends BaseGenerateTestSupportMethodAction {
public GenerateTestMethodAction() {
super(TestIntegrationUtils.MethodKind.TEST, JavaLocalize.actionGeneratetestmethodText());
super(TestIntegrationUtils.MethodKind.TEST, JavaLocalize.actionGenerateTestMethodText());
}
}
Loading
Loading