[groovy, i18n] IDEA-247643: Add more NLS-related annotations

GitOrigin-RevId: 7f8d5e80445263e602c926a619f70c9d0d5da45c
This commit is contained in:
Konstantin Nisht
2020-08-20 18:25:43 +03:00
committed by intellij-monorepo-bot
parent 7a5e59b40a
commit efa9fa1a1c
58 changed files with 228 additions and 199 deletions

View File

@@ -1,20 +1,7 @@
/*
* Copyright 2000-2015 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 com.intellij.psi.impl.light;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiTypeParameter;
import com.intellij.psi.PsiTypeParameterListOwner;
@@ -27,7 +14,7 @@ public class LightTypeParameterBuilder extends LightPsiClassBuilder implements P
private final PsiTypeParameterListOwner myOwner;
private final int myIndex;
public LightTypeParameterBuilder(@NotNull String name, PsiTypeParameterListOwner owner, int index) {
public LightTypeParameterBuilder(@NlsSafe @NotNull String name, PsiTypeParameterListOwner owner, int index) {
super(owner, name);
myOwner = owner;
myIndex = index;

View File

@@ -12,6 +12,7 @@ import com.intellij.ui.IconManager;
import com.intellij.ui.icons.RowIcon;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.PlatformIcons;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -149,7 +150,7 @@ public abstract class LightVariableBase extends LightElement implements PsiVaria
return myOriginInfo;
}
public void setOriginInfo(String originInfo) {
public void setOriginInfo(@NonNls String originInfo) {
myOriginInfo = originInfo;
}
}

View File

@@ -688,6 +688,7 @@ inspection.message.traits.0.contain.clashing.methods.with.signature.1=Traits {0}
inspection.message.unused.catch.parameter.ref=Unused catch parameter '#ref' #loc
inspection.message.package.name.mismatch.actual.0.expected.1=Package name mismatch. Actual: ''{0}'', expected: ''{1}''
inspection.message.property.not.indexable.type.must.be.array.or.list.but.found.0=Property is not indexable. Type must be array or list but found {0}
inspection.message.type.argument.0.can.not.be.1=Type of argument ''{0}'' can not be ''{1}''
text.class.0.is.unused=Class {0} is unused
text.constructor.0.is.unused=Constructor {0} is unused
text.method.0.is.unused=Method {0} is unused

View File

@@ -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 org.jetbrains.plugins.groovy.builder;
import com.intellij.psi.PsiClass;
@@ -6,6 +6,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.PsiType;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
@@ -19,6 +20,7 @@ import static org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesT
public class JsonBuilderContributor extends BuilderMethodsContributor {
private static final String FQN = "groovy.json.JsonBuilder";
@NonNls
static final String ORIGIN_INFO = "via JsonBuilder";
@Nullable

View File

@@ -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 org.jetbrains.plugins.groovy.builder;
import com.intellij.psi.PsiClass;
@@ -6,6 +6,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
import com.intellij.util.Processor;
import groovy.lang.Closure;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierFlags;
@@ -15,11 +16,12 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter;
import static com.intellij.psi.CommonClassNames.JAVA_UTIL_MAP;
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_LANG_CLOSURE;
import static org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesToUtilKt.DELEGATES_TO_TYPE_KEY;
import static org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesToUtilKt.DELEGATES_TO_STRATEGY_KEY;
import static org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesToUtilKt.DELEGATES_TO_TYPE_KEY;
public class StreamingJsonBuilderContributor extends BuilderMethodsContributor {
@NonNls
static final String ORIGIN_INFO = "via StreamingJsonBuilder";
@Nullable

View File

@@ -1,10 +1,11 @@
// 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.builder;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiType;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod;
@@ -17,7 +18,7 @@ import static org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.GrDelegatesT
public class XmlMarkupBuilderNonCodeMemberContributor extends BuilderMethodsContributor {
private static final String FQN = "groovy.xml.MarkupBuilder";
private static final String ORIGIN_INFO = "via MarkupBuilder";
@NonNls private static final String ORIGIN_INFO = "via MarkupBuilder";
@Nullable
@Override

View File

@@ -1,23 +1,11 @@
/*
* 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;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.util.NlsContexts.DetailedDescription;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiType;
import org.jetbrains.plugins.groovy.lang.GrCreateClassKind;
@@ -64,21 +52,21 @@ public abstract class GroovyQuickFixFactory {
public abstract GroovyFix createReplaceWithImportFix();
public abstract LocalQuickFix createGrMoveToDirFix(String actual);
public abstract LocalQuickFix createGrMoveToDirFix(@NlsSafe String actual);
public abstract LocalQuickFix createCreateFieldFromConstructorLabelFix(GrTypeDefinition element, GrNamedArgument argument);
public abstract LocalQuickFix createDynamicPropertyFix(GrArgumentLabel label, PsiClass element);
public abstract GroovyFix createAddMethodFix(String methodName, GrTypeDefinition aClass);
public abstract GroovyFix createAddMethodFix(@NlsSafe String methodName, GrTypeDefinition aClass);
public abstract GroovyFix createAddClassToExtendsFix(GrTypeDefinition aClass, String comparable);
public abstract GroovyFix createAddClassToExtendsFix(GrTypeDefinition aClass, @NlsSafe String comparable);
public abstract IntentionAction createOptimizeImportsFix(boolean onTheFly);
public abstract IntentionAction createRemoveUnusedGrParameterFix(GrParameter parameter);
public abstract IntentionAction createInvestigateFix(String reason);
public abstract IntentionAction createInvestigateFix(@DetailedDescription String reason);
public abstract GroovyFix createMultipleAssignmentFix(int size);

View File

@@ -3,6 +3,7 @@ package org.jetbrains.plugins.groovy.codeInspection.bugs;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.util.IncorrectOperationException;
@@ -108,6 +109,9 @@ public class GroovyRangeTypeCheckInspection extends BaseInspection {
}
private static class MyVisitor extends BaseInspectionVisitor {
@NlsSafe private static final String CALL_NEXT = "next()";
@NlsSafe private static final String CALL_PREVIOUS = "previous()";
@Override
public void visitRangeExpression(@NotNull GrRangeExpression range) {
super.visitRangeExpression(range);
@@ -119,10 +123,10 @@ public class GroovyRangeTypeCheckInspection extends BaseInspection {
final GroovyResolveResult[] nexts = ResolveUtil.getMethodCandidates(iterationType, "next", range, PsiType.EMPTY_ARRAY);
final GroovyResolveResult[] previouses = ResolveUtil.getMethodCandidates(iterationType, "previous", range, PsiType.EMPTY_ARRAY);
if (nexts.length == 0) {
registerError(range, iterationType.getPresentableText(), "next()");
registerError(range, iterationType.getPresentableText(), CALL_NEXT);
}
if (previouses.length == 0) {
registerError(range, iterationType.getPresentableText(), "previous()");
registerError(range, iterationType.getPresentableText(), CALL_PREVIOUS);
}
if (!InheritanceUtil.isInheritor(iterationType, CommonClassNames.JAVA_LANG_COMPARABLE)) {

View File

@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.codeInspection.exception;
import com.intellij.codeInsight.intention.QuickFixFactory;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyBundle;
@@ -37,6 +38,8 @@ public class GroovyUnusedCatchParameterInspection extends BaseInspection {
private static class Visitor extends BaseInspectionVisitor {
@NlsSafe private static final String IGNORED = "ignored";
@Override
public void visitCatchClause(@NotNull GrCatchClause catchClause) {
super.visitCatchClause(catchClause);
@@ -54,7 +57,7 @@ public class GroovyUnusedCatchParameterInspection extends BaseInspection {
if (!visitor.isUsed()) {
final PsiElement nameIdentifier = parameter.getNameIdentifierGroovy();
registerError(nameIdentifier, GroovyBundle.message("inspection.message.unused.catch.parameter.ref"),
new LocalQuickFix[]{QuickFixFactory.getInstance().createRenameElementFix(parameter, "ignored")},
new LocalQuickFix[]{QuickFixFactory.getInstance().createRenameElementFix(parameter, IGNORED)},
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}

View File

@@ -1,6 +1,4 @@
// Copyright 2000-2017 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.codeInspection.naming;
import com.intellij.codeInspection.LocalQuickFix;
@@ -14,13 +12,16 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.siyeh.ig.naming.ClassNamingConvention;
import com.siyeh.ig.naming.NewClassNamingConventionInspection;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.codeInspection.GroovyQuickFixFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
public class NewGroovyClassNamingConventionInspection extends AbstractNamingConventionInspection<PsiClass> {
@NonNls private static final String GROOVY = "Groovy";
public NewGroovyClassNamingConventionInspection() {
super(NewClassNamingConventionInspection.EP_NAME.getExtensionList(), "Groovy" + ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
super(NewClassNamingConventionInspection.EP_NAME.getExtensionList(), GROOVY + ClassNamingConvention.CLASS_NAMING_CONVENTION_SHORT_NAME);
registerConventionsListener(NewClassNamingConventionInspection.EP_NAME);
}
@@ -40,7 +41,7 @@ public class NewGroovyClassNamingConventionInspection extends AbstractNamingConv
public String getShortName() {
String shortName = ex.getShortName();
if (shortName.startsWith("JUnit")) return shortName;
return "Groovy" + (shortName.startsWith("Enum") ? "EnumerationNamingConvention" : shortName);
return GROOVY + (shortName.startsWith("Enum") ? "EnumerationNamingConvention" : shortName);
}
@Override

View File

@@ -15,6 +15,7 @@
*/
package org.jetbrains.plugins.groovy.codeInspection.threading;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
@@ -31,7 +32,7 @@ import java.util.Set;
public class GroovyThreadStopSuspendResumeInspection extends BaseInspection {
private static final Set<String> METHOD_NAMES = new HashSet<>();
private static final Set<@NlsSafe String> METHOD_NAMES = new HashSet<>();
static {
METHOD_NAMES.add("stop");

View File

@@ -175,7 +175,7 @@ public class GroovyTypeCheckVisitor extends BaseInspectionVisitor {
registerError(
namedArgumentExpression,
ProblemHighlightType.GENERIC_ERROR,
"Type of argument '" + labelName + "' can not be '" + expressionType.getPresentableText() + "'"
GroovyBundle.message("inspection.message.type.argument.0.can.not.be.1", labelName,expressionType.getPresentableText())
);
}
}
@@ -646,7 +646,7 @@ public class GroovyTypeCheckVisitor extends BaseInspectionVisitor {
@Override
protected void registerError(@NotNull PsiElement location,
ProblemHighlightType highlightType,
Object... args) {
@InspectionMessage Object... args) {
registerError(location, (String)args[0], LocalQuickFix.EMPTY_ARRAY, highlightType);
}
}

View File

@@ -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 org.jetbrains.plugins.groovy.dsl.holders;
import com.intellij.openapi.diagnostic.Logger;
@@ -10,6 +10,7 @@ import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.dsl.CustomMembersGenerator;
@@ -96,7 +97,7 @@ public class NonCodeMembersHolder implements CustomMembersHolder {
}
@Nullable
private static ClosureDescriptor createClosureDescriptor(Map prop) {
private static ClosureDescriptor createClosureDescriptor(@NonNls Map prop) {
final ClosureDescriptor closure = new ClosureDescriptor();
final Object method = prop.get("method");
@@ -120,7 +121,7 @@ public class NonCodeMembersHolder implements CustomMembersHolder {
return closure;
}
private static GrLightMethodBuilder createMethod(Map prop, PsiElement place, PsiManager manager) {
private static GrLightMethodBuilder createMethod(@NonNls Map prop, PsiElement place, PsiManager manager) {
String name = String.valueOf(prop.get("name"));
final GrLightMethodBuilder method = new GrLightMethodBuilder(manager, name).addModifier(PsiModifier.PUBLIC);

View File

@@ -1,10 +1,12 @@
// 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.ext.newify
import com.intellij.openapi.util.NlsSafe
import com.intellij.psi.*
import com.intellij.psi.impl.light.LightMethodBuilder
import com.intellij.psi.scope.PsiScopeProcessor
import com.intellij.psi.util.parentsWithSelf
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.GroovyLanguage
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
@@ -23,9 +25,21 @@ import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassProcessor
import org.jetbrains.plugins.groovy.lang.resolve.shouldProcessMethods
import java.util.regex.PatternSyntaxException
internal const val newifyAnnotationFqn = "groovy.lang.Newify"
@NlsSafe internal const val newifyAnnotationFqn = "groovy.lang.Newify"
@NonNls
internal const val newifyOriginInfo = "by @Newify"
interface GrNewifyAttributes {
companion object {
@NlsSafe
public const val VALUE = "value"
@NlsSafe
public const val AUTO = "auto"
@NlsSafe
public const val NEW = "new"
}
}
class NewifyMemberContributor : NonCodeMembersContributor() {
override fun processDynamicElements(qualifierType: PsiType,
aClass: PsiClass?,
@@ -50,15 +64,15 @@ class NewifyMemberContributor : NonCodeMembersContributor() {
for (annotation in newifyAnnotations) {
if (qualifier == null) {
val newifiedClasses = getClassArrayValue(annotation, "value", true)
val newifiedClasses = getClassArrayValue(annotation, GrNewifyAttributes.VALUE, true)
newifiedClasses
.filter { psiClass -> GrStaticChecker.isStaticsOK(psiClass, place, psiClass, false) }
.flatMap { buildConstructors(it, it.name) }
.forEach { ResolveUtil.processElement(processor, it, state) }
}
val createNewMethods = GrAnnotationUtil.inferBooleanAttributeNotNull(annotation, "auto")
val createNewMethods = GrAnnotationUtil.inferBooleanAttributeNotNull(annotation, GrNewifyAttributes.AUTO)
if (type != null && createNewMethods) {
buildConstructors(type, "new").forEach {
buildConstructors(type, GrNewifyAttributes.NEW).forEach {
ResolveUtil.processElement(processor, it, state)
}
}

View File

@@ -1,31 +1,17 @@
/*
* 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.ext.spock;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import java.util.Set;
public interface SpockConstants {
@NonNls String SETUP_METHOD_NAME = "setup";
@NonNls String CLEANUP_METHOD_NAME = "cleanup";
@NonNls String SETUP_SPEC_METHOD_NAME = "setupSpec";
@NonNls String CLEANUP_SPEC_METHOD_NAME = "cleanupSpec";
@NlsSafe String SETUP_METHOD_NAME = "setup";
@NlsSafe String CLEANUP_METHOD_NAME = "cleanup";
@NlsSafe String SETUP_SPEC_METHOD_NAME = "setupSpec";
@NlsSafe String CLEANUP_SPEC_METHOD_NAME = "cleanupSpec";
Set<String> FIXTURE_METHOD_NAMES = ContainerUtil.immutableSet(
SETUP_METHOD_NAME,

View File

@@ -1,6 +1,7 @@
// 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.ext.spock;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.util.IncorrectOperationException;
@@ -24,6 +25,8 @@ import java.util.regex.Pattern;
public class SpockUnrollReferenceProvider extends PsiReferenceProvider {
private static final Pattern PATTERN = Pattern.compile("\\#([\\w_]+)");
@NlsSafe private static final String UNROLL = "Unroll";
@NlsSafe private static final String SPOCK_LANG_UNROLL = "spock.lang.Unroll";
@Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
@@ -41,7 +44,7 @@ public class SpockUnrollReferenceProvider extends PsiReferenceProvider {
GrAnnotation annotation = (GrAnnotation)eAnnotation;
String shortName = annotation.getShortName();
if (!shortName.equals("Unroll") && !shortName.equals("spock.lang.Unroll")) return PsiReference.EMPTY_ARRAY;
if (!shortName.equals(UNROLL) && !shortName.equals(SPOCK_LANG_UNROLL)) return PsiReference.EMPTY_ARRAY;
PsiElement modifierList = annotation.getParent();
if (!(modifierList instanceof GrModifierList)) return PsiReference.EMPTY_ARRAY;

View File

@@ -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.controlFlow
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
import org.jetbrains.annotations.NonNls
interface VariableDescriptor {
@NonNls
fun getName(): String
}

View File

@@ -67,6 +67,8 @@ public class InstructionImpl implements Instruction {
return myPredecessors;
}
@NonNls
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append(myNumber);

View File

@@ -17,7 +17,7 @@ public class ThrowingInstruction extends InstructionImpl {
@Override
@NonNls
public String toString() {
final StringBuilder builder = new StringBuilder();
@NonNls final StringBuilder builder = new StringBuilder();
builder.append(num());
builder.append("(");
for (Instruction successor : allSuccessors()) {

View File

@@ -10,6 +10,7 @@ import gnu.trove.TIntHashSet;
import gnu.trove.TIntObjectHashMap;
import gnu.trove.TIntObjectProcedure;
import gnu.trove.TObjectIntHashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
@@ -364,8 +365,9 @@ public final class ReachingDefinitionsCollector {
}
@SuppressWarnings({"UnusedDeclaration"})
@NonNls
private static String dumpDfaResult(ArrayList<TIntObjectHashMap<TIntHashSet>> dfaResult, ReachingDefinitionsDfaInstance dfa) {
final StringBuffer buffer = new StringBuffer();
@NonNls final StringBuffer buffer = new StringBuffer();
for (int i = 0; i < dfaResult.size(); i++) {
TIntObjectHashMap<TIntHashSet> map = dfaResult.get(i);
buffer.append("At ").append(i).append(":\n");

View File

@@ -1,7 +1,8 @@
// 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.dataFlow.readWrite
import org.jetbrains.annotations.NonNls
import java.util.*
class ReadBeforeWriteState(
@@ -11,5 +12,6 @@ class ReadBeforeWriteState(
public override fun clone(): ReadBeforeWriteState = ReadBeforeWriteState(writes.clone() as BitSet, reads.clone() as BitSet)
@NonNls
override fun toString(): String = "(writes=$writes, reads=$reads)"
}

View File

@@ -1,11 +1,8 @@
// Copyright 2000-2018 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.impl;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiType;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -77,9 +74,9 @@ public class GrRangeType extends GrLiteralClassType {
@Override
public String getInternalCanonicalText() {
return "[" +
(myLeft == null ? "null" : myLeft.getInternalCanonicalText()) +
(myLeft == null ? PsiKeyword.NULL : myLeft.getInternalCanonicalText()) +
".." +
(myRight == null ? "null" : myRight.getInternalCanonicalText()) +
(myRight == null ? PsiKeyword.NULL : myRight.getInternalCanonicalText()) +
"]";
}

View File

@@ -1,9 +1,10 @@
// 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.impl;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
@@ -196,7 +197,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public PsiTypeParameter createTypeParameter(@NotNull String name, PsiClassType @NotNull [] superTypes) {
StringBuilder builder = new StringBuilder();
@NlsSafe StringBuilder builder = new StringBuilder();
builder.append("def <").append(name);
if (superTypes.length > 1 ||
superTypes.length == 1 && !superTypes[0].equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
@@ -246,7 +247,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@Nullable String initializer,
@Nullable PsiType type,
String... identifiers) {
StringBuilder text = writeModifiers(modifiers);
@NlsSafe StringBuilder text = writeModifiers(modifiers);
if (type != null && type != PsiType.NULL) {
final PsiType unboxed = TypesUtil.unboxPrimitiveTypeWrapper(type);
@@ -330,7 +331,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
if (!(type instanceof PsiArrayType)) {
final String canonical = type.getCanonicalText();
final String text = canonical != null ? canonical : type.getPresentableText();
if ("null".equals(text)) {
if (PsiKeyword.NULL.equals(text)) {
return "";
}
else {
@@ -378,7 +379,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@Nullable GroovyPsiElement context,
String... modifiers) throws IncorrectOperationException {
try {
StringBuilder fileText = new StringBuilder();
@NonNls StringBuilder fileText = new StringBuilder();
fileText.append("def dsfsadfnbhfjks_weyripouh_huihnrecuio(");
for (String modifier : modifiers) {
fileText.append(modifier).append(' ');
@@ -542,7 +543,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public GrMethod createMethodFromSignature(@NotNull String name, @NotNull GrSignature signature) {
StringBuilder builder = new StringBuilder("public");
StringBuilder builder = new StringBuilder(PsiKeyword.PUBLIC);
final PsiType returnType = signature.getReturnType();
if (returnType != null && returnType != PsiType.NULL) {
builder.append(' ');
@@ -578,11 +579,11 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
return createAnnotationFromText(annoText, null);
}
private GroovyFile createGroovyFileChecked(@NotNull CharSequence idText) {
private GroovyFile createGroovyFileChecked(@NlsSafe @NotNull CharSequence idText) {
return createGroovyFileChecked(idText, false, null);
}
private GroovyFile createGroovyFileChecked(@NotNull CharSequence idText, boolean isPhysical, @Nullable PsiElement context) {
private GroovyFile createGroovyFileChecked(@NlsSafe @NotNull CharSequence idText, boolean isPhysical, @Nullable PsiElement context) {
final GroovyFileImpl file = createDummyFile(idText, isPhysical);
if (ErrorUtil.containsError(file)) {
throw new IncorrectOperationException("cannot create file from text: " + idText);
@@ -633,7 +634,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public GrArgumentList createExpressionArgumentList(GrExpression... expressions) {
StringBuilder text = new StringBuilder();
@NonNls StringBuilder text = new StringBuilder();
text.append("ven (");
for (GrExpression expression : expressions) {
text.append(expression.getText()).append(", ");
@@ -765,7 +766,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
boolean isOnDemand,
String alias,
PsiElement context) {
StringBuilder builder = new StringBuilder();
@NlsSafe StringBuilder builder = new StringBuilder();
builder.append("import ");
if (isStatic) {
builder.append("static ");
@@ -783,6 +784,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
}
@NlsSafe
private static CharSequence generateMethodText(@Nullable String modifier,
@NotNull String name,
@Nullable String type,
@@ -790,7 +792,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
String @NotNull [] paramNames,
@Nullable String body,
boolean isConstructor) {
StringBuilder builder = new StringBuilder();
@NlsSafe StringBuilder builder = new StringBuilder();
if (modifier != null) {
builder.append(modifier);
@@ -892,7 +894,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public GrCatchClause createCatchClause(@NotNull PsiClassType type, @NotNull String parameterName) {
StringBuilder buffer = new StringBuilder("try{} catch(");
@NonNls StringBuilder buffer = new StringBuilder("try{} catch(");
if (type == null) {
buffer.append("Throwable ");
}
@@ -1001,7 +1003,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public GrMethod createMethod(@NotNull @NonNls String name, PsiType returnType, PsiElement context) throws IncorrectOperationException {
final StringBuilder builder = new StringBuilder();
@NonNls final StringBuilder builder = new StringBuilder();
builder.append("def <T>");
if (returnType != null) {
builder.append(returnType.getCanonicalText());
@@ -1058,7 +1060,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public PsiParameterList createParameterList(@NonNls String @NotNull [] names, PsiType @NotNull [] types) throws IncorrectOperationException {
final StringBuilder builder = new StringBuilder();
@NonNls final StringBuilder builder = new StringBuilder();
builder.append("def foo(");
for (int i = 0; i < names.length; i++) {
String name = names[i];

View File

@@ -6,6 +6,7 @@ import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.RecursionGuard;
import com.intellij.openapi.util.RecursionManager;
import com.intellij.psi.*;
@@ -44,6 +45,7 @@ public class GroovyPsiManager implements Disposable {
CommonClassNames.JAVA_UTIL_LIST,
CommonClassNames.JAVA_UTIL_COLLECTION,
CommonClassNames.JAVA_LANG_STRING);
@NlsSafe private static final String PASS = "PASS";
private final Project myProject;
private final Map<String, GrTypeDefinition> myArrayClass = new HashMap<>();
@@ -110,7 +112,7 @@ public class GroovyPsiManager implements Disposable {
PsiAnnotationMemberValue value = annotation.findAttributeValue("value");
return value == null ||
value instanceof PsiReference &&
ResolveUtil.isEnumConstant((PsiReference)value, "PASS", GroovyCommonClassNames.GROOVY_TRANSFORM_TYPE_CHECKING_MODE);
ResolveUtil.isEnumConstant((PsiReference)value, PASS, GroovyCommonClassNames.GROOVY_TRANSFORM_TYPE_CHECKING_MODE);
}
@Nullable

View File

@@ -1,10 +1,11 @@
// Copyright 2000-2018 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.impl;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiSubstitutor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.EmptyGroovyResolveResult;
@@ -137,6 +138,7 @@ public class GroovyResolveResultImpl implements GroovyResolveResult {
}
@Override
@NonNls
public String toString() {
return "GroovyResolveResultImpl{" +
"myElement=" + myElement +

View File

@@ -6,6 +6,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.AstBufferUtil;
import com.intellij.psi.impl.source.tree.Factory;
@@ -82,6 +83,7 @@ import static org.jetbrains.plugins.groovy.lang.psi.impl.utils.ParenthesesUtils.
public final class PsiImplUtil {
private static final Logger LOG = Logger.getInstance(PsiImplUtil.class);
@NlsSafe
private static final String MAIN_METHOD = "main";
public static final Key<SoftReference<PsiCodeBlock>> PSI_CODE_BLOCK = Key.create("Psi_code_block");
public static final Key<SoftReference<PsiTypeElement>> PSI_TYPE_ELEMENT = Key.create("psi.type.element");

View File

@@ -1,11 +1,8 @@
// 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.impl.auxiliary;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiJavaCodeReferenceElement;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.light.LightClassReference;
import com.intellij.psi.tree.IElementType;
@@ -79,7 +76,7 @@ public class GrThrowsClauseImpl extends GrReferenceListImpl implements GrThrowsC
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
if (element instanceof GrCodeReferenceElement || element instanceof PsiJavaCodeReferenceElement) {
if (findChildByClass(GrCodeReferenceElement.class) == null) {
getNode().addLeaf(GroovyTokenTypes.kTHROWS, "throws", null);
getNode().addLeaf(GroovyTokenTypes.kTHROWS, PsiKeyword.THROWS, null);
}
else {
PsiElement lastChild = getLastChild();

View File

@@ -1,13 +1,14 @@
// Copyright 2000-2018 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.impl
import com.intellij.codeInsight.AnnotationUtil
import com.intellij.openapi.util.NlsSafe
import com.intellij.psi.PsiAnnotation
import com.intellij.psi.PsiAnnotationMemberValue
import com.intellij.psi.PsiLiteral
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList
fun PsiAnnotation.findDeclaredDetachedValue(attributeName: String?): PsiAnnotationMemberValue? {
fun PsiAnnotation.findDeclaredDetachedValue(@NlsSafe attributeName: String?): PsiAnnotationMemberValue? {
return AnnotationUtil.findDeclaredAttribute(this, attributeName)?.detachedValue
}

View File

@@ -1,11 +1,8 @@
// 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.impl
import com.intellij.openapi.util.Key
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiRecursiveElementWalkingVisitor
import com.intellij.psi.PsiType
import com.intellij.psi.*
import com.intellij.psi.stubs.StubElement
import com.intellij.psi.util.CachedValue
import com.intellij.psi.util.CachedValueProvider.Result
@@ -171,5 +168,5 @@ fun GrVariable.isDeclaredIn(block: GrControlFlowOwner): Boolean {
fun isThisRef(expression: GrExpression?): Boolean {
return expression is GrReferenceExpression &&
expression.qualifier == null &&
"this" == expression.referenceName
PsiKeyword.THIS == expression.referenceName
}

View File

@@ -2,6 +2,7 @@
package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
import com.intellij.lang.Language;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
@@ -161,7 +162,7 @@ public class GrLightAnnotation extends LightElement implements GrAnnotation {
}
}
public void addAttribute(@Nullable String name, @NotNull String value) {
public void addAttribute(@NlsSafe @Nullable String name, @NlsSafe @NotNull String value) {
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(getProject());
String text = name != null ? name + "=" + value : value;
myAnnotationArgList.addAttribute(factory.createAnnotationAttribute(text, this));

View File

@@ -1,20 +1,7 @@
/*
* Copyright 2000-2016 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.impl.synthetic;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.psi.*;
import com.intellij.psi.impl.light.LightTypeParameter;
import org.jetbrains.annotations.NotNull;
@@ -110,7 +97,7 @@ public class GrMethodWrapper extends GrLightMethodBuilder implements PsiMirrorEl
return new GrMethodWrapper(method, substitutor);
}
public static GrMethodWrapper wrap(@NotNull PsiMethod method, @NotNull String newName) {
public static GrMethodWrapper wrap(@NotNull PsiMethod method, @NlsSafe @NotNull String newName) {
return new GrMethodWrapper(method, PsiSubstitutor.EMPTY, newName);
}

View File

@@ -19,6 +19,7 @@ public abstract class GrStubElementType<S extends StubElement<?>, T extends Groo
}
@Override
@NonNls
public @NotNull String getExternalId() {
return "gr." + super.toString();
}

View File

@@ -1,7 +1,8 @@
// Copyright 2000-2018 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.typeEnhancers;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.util.InheritanceUtil;
@@ -13,6 +14,10 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
public class MapEntryOrKeyValueHintProcessor extends SignatureHintProcessor {
@NlsSafe private static final String INDEX = "index";
@NlsSafe private static final String ARG_NUM = "argNum";
@Override
public String getHintName() {
return "groovy.transform.stc.MapEntryOrKeyValue";
@@ -84,7 +89,7 @@ public class MapEntryOrKeyValueHintProcessor extends SignatureHintProcessor {
Couple<String> pair = parseValue(value);
if (pair == null) return null;
if ("index".equals(pair.getFirst())) {
if (INDEX.equals(pair.getFirst())) {
return Boolean.valueOf(pair.getSecond());
}
@@ -95,7 +100,7 @@ public class MapEntryOrKeyValueHintProcessor extends SignatureHintProcessor {
Couple<String> pair = parseValue(value);
if (pair == null) return null;
if ("argNum".equals(pair.getFirst())) {
if (ARG_NUM.equals(pair.getFirst())) {
return StringUtil.parseInt(pair.getSecond(), 0);
}

View File

@@ -1,10 +1,11 @@
// 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.uast
import com.intellij.lang.Language
import com.intellij.psi.*
import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.util.parents
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.GroovyLanguage
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes
import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference
@@ -129,6 +130,7 @@ class GrUAnnotation(val grElement: GrAnnotation,
class GrUnknownUExpression(override val psi: PsiElement?, override val uastParent: UElement?) : UExpression {
@NonNls
override fun asLogString(): String = "GrUnknownUExpression(grElement)"
override val uAnnotations: List<UAnnotation> = emptyList() //not implemented

View File

@@ -3,6 +3,7 @@ package org.jetbrains.plugins.groovy.lang.psi.util;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
@@ -44,9 +45,9 @@ public final class GrStringUtil {
private GrStringUtil() {
}
public static String unescapeString(String s) {
public static @NlsSafe String unescapeString(String s) {
final int length = s.length();
StringBuilder buffer = new StringBuilder(length);
@NlsSafe StringBuilder buffer = new StringBuilder(length);
boolean escaped = false;
for (int idx = 0; idx < length; idx++) {
char ch = s.charAt(idx);
@@ -131,9 +132,9 @@ public final class GrStringUtil {
return unescapeRegex(s, false);
}
private static String unescapeRegex(String s, boolean unescapeSlash) {
private static @NlsSafe String unescapeRegex(String s, boolean unescapeSlash) {
final int length = s.length();
StringBuilder buffer = new StringBuilder(length);
@NlsSafe StringBuilder buffer = new StringBuilder(length);
boolean escaped = false;
for (int idx = 0; idx < length; idx++) {

View File

@@ -1,7 +1,8 @@
// 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.util
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.NonNls
import org.jetbrains.annotations.TestOnly
import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil.*
@@ -39,6 +40,7 @@ enum class StringKind {
override fun unescape(escaped: String): String = unescapeDollarSlashyString(escaped)
};
@get:NonNls
open val lineBreaker: String get() = "\n"
abstract fun escape(unescaped: String): String

View File

@@ -5,6 +5,7 @@ import com.intellij.lang.jvm.types.JvmArrayType
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.GroovyElementFilter
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.kIN
@@ -62,6 +63,7 @@ fun GrOperatorExpression.multiResolve(): Array<out GroovyResolveResult> {
val PsiMethod.isEffectivelyVarArgs: Boolean get() = isVarArgs || parameters.lastOrNull()?.type is JvmArrayType
@NonNls
fun elementInfo(element: PsiElement): String = "Element: $element; class: ${element.javaClass}; text: ${element.text}"
fun GrCodeReferenceElement.mayContainTypeArguments(): Boolean {

View File

@@ -12,6 +12,7 @@ import com.intellij.util.cls.ClsFormatException;
import com.intellij.util.indexing.*;
import com.intellij.util.indexing.FileBasedIndex.InputFilter;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.*;
@@ -36,7 +37,7 @@ public class GroovyTraitFieldsFileIndex
implements DataExternalizer<Collection<TraitFieldDescriptor>> {
public static final ID<Integer, Collection<TraitFieldDescriptor>> INDEX_ID = ID.create("groovy.trait.fields");
public static final String HELPER_SUFFIX = "$Trait$FieldHelper.class";
@NonNls public static final String HELPER_SUFFIX = "$Trait$FieldHelper.class";
private static final InputFilter FILTER = new DefaultFileTypeSpecificInputFilter(JavaClassFileType.INSTANCE) {
@Override

View File

@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 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.resolve;
import com.intellij.ide.highlighter.JavaClassFileType;
@@ -27,6 +25,7 @@ import com.intellij.util.indexing.*;
import com.intellij.util.indexing.FileBasedIndex.InputFilter;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.*;
@@ -44,7 +43,7 @@ public class GroovyTraitMethodsFileIndex extends SingleEntryFileBasedIndexExtens
private static final Logger LOG = Logger.getInstance(GroovyTraitMethodsFileIndex.class);
private static final ID<Integer, ByteArraySequence> INDEX_ID = ID.create("groovy.trait.methods");
private static final String HELPER_SUFFIX = "$Trait$Helper.class";
@NonNls private static final String HELPER_SUFFIX = "$Trait$Helper.class";
private final InputFilter myFilter;
private final SingleEntryIndexer<ByteArraySequence> myIndexer;

View File

@@ -2,6 +2,7 @@
package org.jetbrains.plugins.groovy.lang.resolve.ast.builder.strategy;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.light.LightMethodBuilder;
@@ -149,6 +150,7 @@ public class InitializerBuilderStrategySupport extends BuilderAnnotationContribu
return StringUtil.isEmpty(builderMethodName) ? "createInitializer" : builderMethodName;
}
@NlsSafe
@NotNull
private static String getBuildMethodName(@NotNull PsiAnnotation annotation) {
final String builderMethodName = AnnotationUtil.getDeclaredStringAttributeValue(annotation, "buildMethodName");

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.resolve.imports
import com.intellij.openapi.util.text.StringUtil
@@ -8,6 +8,7 @@ import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.ResolveState
import com.intellij.psi.scope.PsiScopeProcessor
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase
import org.jetbrains.plugins.groovy.lang.resolve.*
import org.jetbrains.plugins.groovy.lang.resolve.imports.impl.resolve
@@ -81,5 +82,6 @@ data class RegularImport(val classFqn: String, override val name: String) : Groo
return this in defaultRegularImportsSet || starImport in defaultStarImportsSet
}
@NonNls
override fun toString(): String = "import $classFqn as $name"
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.resolve.imports
import com.intellij.psi.JavaPsiFacade
@@ -6,6 +6,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiPackage
import com.intellij.psi.ResolveState
import com.intellij.psi.scope.PsiScopeProcessor
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase
import org.jetbrains.plugins.groovy.lang.resolve.imports.impl.resolve
import org.jetbrains.plugins.groovy.lang.resolve.isNonAnnotationResolve
@@ -28,5 +29,6 @@ data class StarImport(val packageFqn: String) : GroovyStarImport {
override fun isUnnecessary(imports: GroovyFileImports): Boolean = this in defaultStarImportsSet
@NonNls
override fun toString(): String = "import $packageFqn.*"
}

View File

@@ -1,10 +1,11 @@
// Copyright 2000-2018 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.resolve.imports
import com.intellij.openapi.util.text.StringUtil.getQualifiedName
import com.intellij.psi.PsiElement
import com.intellij.psi.ResolveState
import com.intellij.psi.scope.PsiScopeProcessor
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils.*
import org.jetbrains.plugins.groovy.lang.resolve.getName
@@ -61,6 +62,7 @@ data class StaticImport constructor(
return StaticStarImport(classFqn) in imports.staticStarImports
}
@NonNls
override fun toString(): String = "import static $classFqn.$memberName as $name"
private fun namesMapping() = namesMapping(memberName, name)

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2017 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.
@file:Suppress("LoopToCallChain")
package org.jetbrains.plugins.groovy.lang.resolve.imports
@@ -6,6 +6,7 @@ package org.jetbrains.plugins.groovy.lang.resolve.imports
import com.intellij.psi.PsiElement
import com.intellij.psi.ResolveState
import com.intellij.psi.scope.PsiScopeProcessor
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase
import org.jetbrains.plugins.groovy.lang.resolve.imports.impl.NonFqnImport
import org.jetbrains.plugins.groovy.lang.resolve.isAnnotationResolve
@@ -26,5 +27,6 @@ data class StaticStarImport(override val classFqn: String) : NonFqnImport(), Gro
override fun isUnnecessary(imports: GroovyFileImports): Boolean = false
@NonNls
override fun toString(): String = "import static $classFqn.*"
}

View File

@@ -6,6 +6,7 @@ import com.intellij.psi.impl.light.LightMethod;
import com.intellij.psi.scope.DelegatingScopeProcessor;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyLanguage;
@@ -64,6 +65,7 @@ public final class MixinMemberContributor {
return true;
}
@NonNls
public static String getOriginInfoForCategory(PsiMethod element) {
PsiClass aClass = element.getContainingClass();
if (aClass != null && aClass.getName() != null) {
@@ -72,6 +74,7 @@ public final class MixinMemberContributor {
return "mixed in";
}
@NonNls
public static String getOriginInfoForMixin(@NotNull PsiType subjectType) {
return "mixed in " + subjectType.getPresentableText();
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2017 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.resolve.processors;
@@ -7,6 +7,7 @@ import com.intellij.psi.PsiMember;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.impl.light.LightElement;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
@@ -44,6 +45,7 @@ public abstract class ResolverProcessor<T extends GroovyResolveResult> extends G
myCandidates.add(candidate);
}
@NonNls
@NotNull
private static String getElementInfo(@NotNull PsiElement element) {
String text;
@@ -106,6 +108,7 @@ public abstract class ResolverProcessor<T extends GroovyResolveResult> extends G
}
@Override
@NonNls
public String toString() {
return "NameHint: '" +
myName +

View File

@@ -3,6 +3,7 @@ package org.jetbrains.plugins.groovy.swingBuilder;
import com.google.common.collect.ImmutableMap;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.UserDataHolderEx;
import com.intellij.psi.*;
import com.intellij.psi.scope.ElementClassHint;
@@ -10,6 +11,7 @@ import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
@@ -32,7 +34,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
private static final Key<MultiMap<String, PsiMethod>> KEY = Key.create("SwingBuilderNonCodeMemberContributor.KEY");
private static final Object METHOD_KIND = "SwingBuilder_builder_method";
@NonNls private static final Object METHOD_KIND = "SwingBuilder_builder_method";
private static final class MyBuilder {
private final PsiManager myManager;
@@ -107,11 +109,11 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
return res;
}
private void methodObject(String name, String returnType, @Nullable String navigationClass) {
private void methodObject(@NlsSafe String name, String returnType, @Nullable String navigationClass) {
methodObject(name, returnType, navigationClass, null);
}
private void methodObject(String name, String returnType, @Nullable String navigationClass,
private void methodObject(@NlsSafe String name, @NlsSafe String returnType, @Nullable String navigationClass,
@Nullable Map<String, NamedArgumentDescriptor> namedArg) {
MyMethodBuilder method = method(name, returnType, navigationClass);
method.addParameter("map", type(CommonClassNames.JAVA_UTIL_MAP), true);
@@ -180,7 +182,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu
// registerBinding()
methodObject("bind", "org.codehaus.groovy.binding.FullBinding", "groovy.swing.factory.BindFactory",
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
ContainerUtil.<String, NamedArgumentDescriptor>immutableMapBuilder()
.put("source", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("target", NamedArgumentDescriptor.SIMPLE_ON_TOP)
.put("update", NamedArgumentDescriptor.SIMPLE_ON_TOP)

View File

@@ -1,26 +1,13 @@
/*
* Copyright 2000-2016 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.transformations.dsl
import com.intellij.openapi.util.NlsSafe
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder
import org.jetbrains.plugins.groovy.transformations.TransformationContext
class MemberBuilder(val context: TransformationContext) {
fun method(name: String, builder: GrLightMethodBuilder.() -> Unit): GrLightMethodBuilder {
fun method(@NlsSafe name: String, builder: GrLightMethodBuilder.() -> Unit): GrLightMethodBuilder {
return GrLightMethodBuilder(context.manager, name).apply(builder)
}

View File

@@ -3,13 +3,16 @@
package org.jetbrains.plugins.groovy.transformations.immutable
import com.intellij.openapi.util.NlsSafe
import com.intellij.psi.*
import com.intellij.psi.util.InheritanceUtil
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
import org.jetbrains.plugins.groovy.lang.psi.impl.GrAnnotationUtil
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightAnnotation
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames
import org.jetbrains.plugins.groovy.lang.resolve.ast.TupleConstructorAttributes
//set from org.apache.groovy.ast.tools.ImmutablePropertyUtils
internal val builtinImmutables = setOf(
@@ -61,9 +64,9 @@ internal val builtinImmutables = setOf(
"java.time.temporal.WeekFields"
)
internal const val immutableCopyWithKind = "@Immutable#copyWith"
internal const val immutableOrigin = "by @Immutable"
internal const val immutableCopyWith = "copyWith"
@NonNls internal const val immutableCopyWithKind = "@Immutable#copyWith"
@NonNls internal const val immutableOrigin = "by @Immutable"
@NlsSafe internal const val immutableCopyWith = "copyWith"
const val KNOWN_IMMUTABLES_OPTION = "knownImmutables"
const val KNOWN_IMMUTABLE_CLASSES_OPTION = "knownImmutableClasses"
@@ -83,7 +86,7 @@ fun collectImmutableAnnotations(alias: GrAnnotation, list: MutableList<in GrAnno
list.add(GrLightAnnotation(owner, alias, GROOVY_TRANSFORM_IMMUTABLE_BASE, emptyMap()))
list.add(GrLightAnnotation(owner, alias, GROOVY_TRANSFORM_IMMUTABLE_OPTIONS, emptyMap()))
list.add(GrLightAnnotation(owner, alias, GROOVY_TRANSFORM_KNOWN_IMMUTABLE, emptyMap()))
list.add(GrLightAnnotation(owner, alias, GroovyCommonClassNames.GROOVY_TRANSFORM_TUPLE_CONSTRUCTOR, mapOf("defaults" to "false")))
list.add(GrLightAnnotation(owner, alias, GroovyCommonClassNames.GROOVY_TRANSFORM_TUPLE_CONSTRUCTOR, mapOf(TupleConstructorAttributes.DEFAULTS to "false")))
list.add(GrLightAnnotation(owner, alias, GroovyCommonClassNames.GROOVY_TRANSFORM_PROPERTY_OPTIONS, emptyMap()))
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.transformations.impl
import com.intellij.codeInsight.AnnotationUtil
@@ -6,6 +6,7 @@ import com.intellij.psi.CommonClassNames
import com.intellij.psi.PsiArrayType
import com.intellij.psi.PsiModifier
import com.intellij.psi.PsiType
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder
@@ -16,7 +17,7 @@ import org.jetbrains.plugins.groovy.transformations.TransformationContext
private const val VETOABLE_FQN = "groovy.beans.Vetoable"
private const val VCL_FQN = "java.beans.VetoableChangeListener"
private const val VCS_FQN = "java.beans.VetoableChangeSupport"
const val ORIGIN_INFO: String = "via @Vetoable"
@NonNls const val ORIGIN_INFO: String = "via @Vetoable"
class VetoableTransformationSupport : AstTransformationSupport {

View File

@@ -1,11 +1,13 @@
// 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.
@file:JvmName("NamedParamsUtil")
package org.jetbrains.plugins.groovy.transformations.impl.namedVariant
import com.intellij.codeInsight.AnnotationUtil
import com.intellij.openapi.util.NlsSafe
import com.intellij.psi.*
import com.intellij.psi.util.PropertyUtilBase
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral
@@ -17,8 +19,8 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.getArrayValue
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
const val NAMED_VARIANT_ORIGIN_INFO: String = "via @NamedVariant"
const val NAMED_ARGS_PARAMETER_NAME = "__namedArgs"
@NonNls const val NAMED_VARIANT_ORIGIN_INFO: String = "via @NamedVariant"
@NlsSafe const val NAMED_ARGS_PARAMETER_NAME = "__namedArgs"
const val GROOVY_TRANSFORM_NAMED_VARIANT = "groovy.transform.NamedVariant"
const val GROOVY_TRANSFORM_NAMED_PARAM = "groovy.transform.NamedParam"
const val GROOVY_TRANSFORM_NAMED_PARAMS = "groovy.transform.NamedParams"

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.transformations.indexedProperty
import com.intellij.psi.CommonClassNames.JAVA_UTIL_LIST
@@ -8,10 +8,12 @@ import com.intellij.psi.PsiType
import com.intellij.psi.util.CachedValueProvider.Result
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiUtil
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder
internal const val indexedPropertyFqn = "groovy.transform.IndexedProperty"
@NonNls
internal const val indexedPropertyOriginInfo = "by @IndexedProperty"
const val indexedMethodKind: String = "groovy.transform.IndexedProperty.kind"

View File

@@ -1,12 +1,14 @@
// Copyright 2000-2018 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.transformations.listenerList
import com.intellij.psi.CommonClassNames.JAVA_UTIL_COLLECTION
import com.intellij.psi.PsiType
import com.intellij.psi.util.PsiUtil.substituteTypeParameter
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
internal const val listenerListFqn = "groovy.beans.ListenerList"
@NonNls
internal const val listenerListOriginInfo = "by @ListenerList"
fun GrField.getListenerType(): PsiType? = substituteTypeParameter(type, JAVA_UTIL_COLLECTION, 0, false)

View File

@@ -1,10 +1,12 @@
// Copyright 2000-2018 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.transformations.singleton
import com.intellij.codeInsight.AnnotationUtil
import com.intellij.openapi.util.NlsSafe
import com.intellij.psi.PsiAnnotation
import com.intellij.psi.PsiElement
import com.intellij.util.text.nullize
import org.jetbrains.annotations.NonNls
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod
@@ -13,8 +15,9 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.stringValue
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames
internal const val singletonFqn = GroovyCommonClassNames.GROOVY_LANG_SINGLETON
internal const val singletonOriginInfo = "by @Singleton"
@NonNls internal const val singletonOriginInfo = "by @Singleton"
@NlsSafe
fun PsiAnnotation.getPropertyName(): String = findDeclaredDetachedValue("property").stringValue().nullize(true) ?: "instance"
internal fun getAnnotation(identifier: PsiElement?): GrAnnotation? {

View File

@@ -10,6 +10,7 @@ import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileSystem;
@@ -34,6 +35,8 @@ import java.util.regex.Pattern;
*/
public final class LibrariesUtil {
public static final String SOME_GROOVY_CLASS = "org.codehaus.groovy.control.CompilationUnit";
@NlsSafe private static final String LIB = "lib";
@NlsSafe private static final String EMBEDDABLE = "embeddable";
private LibrariesUtil() {
}
@@ -121,7 +124,7 @@ public final class LibrariesUtil {
if (local != null) {
final VirtualFile parent = local.getParent();
if (parent != null) {
if (("lib".equals(parent.getName()) || "embeddable".equals(parent.getName())) && parent.getParent() != null) {
if ((LIB.equals(parent.getName()) || EMBEDDABLE.equals(parent.getName())) && parent.getParent() != null) {
return parent.getParent().getPath();
}
return parent.getPath();
@@ -143,7 +146,7 @@ public final class LibrariesUtil {
if (realFile.exists()) {
File parentFile = realFile.getParentFile();
if (parentFile != null) {
if ("lib".equals(parentFile.getName())) {
if (LIB.equals(parentFile.getName())) {
return parentFile.getParent();
}
return parentFile.getPath();
@@ -181,7 +184,7 @@ public final class LibrariesUtil {
final File emb = new File(embeddable);
if (emb.exists()) {
final File parent = emb.getParentFile();
if ("embeddable".equals(parent.getName()) || "lib".equals(parent.getName())) {
if (EMBEDDABLE.equals(parent.getName()) || LIB.equals(parent.getName())) {
return parent.getParent();
}
return parent.getPath();

View File

@@ -1,8 +1,9 @@
// Copyright 2000-2018 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.util
import com.intellij.openapi.util.RecursionManager
import com.intellij.util.ObjectUtils
import org.jetbrains.annotations.NonNls
import java.util.concurrent.atomic.AtomicReference
/**
@@ -46,6 +47,7 @@ class RecursionAwareSafePublicationLazy<T>(initializer: () -> T) : Lazy<T> {
override fun isInitialized(): Boolean = valueRef.get() !== UNINITIALIZED_VALUE
@NonNls
override fun toString(): String = if (isInitialized()) value.toString() else "Lazy value not initialized yet."
companion object {

View File

@@ -1,7 +1,8 @@
// 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.util
import com.intellij.util.ObjectUtils
import org.jetbrains.annotations.NonNls
import java.util.concurrent.atomic.AtomicReference
class SafePublicationClearableLazyValue<T>(private val initializer: () -> T) {
@@ -27,6 +28,7 @@ class SafePublicationClearableLazyValue<T>(private val initializer: () -> T) {
@Suppress("UNCHECKED_CAST")
fun clear(): Unit = valueRef.set(UNINITIALIZED_VALUE as T)
@NonNls
override fun toString(): String = if (valueRef.get() !== UNINITIALIZED_VALUE) value.toString() else "Lazy value not initialized."
companion object {

View File

@@ -4,6 +4,7 @@ package org.jetbrains.plugins.groovy.dsl;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsContexts.DetailedDescription;
import com.intellij.psi.PsiFile;
import com.intellij.unscramble.UnscrambleDialog;
import com.intellij.util.IncorrectOperationException;
@@ -11,9 +12,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyBundle;
public class InvestigateFix implements IntentionAction {
private final String myReason;
@DetailedDescription private final String myReason;
public InvestigateFix(String reason) {
public InvestigateFix(@DetailedDescription String reason) {
myReason = reason;
}