mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] IDEA-247643: Add more NLS annotations to annotator
GitOrigin-RevId: c82f7cdb31fc2fbc579ead5911f6151764fcfb05
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ae0b2c41ae
commit
defc272b54
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.light;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
@@ -6,6 +6,7 @@ import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentationProviders;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.ElementPresentationUtil;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
@@ -20,6 +21,7 @@ import com.intellij.ui.icons.RowIcon;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -48,17 +50,17 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
setContainingClass(constructedClass);
|
||||
}
|
||||
|
||||
public LightMethodBuilder(PsiManager manager, String name) {
|
||||
public LightMethodBuilder(PsiManager manager, @NlsSafe String name) {
|
||||
this(manager, JavaLanguage.INSTANCE, name);
|
||||
}
|
||||
|
||||
public LightMethodBuilder(PsiManager manager, Language language, String name) {
|
||||
public LightMethodBuilder(PsiManager manager, Language language, @NlsSafe String name) {
|
||||
this(manager, language, name, new LightParameterListBuilder(manager, language), new LightModifierList(manager, language));
|
||||
}
|
||||
|
||||
public LightMethodBuilder(PsiManager manager,
|
||||
Language language,
|
||||
String name,
|
||||
@NlsSafe String name,
|
||||
PsiParameterList parameterList,
|
||||
PsiModifierList modifierList) {
|
||||
this(manager, language, name, parameterList, modifierList,
|
||||
@@ -68,7 +70,7 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
|
||||
public LightMethodBuilder(PsiManager manager,
|
||||
Language language,
|
||||
@NotNull String name,
|
||||
@NlsSafe @NotNull String name,
|
||||
PsiParameterList parameterList,
|
||||
PsiModifierList modifierList,
|
||||
PsiReferenceList throwsList,
|
||||
@@ -151,12 +153,12 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
return this;
|
||||
}
|
||||
|
||||
public LightMethodBuilder addModifier(String modifier) {
|
||||
public LightMethodBuilder addModifier(@NlsSafe String modifier) {
|
||||
((LightModifierList)myModifierList).addModifier(modifier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LightMethodBuilder setModifiers(String... modifiers) {
|
||||
public LightMethodBuilder setModifiers(@NlsSafe String... modifiers) {
|
||||
((LightModifierList)myModifierList).clearModifiers();
|
||||
addModifiers(modifiers);
|
||||
return this;
|
||||
@@ -176,7 +178,7 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
return setMethodReturnType(new Computable.PredefinedValueComputable<>(returnType));
|
||||
}
|
||||
|
||||
public LightMethodBuilder setMethodReturnType(@NotNull final String returnType) {
|
||||
public LightMethodBuilder setMethodReturnType(@NlsSafe @NotNull final String returnType) {
|
||||
return setMethodReturnType(new Computable.NotNullCachedComputable<PsiType>() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -202,15 +204,15 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
return this;
|
||||
}
|
||||
|
||||
public LightMethodBuilder addParameter(@NotNull String name, @NotNull String type) {
|
||||
public LightMethodBuilder addParameter(@NlsSafe @NotNull String name, @NlsSafe @NotNull String type) {
|
||||
return addParameter(name, JavaPsiFacade.getElementFactory(getProject()).createTypeFromText(type, this));
|
||||
}
|
||||
|
||||
public LightMethodBuilder addParameter(@NotNull String name, @NotNull PsiType type) {
|
||||
public LightMethodBuilder addParameter(@NlsSafe @NotNull String name, @NotNull PsiType type) {
|
||||
return addParameter(new LightParameter(name, type, this, JavaLanguage.INSTANCE));
|
||||
}
|
||||
|
||||
public LightMethodBuilder addParameter(@NotNull String name, @NotNull PsiType type, boolean isVarArgs) {
|
||||
public LightMethodBuilder addParameter(@NlsSafe @NotNull String name, @NotNull PsiType type, boolean isVarArgs) {
|
||||
if (isVarArgs && !(type instanceof PsiEllipsisType)) {
|
||||
type = new PsiEllipsisType(type);
|
||||
}
|
||||
@@ -222,7 +224,7 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
return this;
|
||||
}
|
||||
|
||||
public LightMethodBuilder addException(String fqName) {
|
||||
public LightMethodBuilder addException(@NlsSafe String fqName) {
|
||||
((LightReferenceListBuilder)myThrowsList).addReference(fqName);
|
||||
return this;
|
||||
}
|
||||
@@ -408,11 +410,12 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@NonNls
|
||||
public String getOriginInfo() {
|
||||
return myOriginInfo;
|
||||
}
|
||||
|
||||
public void setOriginInfo(@Nullable String originInfo) {
|
||||
public void setOriginInfo(@Nullable @NonNls String originInfo) {
|
||||
myOriginInfo = originInfo;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.annotator.checkers;
|
||||
|
||||
import com.intellij.codeInspection.util.InspectionMessage;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -30,7 +31,7 @@ public class AnnotationCollectorChecker extends CustomAnnotationChecker {
|
||||
final PsiClass clazz = (PsiClass)annotation.getClassReference().resolve();
|
||||
if (clazz == null) return true;
|
||||
final GrAnnotationNameValuePair[] attributes = annotation.getParameterList().getAttributes();
|
||||
Pair<PsiElement, String> r = CustomAnnotationChecker.checkAnnotationArguments(clazz, attributes, false);
|
||||
Pair<PsiElement, @InspectionMessage String> r = CustomAnnotationChecker.checkAnnotationArguments(clazz, attributes, false);
|
||||
if (r != null && r.getFirst() != null) {
|
||||
holder.newAnnotation(HighlightSeverity.ERROR, r.getSecond()).range(r.getFirst()).create();
|
||||
}
|
||||
|
||||
+9
-5
@@ -47,12 +47,16 @@ public abstract class BaseInspectionVisitor extends GroovyElementVisitor {
|
||||
registerError(statementToken, args);
|
||||
}
|
||||
|
||||
private static @InspectionMessage @NotNull String nlsNotNullize(@InspectionMessage @Nullable String s) {
|
||||
return StringUtil.notNullize(s); // NON-NLS
|
||||
}
|
||||
|
||||
protected void registerError(PsiElement location) {
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
final LocalQuickFix[] fix = createFixes(location);
|
||||
String description = StringUtil.notNullize(inspection.buildErrorString(location));
|
||||
String description = nlsNotNullize(inspection.buildErrorString(location));
|
||||
|
||||
registerError(location, description, fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
|
||||
}
|
||||
@@ -62,7 +66,7 @@ public abstract class BaseInspectionVisitor extends GroovyElementVisitor {
|
||||
return;
|
||||
}
|
||||
final LocalQuickFix[] fixes = createFixes(method);
|
||||
String description = StringUtil.notNullize(inspection.buildErrorString(args));
|
||||
String description = nlsNotNullize(inspection.buildErrorString(args));
|
||||
|
||||
registerError(method.getNameIdentifierGroovy(), description, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
|
||||
}
|
||||
@@ -72,7 +76,7 @@ public abstract class BaseInspectionVisitor extends GroovyElementVisitor {
|
||||
return;
|
||||
}
|
||||
final LocalQuickFix[] fix = createFixes(variable);
|
||||
final String description = StringUtil.notNullize(inspection.buildErrorString(args));
|
||||
final String description = nlsNotNullize(inspection.buildErrorString(args));
|
||||
registerError(variable.getNameIdentifierGroovy(), description, fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
|
||||
}
|
||||
|
||||
@@ -81,7 +85,7 @@ public abstract class BaseInspectionVisitor extends GroovyElementVisitor {
|
||||
return;
|
||||
}
|
||||
final LocalQuickFix[] fixes = createFixes(method);
|
||||
final String description = StringUtil.notNullize(inspection.buildErrorString(args));
|
||||
final String description = nlsNotNullize(inspection.buildErrorString(args));
|
||||
|
||||
final GrExpression invoked = method.getInvokedExpression();
|
||||
final PsiElement nameElement = ((GrReferenceExpression)invoked).getReferenceNameElement();
|
||||
@@ -104,7 +108,7 @@ public abstract class BaseInspectionVisitor extends GroovyElementVisitor {
|
||||
ProblemHighlightType highlightType,
|
||||
Object... args) {
|
||||
final LocalQuickFix[] fix = createFixes(location);
|
||||
final String description = StringUtil.notNullize(inspection.buildErrorString(args));
|
||||
final String description = nlsNotNullize(inspection.buildErrorString(args));
|
||||
registerError(location, description, fix, highlightType);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -56,7 +57,7 @@ public final class GrInspectionUtil {
|
||||
return HighlightInfo.newHighlightInfo(highlightInfoType).range(refNameElement).descriptionAndTooltip(message).create();
|
||||
}
|
||||
|
||||
public static void replaceExpression(GrExpression expression, String newExpression) {
|
||||
public static void replaceExpression(GrExpression expression, @NlsSafe String newExpression) {
|
||||
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(expression.getProject());
|
||||
final GrExpression newCall = factory.createExpressionFromText(newExpression, expression.getContext());
|
||||
expression.replaceWithExpression(newCall, true);
|
||||
|
||||
+4
-19
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.codeInspection.changeToMethod.transformations;
|
||||
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.impl.utils.ParenthesesUtils.METHOD_CALL_PRECEDENCE;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.impl.utils.ParenthesesUtils.checkPrecedenceForNonBinaryOps;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.impl.utils.ParenthesesUtils.parenthesize;
|
||||
import static org.jetbrains.plugins.groovy.lang.psi.impl.utils.ParenthesesUtils.*;
|
||||
|
||||
public abstract class Transformation<T extends GrExpression> {
|
||||
|
||||
@@ -42,7 +27,7 @@ public abstract class Transformation<T extends GrExpression> {
|
||||
|
||||
protected abstract void apply(@NotNull T expression);
|
||||
|
||||
public abstract String getMethod();
|
||||
public abstract @NlsSafe String getMethod();
|
||||
|
||||
@NotNull
|
||||
GrExpression addParenthesesIfNeeded(@NotNull GrExpression expression) {
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import groovy.lang.GroovyObjectSupport;
|
||||
import groovy.lang.MetaMethod;
|
||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
||||
import org.codehaus.groovy.runtime.InvokerHelper;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.dsl.dsltop.GdslMembersProvider;
|
||||
@@ -41,7 +42,7 @@ import java.util.function.Consumer;
|
||||
public class CustomMembersGenerator extends GroovyObjectSupport implements GdslMembersHolderConsumer {
|
||||
private static final Logger LOG = Logger.getInstance(CustomMembersGenerator.class);
|
||||
private static final GdslMembersProvider[] PROVIDERS = GdslMembersProvider.EP_NAME.getExtensions();
|
||||
public static final String THROWS = "throws";
|
||||
public static final @NonNls String THROWS = "throws";
|
||||
private FList<Map> myDeclarations = FList.emptyList();
|
||||
private final Project myProject;
|
||||
private final CompoundMembersHolder myDepot = new CompoundMembersHolder();
|
||||
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.psi;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -150,13 +151,13 @@ public abstract class GroovyPsiElementFactory implements JVMElementFactory {
|
||||
public abstract GrCodeReferenceElement createCodeReference(@NotNull String text, @Nullable PsiElement context);
|
||||
|
||||
@NotNull
|
||||
public GrExpression createExpressionFromText(@NotNull CharSequence exprText) {
|
||||
public GrExpression createExpressionFromText(@NotNull @NlsSafe CharSequence exprText) {
|
||||
return createExpressionFromText(exprText.toString(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public abstract GrExpression createExpressionFromText(@NotNull String exprText, @Nullable PsiElement context);
|
||||
public abstract GrExpression createExpressionFromText(@NlsSafe @NotNull String exprText, @Nullable PsiElement context);
|
||||
|
||||
@NotNull
|
||||
public abstract GrVariableDeclaration createFieldDeclaration(String @NotNull [] modifiers, @NotNull String identifier, @Nullable GrExpression initializer, @Nullable PsiType type);
|
||||
|
||||
+3
-15
@@ -1,21 +1,8 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.CallEnvironment;
|
||||
@@ -94,6 +81,7 @@ public class InstructionImpl implements Instruction {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
protected String getElementPresentation() {
|
||||
//return "element: " + (myPsiElement != null ? myPsiElement.getText() : null);
|
||||
return "element: " + myPsiElement;
|
||||
|
||||
Reference in New Issue
Block a user