From 3a250971afbbc140d0b16815c99a79d5f5249623 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 13 Mar 2014 13:04:20 +0400 Subject: [PATCH] notnull --- .../BasicExpressionCompletionContributor.java | 4 +- .../completion/JavaCompletionUtil.java | 6 +-- .../completion/proc/VariablesProcessor.java | 6 +-- .../scope/JavaCompletionProcessor.java | 8 ++-- .../impl/quickfix/CreateFromUsageUtils.java | 2 +- .../impl/quickfix/RenameWrongRefFix.java | 4 +- ...PsiDocCommentOwnerMemberChooserObject.java | 5 +- .../generation/PsiElementClassMember.java | 8 ++-- .../generation/PsiFieldMember.java | 13 ++++-- .../generation/PsiMethodMember.java | 9 ++-- .../codeInsight/template/macro/MacroUtil.java | 4 +- .../psi/AbstractQualifiedReference.java | 6 +-- .../impl/providers/JavaClassReference.java | 6 +-- .../psi/resolve/JavaMethodResolveHelper.java | 8 ++-- .../JavaChangeSignatureUsageProcessor.java | 17 +++++-- .../xml/CanonicalPsiTypeConverterImpl.java | 10 +++- .../com/intellij/psi/infos/CandidateInfo.java | 26 ++++++----- .../psi/infos/ClassCandidateInfo.java | 8 ++-- .../psi/infos/MethodCandidateInfo.java | 19 ++++---- .../intellij/psi/impl/PsiClassImplUtil.java | 4 +- .../ClsJavaCodeReferenceElementImpl.java | 8 ++-- .../psi/impl/light/LightMemberReference.java | 7 +-- .../psi/impl/light/LightPackageReference.java | 5 +- .../psi/impl/source/PsiJavaFileBaseImpl.java | 8 ++-- .../resolve/ClassResolverProcessor.java | 8 ++-- .../source/resolve/PsiResolveHelperImpl.java | 4 +- .../resolve/StaticImportResolveProcessor.java | 10 ++-- .../resolve/SymbolCollectingProcessor.java | 6 +-- .../resolve/VariableResolverProcessor.java | 8 ++-- .../source/tree/java/PsiCodeBlockImpl.java | 4 +- .../PsiMethodReferenceExpressionImpl.java | 6 +-- .../tree/java/PsiReferenceExpressionImpl.java | 4 +- .../src/com/intellij/psi/scope/NameHint.java | 5 +- .../processor/ConflictFilterProcessor.java | 22 +++++---- .../scope/processor/FilterScopeProcessor.java | 10 ++-- .../processor/MethodCandidatesProcessor.java | 8 ++-- .../processor/MethodResolveProcessor.java | 30 ++++++------ .../processor/MethodResolverProcessor.java | 6 +-- .../psi/scope/processor/MethodsProcessor.java | 6 +-- .../scope/processor/VariablesProcessor.java | 6 +-- .../impl/AddAllMembersProcessor.java | 2 +- .../IntObjectPersistentMaplet.java | 5 +- .../src/com/intellij/psi/ResolveState.java | 46 +++++++++++-------- .../intellij/psi/scope/PsiScopeProcessor.java | 6 +-- .../psi/impl/ResolveScopeManager.java | 4 +- .../psi/scope/BaseScopeProcessor.java | 4 +- .../PsiElementMemberChooserObject.java | 5 +- .../psi/scope/DelegatingScopeProcessor.java | 21 +++++++-- ...nfigurationsNonCodeMembersContributor.java | 4 +- .../resolve/GradleScriptContributor.java | 6 +-- .../GradleSettingsScriptContributor.java | 4 +- .../generate/accessors/GrFieldMember.java | 7 ++- .../dynamic/DynamicMembersContributor.java | 4 +- .../GrUnresolvedAccessInspection.java | 4 +- .../fragments/GroovyCodeFragment.java | 23 ++++++++-- .../groovy/dgm/DGMMemberContributor.java | 6 +-- .../plugins/groovy/dgm/GdkMethodHolder.java | 8 ++-- .../groovy/dsl/GroovyDslFileIndex.java | 2 +- .../groovy/editor/GroovyImportHelper.java | 6 +-- .../GroovyConstructorUsagesSearcher.java | 6 ++- .../groovy/gant/GantMemberContributor.java | 4 +- .../geb/GebBrowserMemberContributor.java | 4 +- .../geb/GebJUnitTestMemberContributor.java | 4 +- .../groovy/geb/GebPageMemberContributor.java | 4 +- .../geb/GebSpockTestMemberContributor.java | 4 +- .../geb/GebTestNGTestMemberContributor.java | 4 +- ...roovyConstructorNamedArgumentProvider.java | 10 ++-- .../lang/completion/GdslClosureCompleter.java | 4 +- .../GroovyCompletionContributor.java | 8 ++-- .../groovy/lang/psi/impl/GroovyFileImpl.java | 23 ++++++++-- .../imports/GrImportStatementImpl.java | 12 ++++- .../groovy/lang/psi/util/GdkMethodUtil.java | 2 +- .../lang/resolve/DeclarationCacheKey.java | 4 +- .../resolve/NonCodeMembersContributor.java | 6 +-- .../groovy/lang/resolve/ResolveUtil.java | 6 +-- .../GrCollectionTypeMembersProvider.java | 8 ++-- .../noncode/MixinMemberContributor.java | 4 +- .../processors/CompletionProcessor.java | 6 ++- .../processors/JavaResolverProcessor.java | 4 +- .../processors/MethodResolverProcessor.java | 2 +- .../processors/PropertyResolverProcessor.java | 4 +- .../resolve/processors/ResolverProcessor.java | 13 ++++-- ...MarkupBuilderNonCodeMemberContributor.java | 4 +- .../GrChangeSignatureUsageProcessor.java | 19 ++++++-- .../convertToJava/ExpressionGenerator.java | 9 ++-- .../convertToJava/GenerationUtil.java | 31 ++----------- .../groovy/spock/SpockMemberContributor.java | 4 +- .../SwingBuilderNonCodeMemberContributor.java | 4 +- .../codeInspection/i18n/JavaI18nUtil.java | 6 +-- ...MavenGroovyPomScriptMemberContributor.java | 17 ++++++- .../codeInsight/PyDunderAllReference.java | 8 ++-- .../jetbrains/python/psi/impl/PyFileImpl.java | 29 ++++++++++-- .../resolve/AssignmentCollectProcessor.java | 9 ++-- .../python/psi/resolve/ResolveProcessor.java | 9 ++-- .../python/psi/resolve/VariantsProcessor.java | 9 ++-- .../python/psi/types/PyModuleType.java | 6 +-- .../relaxNG/compact/psi/impl/RncNameImpl.java | 20 +++++++- 97 files changed, 503 insertions(+), 338 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/BasicExpressionCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/BasicExpressionCompletionContributor.java index f18c789ea167..5077c13f413f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/BasicExpressionCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/BasicExpressionCompletionContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -107,7 +107,7 @@ public class BasicExpressionCompletionContributor { PsiScopesUtil.treeWalkUp(new BaseScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiLocalVariable) { if (!matcher.prefixMatches(((PsiLocalVariable)element).getName())) { return true; diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index a5fd6071337d..fd0de03cd792 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -303,7 +303,7 @@ public class JavaCompletionUtil { final Ref subst = Ref.create(PsiSubstitutor.EMPTY); class MyProcessor extends BaseScopeProcessor implements NameHint, ElementClassHint { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element == member) { subst.set(state.get(PsiSubstitutor.KEY)); } @@ -311,7 +311,7 @@ public class JavaCompletionUtil { } @Override - public String getName(ResolveState state) { + public String getName(@NotNull ResolveState state) { return member.getName(); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/proc/VariablesProcessor.java b/java/java-impl/src/com/intellij/codeInsight/completion/proc/VariablesProcessor.java index ab8f6be5e4a3..c05a29b5b9a2 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/proc/VariablesProcessor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/proc/VariablesProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -66,7 +66,7 @@ public class VariablesProcessor /** Always return true since we wanna get all vars in scope */ @Override - public boolean execute(@NotNull PsiElement pe, ResolveState state){ + public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state){ if(pe instanceof PsiVariable){ final PsiVariable pvar = (PsiVariable)pe; final String pvar_name = pvar.getName(); @@ -81,7 +81,7 @@ public class VariablesProcessor } @Override - public final void handleEvent(Event event, Object associated){ + public final void handleEvent(@NotNull Event event, Object associated){ if(event == JavaScopeProcessorEvent.START_STATIC) myStaticScopeFlag = true; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java b/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java index 041b7f6a2489..fb7878dba26c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -77,7 +77,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme private final Condition myMatcher; private final Options myOptions; private final Set myNonInitializedFields = new HashSet(); - private boolean myAllowStaticWithInstanceQualifier; + private final boolean myAllowStaticWithInstanceQualifier; public JavaCompletionProcessor(@NotNull PsiElement element, ElementFilter filter, Options options, @NotNull Condition nameCondition) { myOptions = options; @@ -196,7 +196,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme } @Override - public void handleEvent(Event event, Object associated){ + public void handleEvent(@NotNull Event event, Object associated){ if(event == JavaScopeProcessorEvent.START_STATIC){ myStatic = true; } @@ -209,7 +209,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { //noinspection SuspiciousMethodCalls if (myNonInitializedFields.contains(element)) { return true; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index 1df89f72520b..70fa10703c26 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -523,7 +523,7 @@ public class CreateFromUsageUtils { final List list = new ArrayList(); VariablesProcessor varproc = new VariablesProcessor("", true, list){ @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if(!(element instanceof PsiField) || JavaPsiFacade.getInstance(element.getProject()).getResolveHelper().isAccessible((PsiField)element, expression, null)) { return super.execute(element, state); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java index 6dc619d3c935..acdcfc8062c2 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RenameWrongRefFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -160,7 +160,7 @@ public class RenameWrongRefFix implements IntentionAction { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiNamedElement && element instanceof PsiModifierListOwner && myFilterMethods == element instanceof PsiMethod) { diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiDocCommentOwnerMemberChooserObject.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiDocCommentOwnerMemberChooserObject.java index ae586228ec11..c9ff5f04fed4 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiDocCommentOwnerMemberChooserObject.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiDocCommentOwnerMemberChooserObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -17,6 +17,7 @@ package com.intellij.codeInsight.generation; import com.intellij.psi.PsiDocCommentOwner; import com.intellij.ui.SimpleTextAttributes; +import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -24,7 +25,7 @@ import javax.swing.*; * @author peter */ public class PsiDocCommentOwnerMemberChooserObject extends PsiElementMemberChooserObject { - public PsiDocCommentOwnerMemberChooserObject(final PsiDocCommentOwner owner, final String text, Icon icon) { + public PsiDocCommentOwnerMemberChooserObject(@NotNull PsiDocCommentOwner owner, final String text, Icon icon) { super(owner, text, icon); } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiElementClassMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiElementClassMember.java index 54db06633199..287fd6646c19 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiElementClassMember.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiElementClassMember.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -21,6 +21,7 @@ import com.intellij.psi.PsiDocCommentOwner; import com.intellij.psi.PsiSubstitutor; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.psi.util.PsiFormatUtilBase; +import org.jetbrains.annotations.NotNull; /** * @author peter @@ -29,17 +30,18 @@ public abstract class PsiElementClassMember extend private final T myPsiMember; private PsiSubstitutor mySubstitutor; - protected PsiElementClassMember(final T psiMember, String text) { + protected PsiElementClassMember(@NotNull T psiMember, String text) { this(psiMember, PsiSubstitutor.EMPTY, text); } - protected PsiElementClassMember(final T psiMember, final PsiSubstitutor substitutor, String text) { + protected PsiElementClassMember(@NotNull T psiMember, @NotNull PsiSubstitutor substitutor, String text) { super(psiMember, text, psiMember.getIcon(Iconable.ICON_FLAG_VISIBILITY)); myPsiMember = psiMember; mySubstitutor = substitutor; } @Override + @NotNull public T getElement() { return myPsiMember; } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java index 0f64be3a38ce..e69bb55f80e7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiFieldMember.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -15,11 +15,14 @@ */ package com.intellij.codeInsight.generation; -import com.intellij.psi.*; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiSubstitutor; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.psi.util.PsiFormatUtilBase; -import com.intellij.psi.util.PsiUtil; import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -31,11 +34,11 @@ import java.util.List; public class PsiFieldMember extends PsiElementClassMember implements PropertyClassMember { private static final int FIELD_OPTIONS = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER; - public PsiFieldMember(final PsiField field) { + public PsiFieldMember(@NotNull PsiField field) { super(field, PsiFormatUtil.formatVariable(field, FIELD_OPTIONS, PsiSubstitutor.EMPTY)); } - public PsiFieldMember(PsiField psiMember, PsiSubstitutor substitutor) { + public PsiFieldMember(@NotNull PsiField psiMember, PsiSubstitutor substitutor) { super(psiMember, substitutor, PsiFormatUtil.formatVariable(psiMember, FIELD_OPTIONS, PsiSubstitutor.EMPTY)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodMember.java b/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodMember.java index 7bf32932af5c..4e8311f7de91 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodMember.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/PsiMethodMember.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -20,6 +20,7 @@ import com.intellij.psi.PsiSubstitutor; import com.intellij.psi.infos.CandidateInfo; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.psi.util.PsiFormatUtilBase; +import org.jetbrains.annotations.NotNull; /** * @author peter @@ -28,15 +29,15 @@ public class PsiMethodMember extends PsiElementClassMember{ private static final int PARAM_OPTIONS = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER; private static final int METHOD_OPTIONS = PARAM_OPTIONS | PsiFormatUtilBase.SHOW_PARAMETERS; - public PsiMethodMember(final PsiMethod method) { + public PsiMethodMember(@NotNull PsiMethod method) { this(method, PsiSubstitutor.EMPTY); } - public PsiMethodMember(CandidateInfo info) { + public PsiMethodMember(@NotNull CandidateInfo info) { this((PsiMethod)info.getElement(), info.getSubstitutor()); } - public PsiMethodMember(final PsiMethod method, final PsiSubstitutor substitutor) { + public PsiMethodMember(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor) { super(method, substitutor, PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, METHOD_OPTIONS, PARAM_OPTIONS)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java b/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java index 6010a7a4b41f..263bf7e15f08 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -164,7 +164,7 @@ public class MacroUtil { final List list = new ArrayList(); VariablesProcessor varproc = new VariablesProcessor(prefix, true, list) { @Override - public boolean execute(@NotNull PsiElement pe, ResolveState state) { + public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) { if (pe instanceof PsiVariable) { if (!usedNames.add(((PsiVariable)pe).getName())) { return false; diff --git a/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java b/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java index c9d53ae387e8..d0d7cce6e280 100644 --- a/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java +++ b/java/java-impl/src/com/intellij/psi/AbstractQualifiedReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -249,7 +249,7 @@ public abstract class AbstractQualifiedReference myResults = new LinkedHashSet(); @Override - public boolean execute(@NotNull final PsiElement element, final ResolveState state) { + public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) { if (isFound()) return false; process(element); return true; @@ -264,7 +264,7 @@ public abstract class AbstractQualifiedReference findConflicts(ChangeInfo info, Ref refUsages) { if (info instanceof JavaChangeInfo) { return new ConflictSearcher((JavaChangeInfo)info).findConflicts(refUsages); @@ -80,6 +82,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr } } + @Override public boolean processUsage(ChangeInfo changeInfo, UsageInfo usage, boolean beforeMethodChange, UsageInfo[] usages) { if (!isJavaUsage(usage)) return false; if (!(changeInfo instanceof JavaChangeInfo)) return false; @@ -510,6 +513,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(list.getProject()).getResolveHelper(); final PsiType type = info.getTypeWrapper().getType(changeInfo.getMethod(), list.getManager()); final VariablesProcessor processor = new VariablesProcessor(false) { + @Override protected boolean check(PsiVariable var, ResolveState state) { if (var instanceof PsiField && !resolveHelper.isAccessible((PsiField)var, list, null)) return false; if (var instanceof PsiLocalVariable && list.getTextRange().getStartOffset() <= var.getTextRange().getStartOffset()) return false; @@ -518,7 +522,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr return type.isAssignableFrom(varType); } - public boolean execute(@NotNull PsiElement pe, ResolveState state) { + @Override + public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) { super.execute(pe, state); return size() < 2; } @@ -549,10 +554,12 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr } final PsiCallExpression callExpression = PsiTreeUtil.getParentOfType(list, PsiCallExpression.class); final String defaultValue = info.getDefaultValue(); - return callExpression != null ? info.getValue(callExpression) : defaultValue.length() > 0 ? factory.createExpressionFromText(defaultValue, list) : null; + return callExpression != null ? info.getValue(callExpression) : !defaultValue.isEmpty() + ? factory.createExpressionFromText(defaultValue, list) : null; } + @Override public boolean processPrimaryMethod(ChangeInfo changeInfo) { if (!StdLanguages.JAVA.equals(changeInfo.getLanguage()) || !(changeInfo instanceof JavaChangeInfo)) return false; final PsiElement element = changeInfo.getMethod(); @@ -564,6 +571,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr return true; } + @Override public boolean shouldPreviewUsages(ChangeInfo changeInfo, UsageInfo[] usages) { return false; } @@ -869,6 +877,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr private static class ParameterList implements ChangeSignatureUtil.ChildrenGenerator { public static final ParameterList INSTANCE = new ParameterList(); + @Override public List getChildren(PsiParameterList psiParameterList) { return Arrays.asList(psiParameterList.getParameters()); } @@ -877,6 +886,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr private static class ThrowsList implements ChangeSignatureUtil.ChildrenGenerator { public static final ThrowsList INSTANCE = new ThrowsList(); + @Override public List getChildren(PsiReferenceList throwsList) { return Arrays.asList(throwsList.getReferenceElements()); } @@ -1013,6 +1023,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr private static class ExpressionList implements ChangeSignatureUtil.ChildrenGenerator { public static final ExpressionList INSTANCE = new ExpressionList(); + @Override public List getChildren(PsiExpressionList psiExpressionList) { return Arrays.asList(psiExpressionList.getExpressions()); } diff --git a/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java b/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java index 254dc036547c..1dc7961ae9ef 100644 --- a/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java +++ b/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java @@ -37,6 +37,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp @NonNls private static final String ARRAY_PREFIX = "[L"; private static final JavaClassReferenceProvider CLASS_REFERENCE_PROVIDER = new JavaClassReferenceProvider(); + @Override public PsiType fromString(final String s, final ConvertContext context) { if (s == null) return null; try { @@ -47,10 +48,12 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp } } + @Override public String toString(final PsiType t, final ConvertContext context) { return t == null ? null : t.getCanonicalText(); } + @Override @NotNull public PsiReference[] createReferences(final GenericDomValue genericDomValue, final PsiElement element, ConvertContext context) { final String typeText = genericDomValue.getStringValue(); @@ -60,7 +63,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp return getReferences(genericDomValue.getValue(), typeText, 0, element); } - public PsiReference[] getReferences(@Nullable PsiType type, String typeText, int startOffsetInText, final PsiElement element) { + public PsiReference[] getReferences(@Nullable PsiType type, String typeText, int startOffsetInText, @NotNull final PsiElement element) { final ElementManipulator manipulator = ElementManipulators.getManipulator(element); assert manipulator != null; String trimmed = typeText.trim(); @@ -80,13 +83,16 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp final boolean isPrimitiveType = type instanceof PsiPrimitiveType; return new JavaClassReferenceSet(trimmed, element, offset, false, CLASS_REFERENCE_PROVIDER) { + @Override @NotNull protected JavaClassReference createReference(int refIndex, @NotNull String subRefText, @NotNull TextRange textRange, boolean staticImport) { return new JavaClassReference(this, textRange, refIndex, subRefText, staticImport) { + @Override public boolean isSoft() { return true; } + @Override @NotNull public JavaResolveResult advancedResolve(final boolean incompleteCode) { if (isPrimitiveType) { @@ -96,6 +102,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp return super.advancedResolve(incompleteCode); } + @Override public void processVariants(@NotNull final PsiScopeProcessor processor) { if (processor instanceof JavaCompletionProcessor) { ((JavaCompletionProcessor)processor).setCompletionElements(getVariants()); @@ -104,6 +111,7 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp } } + @Override @NotNull public Object[] getVariants() { final Object[] variants = super.getVariants(); diff --git a/java/java-psi-api/src/com/intellij/psi/infos/CandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/CandidateInfo.java index aff69cd322a5..fb4bbb3cf4c9 100644 --- a/java/java-psi-api/src/com/intellij/psi/infos/CandidateInfo.java +++ b/java/java-psi-api/src/com/intellij/psi/infos/CandidateInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -18,6 +18,7 @@ package com.intellij.psi.infos; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.JavaVersionService; import com.intellij.psi.*; +import com.intellij.psi.util.PsiUtilCore; import org.jetbrains.annotations.NotNull; /** @@ -28,14 +29,14 @@ public class CandidateInfo implements JavaResolveResult { private final PsiElement myPlace; private final PsiClass myAccessClass; - private final PsiElement myCandidate; + @NotNull private final PsiElement myCandidate; private final boolean myStaticsProblem; protected final PsiSubstitutor mySubstitutor; private final PsiElement myCurrentFileResolveContext; private final boolean myPackagePrefixPackageReference; private Boolean myAccessible; // benign datarace - private CandidateInfo(PsiElement candidate, + private CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, Boolean accessible, boolean staticsProblem, @@ -52,15 +53,15 @@ public class CandidateInfo implements JavaResolveResult { myPlace = place; myPackagePrefixPackageReference = packagePrefixPackageReference; } - public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem, PsiElement currFileContext) { + public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem, PsiElement currFileContext) { this(candidate, substitutor, !accessProblem, staticsProblem, currFileContext, null, null, false); } - public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem){ + public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem){ this(candidate, substitutor, accessProblem, staticsProblem, null); } - public CandidateInfo(PsiElement candidate, + public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, PsiElement place, PsiClass accessClass, @@ -69,15 +70,15 @@ public class CandidateInfo implements JavaResolveResult { this(candidate, substitutor, null, staticsProblem, currFileContext, place, accessClass, false); } - public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor, PsiElement place, boolean staticsProblem){ + public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, PsiElement place, boolean staticsProblem){ this(candidate, substitutor, place, null, staticsProblem, null); } - public CandidateInfo(PsiElement candidate, @NotNull PsiSubstitutor substitutor){ + public CandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor){ this(candidate, substitutor, null, null, false, null); } - public CandidateInfo(CandidateInfo candidate, @NotNull PsiSubstitutor newSubstitutor){ + public CandidateInfo(@NotNull CandidateInfo candidate, @NotNull PsiSubstitutor newSubstitutor){ this(candidate.myCandidate, newSubstitutor, candidate.myAccessible, candidate.myStaticsProblem, candidate.myCurrentFileResolveContext, candidate.myPlace, null, false); } @@ -93,6 +94,7 @@ public class CandidateInfo implements JavaResolveResult { } @Override + @NotNull public PsiElement getElement(){ return myCandidate; } @@ -160,7 +162,7 @@ public class CandidateInfo implements JavaResolveResult { if (myStaticsProblem != that.myStaticsProblem) return false; if (myAccessClass != null ? !myAccessClass.equals(that.myAccessClass) : that.myAccessClass != null) return false; if (isAccessible() != that.isAccessible()) return false; - if (myCandidate != null ? !myCandidate.equals(that.myCandidate) : that.myCandidate != null) return false; + if (!myCandidate.equals(that.myCandidate)) return false; if (myCurrentFileResolveContext != null ? !myCurrentFileResolveContext.equals(that.myCurrentFileResolveContext) : that.myCurrentFileResolveContext != null) { @@ -174,7 +176,7 @@ public class CandidateInfo implements JavaResolveResult { public int hashCode() { int result = myPlace != null ? myPlace.hashCode() : 0; result = 31 * result + (myAccessClass != null ? myAccessClass.hashCode() : 0); - result = 31 * result + (myCandidate != null ? myCandidate.hashCode() : 0); + result = 31 * result + myCandidate.hashCode(); result = 31 * result + (isAccessible() ? 1 : 0); result = 31 * result + (myStaticsProblem ? 1 : 0); result = 31 * result + mySubstitutor.hashCode(); @@ -185,5 +187,5 @@ public class CandidateInfo implements JavaResolveResult { @NotNull public static final JavaResolveResult[] RESOLVE_RESULT_FOR_PACKAGE_PREFIX_PACKAGE = - {new CandidateInfo(null, PsiSubstitutor.EMPTY, Boolean.TRUE, false, null, null, null, true)}; + {new CandidateInfo(PsiUtilCore.NULL_PSI_ELEMENT, PsiSubstitutor.EMPTY, Boolean.TRUE, false, null, null, null, true)}; } diff --git a/java/java-psi-api/src/com/intellij/psi/infos/ClassCandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/ClassCandidateInfo.java index 97876b21d170..110b88d3bd6e 100644 --- a/java/java-psi-api/src/com/intellij/psi/infos/ClassCandidateInfo.java +++ b/java/java-psi-api/src/com/intellij/psi/infos/ClassCandidateInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -18,6 +18,7 @@ package com.intellij.psi.infos; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiSubstitutor; +import org.jetbrains.annotations.NotNull; /** * Created by IntelliJ IDEA. @@ -27,14 +28,15 @@ import com.intellij.psi.PsiSubstitutor; * To change this template use Options | File Templates. */ public class ClassCandidateInfo extends CandidateInfo{ - public ClassCandidateInfo(PsiElement candidate, PsiSubstitutor substitutor, boolean accessProblem, PsiElement currFileContext){ + public ClassCandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor, boolean accessProblem, PsiElement currFileContext){ super(candidate, substitutor, accessProblem, false, currFileContext); } - public ClassCandidateInfo(PsiElement candidate, PsiSubstitutor substitutor){ + public ClassCandidateInfo(@NotNull PsiElement candidate, @NotNull PsiSubstitutor substitutor){ super(candidate, substitutor, false, false); } + @NotNull @Override public PsiClass getElement(){ return (PsiClass)super.getElement(); diff --git a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java index 85619f85c1f5..724adf33e24a 100644 --- a/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java +++ b/java/java-psi-api/src/com/intellij/psi/infos/MethodCandidateInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -47,7 +47,7 @@ public class MethodCandidateInfo extends CandidateInfo{ private PsiSubstitutor myCalcedSubstitutor; // benign race private final LanguageLevel myLanguageLevel; - public MethodCandidateInfo(PsiElement candidate, + public MethodCandidateInfo(@NotNull PsiElement candidate, PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem, @@ -59,8 +59,8 @@ public class MethodCandidateInfo extends CandidateInfo{ PsiUtil.getLanguageLevel(argumentList)); } - public MethodCandidateInfo(PsiElement candidate, - PsiSubstitutor substitutor, + public MethodCandidateInfo(@NotNull PsiElement candidate, + @NotNull PsiSubstitutor substitutor, boolean accessProblem, boolean staticsProblem, PsiElement argumentList, @@ -155,11 +155,9 @@ public class MethodCandidateInfo extends CandidateInfo{ PsiSubstitutor incompleteSubstitutor = super.getSubstitutor(); if (myTypeArguments != null) { PsiMethod method = getElement(); - if (method != null) { - PsiTypeParameter[] typeParams = method.getTypeParameters(); - for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) { - incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]); - } + PsiTypeParameter[] typeParams = method.getTypeParameters(); + for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) { + incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]); } } return incompleteSubstitutor; @@ -216,7 +214,7 @@ public class MethodCandidateInfo extends CandidateInfo{ } protected PsiElement getParent() { - return myArgumentList != null ? myArgumentList.getParent() : myArgumentList; + return myArgumentList != null ? myArgumentList.getParent() : null; } @Override @@ -224,6 +222,7 @@ public class MethodCandidateInfo extends CandidateInfo{ return super.isValidResult() && isApplicable(); } + @NotNull @Override public PsiMethod getElement(){ return (PsiMethod)super.getElement(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 9da870069461..3f4cea44d90a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -225,7 +225,7 @@ public class PsiClassImplUtil { FilterScopeProcessor processor = new FilterScopeProcessor( new OrFilter(ElementClassFilter.METHOD, ElementClassFilter.FIELD, ElementClassFilter.CLASS)) { @Override - protected void add(PsiElement element, PsiSubstitutor substitutor) { + protected void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) { if (element instanceof PsiMethod) { methods.add(Pair.create((PsiMember)element, substitutor)); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaCodeReferenceElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaCodeReferenceElementImpl.java index 534b4c77a811..7b44a496416c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaCodeReferenceElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaCodeReferenceElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -95,14 +95,14 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P @Override public JavaResolveResult[] resolve(@NotNull ClsJavaCodeReferenceElementImpl ref, boolean incompleteCode) { final JavaResolveResult resolveResult = ref.advancedResolveImpl(); - return resolveResult.getElement() == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[] {resolveResult}; + return resolveResult == null ? JavaResolveResult.EMPTY_ARRAY : new JavaResolveResult[] {resolveResult}; } } private JavaResolveResult advancedResolveImpl() { PsiTypeElement[] typeElements = myRefParameterList == null ? PsiTypeElement.EMPTY_ARRAY : myRefParameterList.getTypeParameterElements(); PsiElement resolve = resolveElement(); - + if (resolve == null) return null; if (resolve instanceof PsiClass) { Map substitutionMap = new HashMap(); int index = 0; @@ -129,7 +129,7 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P } index++; } - collectOuterClassTypeArgs(((PsiClass)resolve), myCanonicalText, substitutionMap); + collectOuterClassTypeArgs((PsiClass)resolve, myCanonicalText, substitutionMap); return new CandidateInfo(resolve, PsiSubstitutorImpl.createSubstitutor(substitutionMap)); } else { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightMemberReference.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightMemberReference.java index bc90ac135613..0f5d8f5d8a49 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightMemberReference.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightMemberReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -24,12 +24,12 @@ import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; public class LightMemberReference extends LightElement implements PsiJavaCodeReferenceElement { - private final PsiMember myRefMember; + @NotNull private final PsiMember myRefMember; private final PsiSubstitutor mySubstitutor; private LightReferenceParameterList myParameterList; - public LightMemberReference(PsiManager manager, PsiMember refClass, PsiSubstitutor substitutor) { + public LightMemberReference(PsiManager manager, @NotNull PsiMember refClass, PsiSubstitutor substitutor) { super(manager, JavaLanguage.INSTANCE); myRefMember = refClass; @@ -37,6 +37,7 @@ public class LightMemberReference extends LightElement implements PsiJavaCodeRef } @Override + @NotNull public PsiElement resolve() { return myRefMember; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightPackageReference.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightPackageReference.java index 7aa6aaac83af..56916f6e2acb 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightPackageReference.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightPackageReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -52,7 +52,8 @@ public class LightPackageReference extends LightElement implements PsiJavaCodeRe @Override @NotNull public JavaResolveResult advancedResolve(boolean incompleteCode){ - return new CandidateInfo(resolve(), PsiSubstitutor.EMPTY); + PsiElement resolve = resolve(); + return resolve == null ? JavaResolveResult.EMPTY : new CandidateInfo(resolve, PsiSubstitutor.EMPTY); } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java index dd88a17396c9..cbe3e2bf923c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -242,7 +242,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava } @Override - public void handleEvent(final Event event, final Object associated) { + public void handleEvent(@NotNull final Event event, final Object associated) { if (JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT.equals(event) && associated instanceof PsiImportStaticStatement) { final PsiImportStaticStatement importStaticStatement = (PsiImportStaticStatement)associated; myIsProcessingOnDemand = importStaticStatement.isOnDemand(); @@ -254,7 +254,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava } @Override - public boolean execute(@NotNull final PsiElement element, final ResolveState state) { + public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) { if (element instanceof PsiModifierListOwner && ((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) { if (element instanceof PsiNamedElement && myIsProcessingOnDemand) { final String name = ((PsiNamedElement)element).getName(); @@ -290,7 +290,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava return processDeclarationsNoGuess(processor, state, lastParent, place); } - private boolean processDeclarationsNoGuess(PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place) { + private boolean processDeclarationsNoGuess(PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, PsiElement place) { processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this); final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); final NameHint nameHint = processor.getHint(NameHint.KEY); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ClassResolverProcessor.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ClassResolverProcessor.java index b0eb406f2aef..b109372cc882 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ClassResolverProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/ClassResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -83,7 +83,7 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi } @Override - public String getName(ResolveState state) { + public String getName(@NotNull ResolveState state) { return myClassName; } @@ -93,7 +93,7 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi } @Override - public void handleEvent(PsiScopeProcessor.Event event, Object associated) { + public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) { if (event == JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT) { myCurrentFileContext = (PsiElement)associated; } @@ -207,7 +207,7 @@ public class ClassResolverProcessor extends BaseScopeProcessor implements NameHi } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (!(element instanceof PsiClass)) return true; final PsiClass aClass = (PsiClass)element; final String name = aClass.getName(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index 840d1b43b991..65a2ef6d7d1e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -101,7 +101,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { } @Nullable - private PsiVariable resolveVar(final String referenceText, final PsiElement context, final boolean[] problemWithAccess) { + private PsiVariable resolveVar(@NotNull String referenceText, final PsiElement context, final boolean[] problemWithAccess) { final PsiJavaParserFacade parserFacade = JavaPsiFacade.getInstance(myManager.getProject()).getParserFacade(); try { final PsiJavaCodeReferenceElement ref = parserFacade.createReferenceFromText(referenceText, context); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java index 335969987d41..374ad46794fa 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -33,13 +33,13 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements private final List myClassResult = new SmartList(); private final List myResults = new SmartList(); - public StaticImportResolveProcessor(final PsiImportStaticReferenceElement reference) { + public StaticImportResolveProcessor(@NotNull PsiImportStaticReferenceElement reference) { myReference = reference; myName = myReference.getReferenceName(); } @Override - public boolean execute(@NotNull final PsiElement candidate, final ResolveState state) { + public boolean execute(@NotNull final PsiElement candidate, @NotNull final ResolveState state) { if (candidate instanceof PsiMember && ((PsiModifierListOwner)candidate).hasModifierProperty(PsiModifier.STATIC)) { if (candidate instanceof PsiField) { if (checkDomination((PsiMember)candidate, myFieldResults)) return true; @@ -86,7 +86,7 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements } @Override - public String getName(final ResolveState state) { + public String getName(@NotNull final ResolveState state) { return myName; } @@ -124,7 +124,7 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements private static class OurResolveResult extends CandidateInfo { private final PsiImportStaticReferenceElement myReference; - public OurResolveResult(final PsiElement candidate, final PsiImportStaticReferenceElement reference) { + public OurResolveResult(@NotNull PsiElement candidate, final PsiImportStaticReferenceElement reference) { super(candidate, PsiSubstitutor.EMPTY); myReference = reference; } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java index c65b6e65a6df..b283b39360ca 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -43,14 +43,14 @@ public class SymbolCollectingProcessor extends BaseScopeProcessor implements Ele } @Override - public void handleEvent(PsiScopeProcessor.Event event, Object associated) { + public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) { if (event == JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT) { myCurrentFileContext = (PsiElement)associated; } } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiNamedElement) { PsiNamedElement named = (PsiNamedElement)element; String name = named.getName(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/VariableResolverProcessor.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/VariableResolverProcessor.java index f72ee4f54427..ead814a8ef63 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/VariableResolverProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/VariableResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -69,7 +69,7 @@ public class VariableResolverProcessor extends ConflictFilterProcessor implement } @Override - public final void handleEvent(PsiScopeProcessor.Event event, Object associated) { + public final void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) { super.handleEvent(event, associated); if(event == JavaScopeProcessorEvent.START_STATIC){ myStaticScopeFlag = true; @@ -80,7 +80,7 @@ public class VariableResolverProcessor extends ConflictFilterProcessor implement } @Override - public void add(PsiElement element, PsiSubstitutor substitutor) { + public void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) { final boolean staticProblem = myStaticScopeFlag && !((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC); add(new CandidateInfo(element, substitutor, myPlace, myAccessClass, staticProblem, myCurrentFileContext)); } @@ -92,7 +92,7 @@ public class VariableResolverProcessor extends ConflictFilterProcessor implement } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (!(element instanceof PsiField) && (myName == null || PsiUtil.checkName(element, myName, myPlace))) { super.execute(element, state); return myResults.isEmpty(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java index b03e9a42e3f5..e530554341fd 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiCodeBlockImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -102,7 +102,7 @@ public class PsiCodeBlockImpl extends LazyParseablePsiElement implements PsiCode final Ref conflict = new Ref(Boolean.FALSE); PsiScopesUtil.walkChildrenScopes(this, new BaseScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiLocalVariable) { final PsiLocalVariable variable = (PsiLocalVariable)element; final String name = variable.getName(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java index f48fcb59f57a..94f6adf546de 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -451,8 +451,8 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase } @Override - protected MethodCandidateInfo createCandidateInfo(final PsiMethod method, - final PsiSubstitutor substitutor, + protected MethodCandidateInfo createCandidateInfo(@NotNull final PsiMethod method, + @NotNull final PsiSubstitutor substitutor, final boolean staticProblem, final boolean accessible, final boolean varargs) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java index 7f4a7dd1dd8b..f91f01c3195c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiReferenceExpressionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -491,7 +491,7 @@ public class PsiReferenceExpressionImpl extends PsiReferenceExpressionBase imple private final Set myVarNames = new THashSet(); @Override - public boolean execute(@NotNull final PsiElement element, final ResolveState state) { + public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) { if (element instanceof PsiLocalVariable || element instanceof PsiParameter) { myVarNames.add(((PsiVariable) element).getName()); } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/NameHint.java b/java/java-psi-impl/src/com/intellij/psi/scope/NameHint.java index be526419b8f4..5b1fdfdbaaf5 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/NameHint.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/NameHint.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -17,11 +17,12 @@ package com.intellij.psi.scope; import com.intellij.openapi.util.Key; import com.intellij.psi.ResolveState; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface NameHint { Key KEY = Key.create("NameHint"); @Nullable - String getName(ResolveState state); + String getName(@NotNull ResolveState state); } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/ConflictFilterProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/ConflictFilterProcessor.java index f46dd70fc398..0744b3b59d41 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/ConflictFilterProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/ConflictFilterProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -34,7 +34,7 @@ import java.util.List; */ public class ConflictFilterProcessor extends FilterScopeProcessor implements NameHint { private final PsiConflictResolver[] myResolvers; - private JavaResolveResult[] myCachedResult = null; + private JavaResolveResult[] myCachedResult; protected String myName; protected final PsiElement myPlace; protected final PsiFile myPlaceFile; @@ -53,8 +53,9 @@ public class ConflictFilterProcessor extends FilterScopeProcessor } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { - if (myCachedResult != null && myCachedResult.length == 1 && myCachedResult[0].isAccessible()) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { + JavaResolveResult[] cachedResult = myCachedResult; + if (cachedResult != null && cachedResult.length == 1 && cachedResult[0].isAccessible()) { return false; } if (myName == null || PsiUtil.checkName(element, myName, myPlace)) { @@ -64,7 +65,7 @@ public class ConflictFilterProcessor extends FilterScopeProcessor } @Override - protected void add(PsiElement element, PsiSubstitutor substitutor) { + protected void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) { add(new CandidateInfo(element, substitutor)); } @@ -74,7 +75,7 @@ public class ConflictFilterProcessor extends FilterScopeProcessor } @Override - public void handleEvent(PsiScopeProcessor.Event event, Object associated) { + public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) { if (event == JavaScopeProcessorEvent.CHANGE_LEVEL && myName != null) { getResult(); } @@ -82,7 +83,8 @@ public class ConflictFilterProcessor extends FilterScopeProcessor @NotNull public JavaResolveResult[] getResult() { - if (myCachedResult == null) { + JavaResolveResult[] cachedResult = myCachedResult; + if (cachedResult == null) { final List conflicts = getResults(); for (PsiConflictResolver resolver : myResolvers) { CandidateInfo candidate = resolver.resolveConflict(conflicts); @@ -92,14 +94,14 @@ public class ConflictFilterProcessor extends FilterScopeProcessor break; } } - myCachedResult = conflicts.toArray(new JavaResolveResult[conflicts.size()]); + myCachedResult = cachedResult = conflicts.toArray(new JavaResolveResult[conflicts.size()]); } - return myCachedResult; + return cachedResult; } @Override - public String getName(ResolveState state) { + public String getName(@NotNull ResolveState state) { return myName; } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/FilterScopeProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/FilterScopeProcessor.java index 96c8d95c9a5f..78be6842950d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/FilterScopeProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/FilterScopeProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -57,7 +57,7 @@ public class FilterScopeProcessor extends BaseScopeProcessor { } @Override - public void handleEvent(PsiScopeProcessor.Event event, Object associated) { + public void handleEvent(@NotNull PsiScopeProcessor.Event event, Object associated) { if (myProcessor != null) { myProcessor.handleEvent(event, associated); } @@ -67,7 +67,7 @@ public class FilterScopeProcessor extends BaseScopeProcessor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (myFilter.isAcceptable(element, myCurrentDeclarationHolder)) { if (myProcessor != null) { return myProcessor.execute(element, state); @@ -77,13 +77,13 @@ public class FilterScopeProcessor extends BaseScopeProcessor { return true; } - protected void add(PsiElement element, PsiSubstitutor substitutor) { + protected void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) { //noinspection unchecked myResults.add((T)element); } @Override - public T getHint(@NotNull Key hintKey) { + public K getHint(@NotNull Key hintKey) { if (myProcessor != null) { return myProcessor.getHint(hintKey); } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java index e44dfc7a9040..0a21f9ed2f81 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodCandidatesProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -43,14 +43,14 @@ public class MethodCandidatesProcessor extends MethodsProcessor{ } @Override - public void add(PsiElement element, PsiSubstitutor substitutor) { + public void add(@NotNull PsiElement element, @NotNull PsiSubstitutor substitutor) { if (element instanceof PsiMethod) { final PsiMethod method = (PsiMethod)element; addMethod(method, substitutor, isInStaticScope() && !method.hasModifierProperty(PsiModifier.STATIC)); } } - public void addMethod(final PsiMethod method, final PsiSubstitutor substitutor, final boolean staticProblem) { + public void addMethod(@NotNull PsiMethod method, final PsiSubstitutor substitutor, final boolean staticProblem) { final boolean isAccessible = JavaResolveUtil.isAccessible(method, method.getContainingClass(), method.getModifierList(), myPlace, myAccessClass, myCurrentFileContext, myPlaceFile) && !isShadowed(method); @@ -67,7 +67,7 @@ public class MethodCandidatesProcessor extends MethodsProcessor{ return false; } - protected MethodCandidateInfo createCandidateInfo(final PsiMethod method, final PsiSubstitutor substitutor, + protected MethodCandidateInfo createCandidateInfo(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, final boolean staticProblem, final boolean accessible, final boolean varargs) { final PsiExpressionList argumentList = getArgumentList(); return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext, diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolveProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolveProcessor.java index 463e2a12b04a..664b70fd39b2 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolveProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolveProcessor.java @@ -1,17 +1,17 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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 + * 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 + * 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. + * 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. */ package com.intellij.psi.scope.processor; @@ -51,13 +51,15 @@ public class MethodResolveProcessor implements PsiScopeProcessor, ElementClassHi return myMethods.toArray(new PsiMethod[myMethods.size()]); } - public boolean execute(@NotNull PsiElement element, ResolveState state) { + @Override + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod) { ContainerUtil.addIfNotNull(myMethods, (PsiMethod)element); } return true; } + @Override public T getHint(@NotNull Key hintKey) { if (hintKey == ElementClassHint.KEY) { return (T)this; @@ -68,9 +70,11 @@ public class MethodResolveProcessor implements PsiScopeProcessor, ElementClassHi return null; } - public void handleEvent(Event event, Object associated) { + @Override + public void handleEvent(@NotNull Event event, Object associated) { } + @Override public boolean shouldProcess(DeclarationKind kind) { return kind == DeclarationKind.METHOD; } @@ -90,7 +94,7 @@ public class MethodResolveProcessor implements PsiScopeProcessor, ElementClassHi @Nullable @Override - public String getName(ResolveState state) { + public String getName(@NotNull ResolveState state) { return myNameHint; } } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java index b73f87b72ce4..543143e44149 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -52,7 +52,7 @@ public class MethodResolverProcessor extends MethodCandidatesProcessor { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { if (event == JavaScopeProcessorEvent.CHANGE_LEVEL) { if (myHasAccessibleStaticCorrectCandidate) myStopAcceptingCandidates = true; } @@ -60,7 +60,7 @@ public class MethodResolverProcessor extends MethodCandidatesProcessor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { return !myStopAcceptingCandidates && super.execute(element, state); } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodsProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodsProcessor.java index 47e8b8a6d81a..1d89d43450cd 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodsProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/MethodsProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -89,7 +89,7 @@ public abstract class MethodsProcessor extends ConflictFilterProcessor implement } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { if (event == JavaScopeProcessorEvent.START_STATIC) { myStaticScopeFlag = true; } @@ -110,7 +110,7 @@ public abstract class MethodsProcessor extends ConflictFilterProcessor implement this.myIsConstructor = myIsConstructor; } - public void forceAddResult(PsiMethod method) { + public void forceAddResult(@NotNull PsiMethod method) { add(new CandidateInfo(method, PsiSubstitutor.EMPTY, false, false, myCurrentFileContext)); } diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java index 6f9d64c105d8..530a8ad83f02 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -53,7 +53,7 @@ public abstract class VariablesProcessor extends BaseScopeProcessor implements E /** Always return true since we wanna get all vars in scope */ @Override - public boolean execute(@NotNull PsiElement pe, ResolveState state){ + public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state){ if(pe instanceof PsiVariable){ final PsiVariable pvar = (PsiVariable)pe; if(!myStaticSensitiveFlag || !myStaticScopeFlag || pvar.hasModifierProperty(PsiModifier.STATIC)){ @@ -66,7 +66,7 @@ public abstract class VariablesProcessor extends BaseScopeProcessor implements E } @Override - public final void handleEvent(Event event, Object associated){ + public final void handleEvent(@NotNull Event event, Object associated){ if(event == JavaScopeProcessorEvent.START_STATIC) myStaticScopeFlag = true; } diff --git a/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java b/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java index f692c8ff50da..3d27bf820390 100644 --- a/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java +++ b/java/java-structure-view/src/com/intellij/ide/structureView/impl/AddAllMembersProcessor.java @@ -43,7 +43,7 @@ public class AddAllMembersProcessor extends BaseScopeProcessor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { PsiMember member = (PsiMember)element; if (!isInteresting(element)) return true; if (myPsiClass.isInterface() && isObjectMember(element)) return true; diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/IntObjectPersistentMaplet.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/IntObjectPersistentMaplet.java index 53c3fd3bd194..855f72684d2f 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/IntObjectPersistentMaplet.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/IntObjectPersistentMaplet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -120,6 +120,7 @@ public class IntObjectPersistentMaplet extends IntObjectMaplet{ } } + @Override public void flush(boolean memoryCachesOnly) { if (memoryCachesOnly) { if (myMap.isDirty()) { @@ -139,7 +140,7 @@ public class IntObjectPersistentMaplet extends IntObjectMaplet{ public boolean process(Integer key) { try { final V value = myMap.get(key); - return value == null? proc.execute(key, null) : proc.execute(key, value); + return proc.execute(key, value); } catch (IOException e) { throw new BuildDataCorruptedException(e); diff --git a/platform/core-api/src/com/intellij/psi/ResolveState.java b/platform/core-api/src/com/intellij/psi/ResolveState.java index 714652c71437..6ea8dfc046b0 100644 --- a/platform/core-api/src/com/intellij/psi/ResolveState.java +++ b/platform/core-api/src/com/intellij/psi/ResolveState.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -22,6 +22,7 @@ package com.intellij.psi; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.KeyWithDefaultValue; import gnu.trove.THashMap; +import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -29,15 +30,17 @@ import java.util.Map; public class ResolveState { private static final ResolveState ourInitialState = new ResolveState(); + @NotNull public static ResolveState initial() { return ourInitialState; } - public ResolveState put(Key key, T value) { + @NotNull + public ResolveState put(@NotNull Key key, T value) { return new OneElementResolveState(key, value); } - public T get(Key key) { + public T get(@NotNull Key key) { if (key instanceof KeyWithDefaultValue) { return ((KeyWithDefaultValue)key).getDefaultValue(); } @@ -45,16 +48,18 @@ public class ResolveState { } private static class OneElementResolveState extends ResolveState { - final Key myKey; - final Object myValue; + @NotNull + private final Key myKey; + private final Object myValue; - OneElementResolveState(Key key, Object value) { + private OneElementResolveState(@NotNull Key key, Object value) { myKey = key; myValue = value; } + @NotNull @Override - public ResolveState put(Key key, T value) { + public ResolveState put(@NotNull Key key, T value) { if (myKey.equals(key)) { return new OneElementResolveState(key, value); } @@ -63,7 +68,7 @@ public class ResolveState { } @Override - public T get(Key key) { + public T get(@NotNull Key key) { Object value = myKey.equals(key) ? myValue : null; if (value == null && key instanceof KeyWithDefaultValue) { return ((KeyWithDefaultValue)key).getDefaultValue(); @@ -73,20 +78,21 @@ public class ResolveState { } private static class TwoElementResolveState extends ResolveState { - final Key myKey1; - final Object myValue1; - final Key myKey2; - final Object myValue2; + @NotNull private final Key myKey1; + private final Object myValue1; + @NotNull private final Key myKey2; + private final Object myValue2; - TwoElementResolveState(Key key1, Object value1, Key key2, Object value2) { + TwoElementResolveState(@NotNull Key key1, Object value1, @NotNull Key key2, Object value2) { myKey1 = key1; myValue1 = value1; myKey2 = key2; myValue2 = value2; } + @NotNull @Override - public ResolveState put(Key key, T value) { + public ResolveState put(@NotNull Key key, T value) { if (myKey1.equals(key)) { return new TwoElementResolveState(key, value, myKey2, myValue2); } @@ -98,7 +104,7 @@ public class ResolveState { } @Override - public T get(Key key) { + public T get(@NotNull Key key) { Object value; if (myKey1.equals(key)) { value = myValue1; @@ -118,27 +124,27 @@ public class ResolveState { } private static class ManyElementResolveState extends ResolveState { - private final Map myValues = new THashMap(); - ManyElementResolveState(ManyElementResolveState parent, Key key, Object value) { + ManyElementResolveState(@NotNull ManyElementResolveState parent, @NotNull Key key, Object value) { myValues.putAll(parent.myValues); myValues.put(key, value); } - ManyElementResolveState(TwoElementResolveState twoState, Key key, Object value) { + ManyElementResolveState(@NotNull TwoElementResolveState twoState, @NotNull Key key, Object value) { myValues.put(twoState.myKey1, twoState.myValue1); myValues.put(twoState.myKey2, twoState.myValue2); myValues.put(key, value); } + @NotNull @Override - public ResolveState put(Key key, T value) { + public ResolveState put(@NotNull Key key, T value) { return new ManyElementResolveState(this, key, value); } @Override - public T get(Key key) { + public T get(@NotNull Key key) { final T value = (T)myValues.get(key); if (value == null && key instanceof KeyWithDefaultValue) { return ((KeyWithDefaultValue) key).getDefaultValue(); diff --git a/platform/core-api/src/com/intellij/psi/scope/PsiScopeProcessor.java b/platform/core-api/src/com/intellij/psi/scope/PsiScopeProcessor.java index 28983a78a911..bd8d55b4133a 100644 --- a/platform/core-api/src/com/intellij/psi/scope/PsiScopeProcessor.java +++ b/platform/core-api/src/com/intellij/psi/scope/PsiScopeProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -31,10 +31,10 @@ public interface PsiScopeProcessor { * @param state current state of resolver. * @return false to stop processing. */ - boolean execute(@NotNull PsiElement element, ResolveState state); + boolean execute(@NotNull PsiElement element, @NotNull ResolveState state); @Nullable T getHint(@NotNull Key hintKey); - void handleEvent(Event event, @Nullable Object associated); + void handleEvent(@NotNull Event event, @Nullable Object associated); } diff --git a/platform/core-impl/src/com/intellij/psi/impl/ResolveScopeManager.java b/platform/core-impl/src/com/intellij/psi/impl/ResolveScopeManager.java index 3b9b5849faea..92bb374969a2 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/ResolveScopeManager.java +++ b/platform/core-impl/src/com/intellij/psi/impl/ResolveScopeManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -44,7 +44,7 @@ public abstract class ResolveScopeManager { } @NotNull - public static GlobalSearchScope getElementResolveScope(PsiElement element) { + public static GlobalSearchScope getElementResolveScope(@NotNull PsiElement element) { return getInstance(element.getProject()).getResolveScope(element); } } diff --git a/platform/core-impl/src/com/intellij/psi/scope/BaseScopeProcessor.java b/platform/core-impl/src/com/intellij/psi/scope/BaseScopeProcessor.java index 889122c2fe63..943da35b3d5e 100644 --- a/platform/core-impl/src/com/intellij/psi/scope/BaseScopeProcessor.java +++ b/platform/core-impl/src/com/intellij/psi/scope/BaseScopeProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -25,6 +25,6 @@ public abstract class BaseScopeProcessor implements PsiScopeProcessor { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { } } diff --git a/platform/lang-api/src/com/intellij/codeInsight/generation/PsiElementMemberChooserObject.java b/platform/lang-api/src/com/intellij/codeInsight/generation/PsiElementMemberChooserObject.java index 016a38a01e47..5bf2f9504d6e 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/generation/PsiElementMemberChooserObject.java +++ b/platform/lang-api/src/com/intellij/codeInsight/generation/PsiElementMemberChooserObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -30,11 +30,12 @@ public class PsiElementMemberChooserObject extends MemberChooserObjectBase { myPsiElement = psiElement; } - public PsiElementMemberChooserObject(final PsiElement psiElement, final String text, @Nullable final Icon icon) { + public PsiElementMemberChooserObject(@NotNull PsiElement psiElement, final String text, @Nullable final Icon icon) { super(text, icon); myPsiElement = psiElement; } + @NotNull public PsiElement getPsiElement() { return myPsiElement; } diff --git a/platform/lang-impl/src/com/intellij/psi/scope/DelegatingScopeProcessor.java b/platform/lang-impl/src/com/intellij/psi/scope/DelegatingScopeProcessor.java index ea5c27501cca..b9e41eb1bbd3 100644 --- a/platform/lang-impl/src/com/intellij/psi/scope/DelegatingScopeProcessor.java +++ b/platform/lang-impl/src/com/intellij/psi/scope/DelegatingScopeProcessor.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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. + */ package com.intellij.psi.scope; import com.intellij.openapi.util.Key; @@ -12,12 +27,12 @@ import org.jetbrains.annotations.Nullable; public abstract class DelegatingScopeProcessor implements PsiScopeProcessor { private final PsiScopeProcessor myDelegate; - public DelegatingScopeProcessor(PsiScopeProcessor delegate) { + public DelegatingScopeProcessor(@NotNull PsiScopeProcessor delegate) { myDelegate = delegate; } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { return myDelegate.execute(element, state); } @@ -28,7 +43,7 @@ public abstract class DelegatingScopeProcessor implements PsiScopeProcessor { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { myDelegate.handleEvent(event, associated); } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleConfigurationsNonCodeMembersContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleConfigurationsNonCodeMembersContributor.java index fa56f5b7814b..b9a534ad09ad 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleConfigurationsNonCodeMembersContributor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleConfigurationsNonCodeMembersContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -45,7 +45,7 @@ public class GradleConfigurationsNonCodeMembersContributor extends NonCodeMember PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { if (place == null || aClass == null) { return; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java index fc6bceacb429..d3ad60e3111d 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleScriptContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -37,7 +37,7 @@ import java.util.Set; */ public class GradleScriptContributor extends NonCodeMembersContributor { - public final static Set BUILD_PROJECT_SCRIPT_BLOCKS = ContainerUtil.newHashSet( + public static final Set BUILD_PROJECT_SCRIPT_BLOCKS = ContainerUtil.newHashSet( "project", "configure", "subprojects", @@ -51,7 +51,7 @@ public class GradleScriptContributor extends NonCodeMembersContributor { PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { if (place == null) { return; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleSettingsScriptContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleSettingsScriptContributor.java index 1bb333d13ba4..52a548d22a01 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleSettingsScriptContributor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleSettingsScriptContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -34,7 +34,7 @@ public class GradleSettingsScriptContributor extends NonCodeMembersContributor { PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { if (place == null) { return; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/accessors/GrFieldMember.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/accessors/GrFieldMember.java index dae05f9c94ab..055b60d81a18 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/accessors/GrFieldMember.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/accessors/GrFieldMember.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -23,6 +23,7 @@ import com.intellij.psi.PsiModifier; import com.intellij.psi.PsiSubstitutor; import com.intellij.psi.util.PsiFormatUtil; import com.intellij.psi.util.PsiFormatUtilBase; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.actions.generate.GroovyGenerationInfo; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod; @@ -35,10 +36,11 @@ import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils; public class GrFieldMember extends PsiElementClassMember implements EncapsulatableClassMember { private static final int FIELD_OPTIONS = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.TYPE_AFTER; - protected GrFieldMember(final PsiField field) { + protected GrFieldMember(@NotNull PsiField field) { super(field, PsiFormatUtil.formatVariable(field, FIELD_OPTIONS, PsiSubstitutor.EMPTY)); } + @Override @Nullable public GroovyGenerationInfo generateGetter() { PsiField field = getElement(); @@ -52,6 +54,7 @@ public class GrFieldMember extends PsiElementClassMember implements En return existing == null || existing instanceof GrAccessorMethod ? template : null; } + @Override @Nullable public GroovyGenerationInfo generateSetter() { PsiField field = getElement(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicMembersContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicMembersContributor.java index 03381b494424..079cd796fed4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicMembersContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicMembersContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -31,7 +31,7 @@ public class DynamicMembersContributor extends NonCodeMembersContributor { PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { if (aClass == null) return; final DynamicManager manager = DynamicManager.getInstance(place.getProject()); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java index 6b58f99d0ddc..a833dbe0dc4d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java @@ -384,7 +384,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo final Ref result = new Ref(false); PsiScopeProcessor processor = new PsiScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod && name.equals(((PsiMethod)element).getName()) && patternMethod.getParameterList().getParametersCount() == ((PsiMethod)element).getParameterList().getParametersCount() && @@ -402,7 +402,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo } @Override - public void handleEvent(Event event, @Nullable Object associated) { + public void handleEvent(@NotNull Event event, @Nullable Object associated) { } }; ResolveUtil.treeWalkUp(container, processor, true); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java index 5a75a0d13db9..f3e3710ff2b6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -65,14 +65,17 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this); } + @Override public void setThisType(PsiType thisType) { myThisType = thisType; } + @Override public PsiType getSuperType() { return mySuperType; } + @Override public void setSuperType(PsiType superType) { mySuperType = superType; } @@ -94,6 +97,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme /** * @return list of imports in format "qname[:imported_name](,qname[:imported_name])*" */ + @Override public String importsToString() { if (myPseudoImports.isEmpty()) return ""; @@ -122,6 +126,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme return buffer.toString(); } + @Override public void addImportsFromString(String imports) { for (String anImport : imports.split(",")) { int colon = anImport.indexOf(':'); @@ -137,48 +142,58 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme } } + @Override public void setVisibilityChecker(JavaCodeFragment.VisibilityChecker checker) { } + @Override public VisibilityChecker getVisibilityChecker() { return VisibilityChecker.EVERYTHING_VISIBLE; } + @Override public void setExceptionHandler(ExceptionHandler checker) { myExceptionChecker = checker; } + @Override public ExceptionHandler getExceptionHandler() { return myExceptionChecker; } + @Override public void setIntentionActionsFilter(@NotNull IntentionActionsFilter filter) { myFilter = filter; } + @Override public IntentionActionsFilter getIntentionActionsFilter() { return myFilter; } + @Override public void forceResolveScope(GlobalSearchScope scope) { myResolveScope = scope; } + @Override public GlobalSearchScope getForcedResolveScope() { return myResolveScope; } + @Override public boolean importClass(PsiClass aClass) { return false; } + @Override public PsiType getThisType() { return myThisType; } @Override protected boolean processImports(PsiScopeProcessor processor, - ResolveState state, + @NotNull ResolveState state, PsiElement lastParent, PsiElement place, GrImportStatement[] importStatements, @@ -209,7 +224,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme } protected boolean processPseudoImports(PsiScopeProcessor processor, - ResolveState state, + @NotNull ResolveState state, PsiElement lastParent, PsiElement place, boolean onDemand) { @@ -235,7 +250,7 @@ public class GroovyCodeFragment extends GroovyFileImpl implements JavaCodeFragme return true; } - private boolean processSingleImports(PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place) { + private boolean processSingleImports(PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, PsiElement place) { NameHint nameHint = processor.getHint(NameHint.KEY); String name = nameHint != null ? nameHint.getName(state) : null; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java index 224c5b43878c..8429af8847d7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -38,7 +38,7 @@ public class DGMMemberContributor extends NonCodeMembersContributor { PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { Project project = place.getProject(); GlobalSearchScope resolveScope = place.getResolveScope(); GroovyPsiManager groovyPsiManager = GroovyPsiManager.getInstance(project); @@ -54,7 +54,7 @@ public class DGMMemberContributor extends NonCodeMembersContributor { private static boolean processCategories(PsiType qualifierType, PsiScopeProcessor processor, - ResolveState state, + @NotNull ResolveState state, Project project, GlobalSearchScope resolveScope, GroovyPsiManager groovyPsiManager, List instanceCategories, diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/GdkMethodHolder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/GdkMethodHolder.java index 574dc69cd4f6..a1f024d2dbeb 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/GdkMethodHolder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/GdkMethodHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -39,8 +39,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; * @author Max Medvedev */ public class GdkMethodHolder { - private static Key> CACHED_NON_STATIC = Key.create("Cached instance gdk method holder"); - private static Key> CACHED_STATIC = Key.create("Cached static gdk method holder"); + private static final Key> CACHED_NON_STATIC = Key.create("Cached instance gdk method holder"); + private static final Key> CACHED_STATIC = Key.create("Cached static gdk method holder"); private final ConcurrentFactoryMap> myOriginalMethodsByNameAndType; @@ -90,7 +90,7 @@ public class GdkMethodHolder { return TypesUtil.boxPrimitiveType(TypeConversionUtil.erasure(parameterType), myPsiManager, myScope); } - public boolean processMethods(PsiScopeProcessor processor, ResolveState state, PsiType qualifierType, Project project) { + public boolean processMethods(PsiScopeProcessor processor, @NotNull ResolveState state, PsiType qualifierType, Project project) { if (qualifierType == null) return true; NameHint nameHint = processor.getHint(NameHint.KEY); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java index b852cd2159c1..fdb4b7f08768 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java @@ -309,7 +309,7 @@ public class GroovyDslFileIndex extends ScalarIndexExtension { final DelegatingScopeProcessor nameChecker = new DelegatingScopeProcessor(processor) { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) { return processor.execute(element, state); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java index d6a3214072f7..1b3d8d4faec3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -48,7 +48,7 @@ public class GroovyImportHelper { } } for (String pkg : getImplicitlyImportedPackages(file)) { - if (qname.equals(pkg + "." + expectedName) || pkg.length() == 0 && qname.equals(expectedName)) { + if (qname.equals(pkg + "." + expectedName) || pkg.isEmpty() && qname.equals(expectedName)) { return true; } } @@ -91,7 +91,7 @@ public class GroovyImportHelper { final DelegatingScopeProcessor packageSkipper = new DelegatingScopeProcessor(processor) { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiPackage) return true; return super.execute(element, state); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java index 443492f5cb26..d3b9cec9481d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyConstructorUsagesSearcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -391,7 +391,7 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase processor, final PsiMethod constructor) { if (constructor instanceof GrMethod) { @@ -404,10 +404,12 @@ public class GroovyConstructorUsagesSearcher extends QueryExecutorBase myResolveTargetKinds; @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod || element instanceof PsiField) { String propertyName; PsiType type; @@ -225,7 +225,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { } @@ -257,7 +257,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP } @Override - public String getName(ResolveState state) { + public String getName(@NotNull ResolveState state) { return myNameHint; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GdslClosureCompleter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GdslClosureCompleter.java index a7f6e342cd60..47ebb661c960 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GdslClosureCompleter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GdslClosureCompleter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -76,7 +76,7 @@ public class GdslClosureCompleter extends ClosureCompleter { private static void processExecutors(PsiType qtype, GrReferenceExpression ref, final ArrayList descriptors) { GroovyDslFileIndex.processExecutors(qtype, ref, new BaseScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof ClosureDescriptor) { descriptors.add((ClosureDescriptor)element); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java index ce5d9c1c2d45..3aec0b1036ff 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java @@ -115,7 +115,7 @@ public class GroovyCompletionContributor extends CompletionContributor { final PsiManager manager = file.getManager(); PsiScopeProcessor processor = new PsiScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { return !manager.areElementsEquivalent(element, member); } @@ -125,7 +125,7 @@ public class GroovyCompletionContributor extends CompletionContributor { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { } }; @@ -447,6 +447,7 @@ public class GroovyCompletionContributor extends CompletionContributor { final List zeroPriority = newArrayList(); reference.processVariants(matcher, parameters, new Consumer() { + @Override public void consume(LookupElement lookupElement) { Object object = lookupElement.getObject(); if (object instanceof GroovyResolveResult) { @@ -666,6 +667,7 @@ public class GroovyCompletionContributor extends CompletionContributor { private static final String DUMMY_IDENTIFIER_DECAPITALIZED = StringUtil.decapitalize(CompletionUtil.DUMMY_IDENTIFIER); + @Override public void beforeCompletion(@NotNull final CompletionInitializationContext context) { final String identifier = getIdentifier(context); if (identifier != null) { @@ -729,7 +731,7 @@ public class GroovyCompletionContributor extends CompletionContributor { if (element == null) return DUMMY_IDENTIFIER_DECAPITALIZED; final String text = element.getText(); - if (text.length() == 0) return DUMMY_IDENTIFIER_DECAPITALIZED; + if (text.isEmpty()) return DUMMY_IDENTIFIER_DECAPITALIZED; return Character.isUpperCase(text.charAt(0)) ? CompletionInitializationContext.DUMMY_IDENTIFIER : DUMMY_IDENTIFIER_DECAPITALIZED; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java index 9728c5436861..7b1fd24e6fe5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -100,6 +100,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { super(viewProvider, GroovyFileType.GROOVY_LANGUAGE); } + @Override @NotNull public String getPackageName() { GrPackageDefinition packageDef = getPackageDefinition(); @@ -112,6 +113,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return ""; } + @Override public GrPackageDefinition getPackageDefinition() { final StubElement stub = getStub(); if (stub != null) { @@ -138,6 +140,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return mySyntheticArgsParameter; } + @Override public boolean processDeclarations(@NotNull final PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @@ -205,7 +208,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { } protected boolean processImports(PsiScopeProcessor processor, - ResolveState state, + @NotNull ResolveState state, PsiElement lastParent, PsiElement place, GrImportStatement[] importStatements, @@ -262,7 +265,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { PsiPackage aPackage = facade.findPackage(packageName); if (aPackage != null && !aPackage.processDeclarations(new DelegatingScopeProcessor(processor) { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiPackage) return true; return super.execute(element, state); } @@ -294,6 +297,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return !(run instanceof GrTopLevelDefinition || run instanceof GrImportStatement || lastParent instanceof GrMember); } + @Override public GrImportStatement[] getImportStatements() { final StubElement stub = getStub(); if (stub != null) { @@ -303,12 +307,14 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return calcTreeElement().getChildrenAsPsiElements(GroovyElementTypes.IMPORT_STATEMENT, GrImportStatement.ARRAY_FACTORY); } + @Override @Nullable public Icon getIcon(int flags) { final Icon baseIcon = isScript() ? GroovyScriptTypeDetector.getScriptType(this).getScriptIcon() : JetgroovyIcons.Groovy.Groovy_16x16; return ElementBase.createLayeredIcon(this, baseIcon, ElementBase.transformFlags(this, flags)); } + @Override public GrImportStatement addImportForClass(PsiClass aClass) { try { // Calculating position @@ -367,6 +373,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return anchor; } + @Override public GrImportStatement addImport(GrImportStatement statement) throws IncorrectOperationException { PsiElement anchor = getAnchorToInsertImportAfter(statement); final PsiElement result = addAfter(statement, anchor); @@ -377,6 +384,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return gImport; } + @Override public boolean isScript() { final StubElement stub = getStub(); if (stub instanceof GrFileStub) { @@ -418,6 +426,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { super.subtreeChanged(); } + @Override public GroovyScriptClass getScriptClass() { if (isScript()) { if (myScriptClass == null) { @@ -435,11 +444,12 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { } } + @Override public void setPackageName(String packageName) { final ASTNode fileNode = getNode(); assert fileNode != null; final GrPackageDefinition currentPackage = getPackageDefinition(); - if (packageName == null || packageName.length() == 0) { + if (packageName == null || packageName.isEmpty()) { if (currentPackage != null) { final ASTNode currNode = currentPackage.getNode(); fileNode.removeChild(currNode); @@ -511,6 +521,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { }); } + @Override public void clearCaches() { super.clearCaches(); synchronized (lock) { @@ -519,6 +530,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { } } + @Override public PsiElement getContext() { if (myContext != null) { return myContext; @@ -526,6 +538,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return super.getContext(); } + @Override @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"}) protected GroovyFileImpl clone() { GroovyFileImpl clone = (GroovyFileImpl)super.clone(); @@ -543,6 +556,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { myContext = context; } + @Override @NotNull public PsiClass[] getClasses() { final PsiClass[] declaredDefs = super.getClasses(); @@ -554,6 +568,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { return result; } + @Override public PsiElement getOriginalElement() { final PsiClass scriptClass = getScriptClass(); if (scriptClass != null) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java index 03e8016f08bf..69fef9debdaf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java @@ -65,6 +65,7 @@ public class GrImportStatementImpl extends GrStubElementBase 0) { + if (!allCandidates.isEmpty()) { return allCandidates.toArray(new GroovyResolveResult[allCandidates.size()]); } else if (!hasApplicableMethods) { @@ -960,7 +960,7 @@ public class ResolveUtil { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (myBorderPassed) { return false; } @@ -972,7 +972,7 @@ public class ResolveUtil { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { if (event == DECLARATION_SCOPE_PASSED) { myBorderPassed = true; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java index fdcff3ee9264..caecf90e539b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -41,11 +41,11 @@ public class GrCollectionTypeMembersProvider extends NonCodeMembersContributor { } @Override - public void processDynamicElements(final @NotNull PsiType qualifierType, + public void processDynamicElements(@NotNull final PsiType qualifierType, PsiClass aClass, final PsiScopeProcessor processor, final PsiElement place, - final ResolveState state) { + @NotNull final ResolveState state) { final PsiType collectionType = PsiUtil.extractIterableTypeParameter(qualifierType, true); if (collectionType == null) return; @@ -63,7 +63,7 @@ public class GrCollectionTypeMembersProvider extends NonCodeMembersContributor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiField) { final PsiType type = ((PsiField)element).getType(); final String typeText = diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/MixinMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/MixinMemberContributor.java index d8d24a28944e..09f900b8f535 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/MixinMemberContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/MixinMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -146,7 +146,7 @@ public class MixinMemberContributor extends NonCodeMembersContributor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod && GdkMethodUtil.isCategoryMethod((PsiMethod)element, myType, myPlace, state.get(PsiSubstitutor.KEY))) { PsiMethod method = (PsiMethod)element; String originInfo = getOriginInfoForCategory(method); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java index 7b3923a8a906..5a008d6b8fac 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -34,7 +34,8 @@ public class CompletionProcessor extends ResolverProcessor { super(name, resolveTargets, place, PsiType.EMPTY_ARRAY); } - public boolean execute(@NotNull PsiElement element, ResolveState substitutor) { + @Override + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) { if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) { return true; } @@ -54,6 +55,7 @@ public class CompletionProcessor extends ResolverProcessor { return new CompletionProcessor(place, RESOLVE_KINDS_CLASS_PACKAGE, null); } + @Override @NotNull public GroovyResolveResult[] getCandidates() { if (!super.hasCandidates()) return GroovyResolveResult.EMPTY_ARRAY; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/JavaResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/JavaResolverProcessor.java index 43a187ff4280..01349dcbf451 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/JavaResolverProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/JavaResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -37,7 +37,7 @@ public class JavaResolverProcessor extends DelegatingScopeProcessor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (myHint != null && element instanceof PsiNamedElement) { final String expectedName = myHint.getName(state); final String elementName = ((PsiNamedElement)element).getName(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java index bddbf4c4719c..337718ff0e66 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java @@ -377,7 +377,7 @@ public class MethodResolverProcessor extends ResolverProcessor implements GrMeth } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { super.handleEvent(event, associated); if (JavaScopeProcessorEvent.CHANGE_LEVEL == event && super.hasCandidates()) { myStopExecuting = true; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java index d82405218f56..1adbd3e285f9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -36,7 +36,7 @@ public class PropertyResolverProcessor extends ResolverProcessor { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { return super.execute(element, state) || element instanceof PsiField; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java index 4ef8e4d35f30..1b624a452746 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java @@ -54,8 +54,7 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint private final EnumSet myResolveTargetKinds; private Set myProcessedClasses; protected PsiElement myPlace; - private - @NotNull final PsiType[] myTypeArguments; + @NotNull private final PsiType[] myTypeArguments; private List myCandidates; @@ -69,6 +68,7 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint myTypeArguments = typeArguments; } + @Override public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiLocalVariableImpl) { //todo a better hack return true; // the debugger creates a Java code block context and our expressions to evaluate resolve there @@ -173,6 +173,7 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint return myCandidates.toArray(new GroovyResolveResult[myCandidates.size()]); } + @Override @SuppressWarnings({"unchecked"}) public T getHint(@NotNull Key hintKey) { if ((NameHint.KEY == hintKey && myName != null) || ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) { @@ -182,17 +183,20 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint return null; } - public void handleEvent(Event event, Object associated) { + @Override + public void handleEvent(@NotNull Event event, Object associated) { } public String getName() { return myName; } + @Override public boolean shouldProcess(ResolveKind resolveKind) { return myResolveTargetKinds.contains(resolveKind); } + @Override public boolean shouldProcess(DeclarationKind kind) { switch (kind) { case CLASS: @@ -226,7 +230,8 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint return null; } - public String getName(ResolveState state) { + @Override + public String getName(@NotNull ResolveState state) { return myName; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java index e753ed9232d3..07d4d0b92f69 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -40,7 +40,7 @@ public class XmlMarkupBuilderNonCodeMemberContributor extends NonCodeMembersCont PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { String nameHint = ResolveUtil.getNameHint(processor); if (nameHint == null) return; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java index fb70da6417da..11a1570d339a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureUsageProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -89,6 +89,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.refactoring.changeSignature.GrChangeSignatureUsageProcessor"); + @Override public UsageInfo[] findUsages(ChangeInfo info) { if (info instanceof JavaChangeInfo) { return new GrChageSignatureUsageSearcher((JavaChangeInfo)info).findUsages(); @@ -96,6 +97,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc return UsageInfo.EMPTY_ARRAY; } + @Override public MultiMap findConflicts(ChangeInfo info, Ref refUsages) { if (info instanceof JavaChangeInfo) { return new GrChangeSignatureConflictSearcher((JavaChangeInfo)info).findConflicts(refUsages); @@ -105,6 +107,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc } } + @Override public boolean processPrimaryMethod(ChangeInfo changeInfo) { if (!(changeInfo instanceof GrChangeInfoImpl)) return false; @@ -117,6 +120,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc return processPrimaryMethodInner(grInfo, method, null); } + @Override public boolean shouldPreviewUsages(ChangeInfo changeInfo, UsageInfo[] usages) { if (!StringUtil.isJavaIdentifier(changeInfo.getNewName())) return true; @@ -397,6 +401,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc return null; } + @Override public boolean processUsage(ChangeInfo changeInfo, UsageInfo usageInfo, boolean beforeMethodChange, UsageInfo[] usages) { if (!(changeInfo instanceof JavaChangeInfo)) return false; @@ -532,7 +537,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc GrClosureSignatureUtil.ArgInfo argInfo = map[index]; List arguments = argInfo.args; if (argInfo.isMultiArg) { //arguments for Map and varArg - if ((i != 0 || !(arguments.size() > 0 && arguments.iterator().next() instanceof GrNamedArgument)) && + if ((i != 0 || !(!arguments.isEmpty() && arguments.iterator().next() instanceof GrNamedArgument)) && (i != parameters.length - 1 || !parameter.isVarargType())) { final PsiType type = parameter.createType(changeInfo.getMethod().getParameterList(), argumentList.getManager()); final GrExpression arg = GroovyRefactoringUtil.generateArgFromMultiArg(substitutor, arguments, type, element.getProject()); @@ -605,7 +610,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc } GrCall call = GroovyRefactoringUtil.getCallExpressionByMethodReference(element); - if (argumentList.getText().trim().length() == 0 && (call == null || !PsiImplUtil.hasClosureArguments(call))) { + if (argumentList.getText().trim().isEmpty() && (call == null || !PsiImplUtil.hasClosureArguments(call))) { argumentList = argumentList.replaceWithArgumentList(factory.createArgumentList()); } CodeStyleManager.getInstance(argumentList.getProject()).reformat(argumentList); @@ -627,6 +632,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(list.getProject()).getResolveHelper(); final PsiType type = info.getTypeWrapper().getType(changeInfo.getMethod(), list.getManager()); final VariablesProcessor processor = new VariablesProcessor(false) { + @Override protected boolean check(PsiVariable var, ResolveState state) { if (var instanceof PsiField && !resolveHelper.isAccessible((PsiField)var, list, null)) return false; if (var instanceof GrVariable && @@ -640,7 +646,8 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc return type.isAssignableFrom(varType); } - public boolean execute(@NotNull PsiElement pe, ResolveState state) { + @Override + public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) { super.execute(pe, state); return size() < 2; } @@ -696,6 +703,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc else if (context instanceof GrTryCatchStatement) { final GrCatchClause[] catchClauses = ((GrTryCatchStatement)context).getCatchClauses(); List referencedTypes = ContainerUtil.map(catchClauses, new Function() { + @Override @Nullable public PsiClassType fun(GrCatchClause grCatchClause) { final GrParameter grParameter = grCatchClause.getParameter(); @@ -738,6 +746,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc final GrCatchClause[] clauses = tryCatch.getCatchClauses(); List restricted = ContainerUtil.map(clauses, new Function() { + @Override @Nullable public String fun(GrCatchClause grCatchClause) { final GrParameter grParameter = grCatchClause.getParameter(); @@ -764,6 +773,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc final GroovyPsiElement context, final PsiClassType[] handledExceptions) { return ContainerUtil.findAll(exceptions, new Condition() { + @Override public boolean value(PsiClassType o) { if (!InheritanceUtil.isInheritor(o, CommonClassNames.JAVA_LANG_EXCEPTION)) return false; for (PsiClassType type : handledExceptions) { @@ -776,6 +786,7 @@ public class GrChangeSignatureUsageProcessor implements ChangeSignatureUsageProc private static PsiClassType[] getExceptions(ThrownExceptionInfo[] infos, final PsiElement context, final PsiManager manager) { return ContainerUtil.map(infos, new Function() { + @Override @Nullable public PsiClassType fun(ThrownExceptionInfo thrownExceptionInfo) { return (PsiClassType)thrownExceptionInfo.createType(context, manager); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java index fb783b922737..475d09bf1730 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -94,8 +94,8 @@ import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter. public class ExpressionGenerator extends Generator { private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.refactoring.convertToJava.ExpressionGenerator"); - private StringBuilder builder; - private GroovyPsiElementFactory factory; + private final StringBuilder builder; + private final GroovyPsiElementFactory factory; private final ExpressionContext context; @@ -129,6 +129,7 @@ public class ExpressionGenerator extends Generator { } + @Override public void visitExpression(GrExpression expression) { LOG.error("this method should not be invoked"); } @@ -1411,7 +1412,7 @@ public class ExpressionGenerator extends Generator { final CheckProcessElement processor = new CheckProcessElement(method); ResolveUtil.processAllDeclarationsSeparately(conjunct, processor, new BaseScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { return false; } }, ResolveState.initial(), context); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java index 8af18d6e5d2b..4776713cb6ea 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -59,27 +59,6 @@ import java.util.Arrays; import java.util.Map; import java.util.Set; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBAND; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBAND_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBOR; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBOR_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBSR_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBXOR; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mBXOR_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDIV; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mDIV_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMINUS; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMINUS_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMOD; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mMOD_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mPLUS; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mPLUS_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSL_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSR_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR_ASSIGN; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR_STAR; -import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mSTAR_STAR_ASSIGN; import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*; import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter.writeType; @@ -226,7 +205,7 @@ public class GenerationUtil { } else { addParentheses = - context != null && (context.shouldInsertCurlyBrackets() || context.myStatements.size() > 0) && parent instanceof GrControlStatement; + context != null && (context.shouldInsertCurlyBrackets() || !context.myStatements.isEmpty()) && parent instanceof GrControlStatement; } if (addParentheses) { @@ -541,7 +520,7 @@ public class GenerationUtil { final CheckProcessElement checker = new CheckProcessElement(member); ResolveUtil.processAllDeclarationsSeparately(declared, checker, new BaseScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { return false; } }, ResolveState.initial(), qualifier); @@ -561,7 +540,7 @@ public class GenerationUtil { } @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (myManager.areElementsEquivalent(element, myMember)) { myResult = true; return false; @@ -575,7 +554,7 @@ public class GenerationUtil { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { } public boolean isFound() { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java index 96c7f89728c5..d408a7c510f1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -40,7 +40,7 @@ public class SpockMemberContributor extends NonCodeMembersContributor { PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { ClassHint classHint = processor.getHint(ClassHint.KEY); if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) { GrMethod method = PsiTreeUtil.getParentOfType(place, GrMethod.class); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java index 9a3cb3d000c4..137feaa0673e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -833,7 +833,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { ClassHint classHint = processor.getHint(ClassHint.KEY); if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return; diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nUtil.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nUtil.java index 327aad8a6dde..7868bc1b28c7 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nUtil.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/JavaI18nUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -287,7 +287,7 @@ public class JavaI18nUtil extends I18nUtil { private static void addAvailableMethodsOfType(final PsiClassType type, final PsiLiteralExpression context, final Collection result) { PsiScopesUtil.treeWalkUp(new PsiScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PsiMethod) { PsiMethod method = (PsiMethod)element; PsiType returnType = method.getReturnType(); @@ -305,7 +305,7 @@ public class JavaI18nUtil extends I18nUtil { } @Override - public void handleEvent(Event event, Object associated) { + public void handleEvent(@NotNull Event event, Object associated) { } }, context, null); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java index 21e40a3087d5..b159363cc94b 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyPomScriptMemberContributor.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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. + */ package org.jetbrains.idea.maven.plugins.groovy; import com.intellij.psi.*; @@ -36,7 +51,7 @@ public class MavenGroovyPomScriptMemberContributor extends NonCodeMembersContrib PsiClass aClass, PsiScopeProcessor processor, PsiElement place, - ResolveState state) { + @NotNull ResolveState state) { PsiElement pomElement = aClass.getContainingFile().getContext(); if (pomElement == null) return; diff --git a/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java b/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java index 659381f720ab..8aaaea3e718a 100644 --- a/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java +++ b/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -45,7 +45,7 @@ public class PyDunderAllReference extends PsiReferenceBase ranges = element.getStringValueTextRanges(); - if (ranges.size() > 0) { + if (!ranges.isEmpty()) { setRangeInElement(ranges.get(0)); } } @@ -70,7 +70,7 @@ public class PyDunderAllReference extends PsiReferenceBase> myFindExportedNameStack = new ArrayListThreadLocal(); + private final ThreadLocal> myFindExportedNameStack = new ArrayListThreadLocal(); //private volatile Boolean myAbsoluteImportEnabled; private final Map myFutureFeatures; @@ -251,6 +251,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { myModificationTracker = PsiModificationTracker.SERVICE.getInstance(getProject()); } + @Override @NotNull public FileType getFileType() { return PythonFileType.INSTANCE; @@ -260,14 +261,17 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return "PyFile:" + getName(); } + @Override public PyFunction findTopLevelFunction(String name) { return findByName(name, getTopLevelFunctions()); } + @Override public PyClass findTopLevelClass(String name) { return findByName(name, getTopLevelClasses()); } + @Override public PyTargetExpression findTopLevelAttribute(String name) { return findByName(name, getTopLevelAttributes()); } @@ -282,6 +286,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return null; } + @Override public LanguageLevel getLanguageLevel() { if (myOriginalFile != null) { return ((PyFileImpl) myOriginalFile).getLanguageLevel(); @@ -297,10 +302,12 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return PyUtil.getLanguageLevelForVirtualFile(getProject(), virtualFile); } + @Override public Icon getIcon(int flags) { return PythonFileType.INSTANCE.getIcon(); } + @Override public void accept(@NotNull PsiElementVisitor visitor) { if (isAcceptedFor(visitor.getClass())) { if (visitor instanceof PyElementVisitor) { @@ -334,7 +341,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { final List remainingDunderAll = dunderAll == null ? null : new ArrayList(dunderAll); PsiScopeProcessor wrapper = new PsiScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (!processor.execute(element, state)) return false; if (remainingDunderAll != null && element instanceof PyElement) { remainingDunderAll.remove(((PyElement) element).getName()); @@ -348,7 +355,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { } @Override - public void handleEvent(Event event, @Nullable Object associated) { + public void handleEvent(@NotNull Event event, @Nullable Object associated) { processor.handleEvent(event, associated); } }; @@ -394,6 +401,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return true; } + @Override public List getStatements() { List stmts = new ArrayList(); for (PsiElement child : getChildren()) { @@ -405,14 +413,17 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return stmts; } + @Override public List getTopLevelClasses() { return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.CLASS_DECLARATION, PyClass.class); } + @Override public List getTopLevelFunctions() { return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.FUNCTION_DECLARATION, PyFunction.class); } + @Override public List getTopLevelAttributes() { return PyPsiUtils.collectStubChildren(this, this.getStub(), PyElementTypes.TARGET_EXPRESSION, PyTargetExpression.class); } @@ -502,6 +513,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return null; } + @Override @Nullable public PsiElement getElementNamed(String name) { PsiElement exportedName = findExportedName(name); @@ -518,6 +530,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return exportedName; } + @Override @NotNull public Iterable iterateNames() { final List result = new ArrayList(); @@ -535,10 +548,12 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return result; } + @Override public boolean mustResolveOutside() { return false; } + @Override @NotNull public List getImportTargets() { List ret = new ArrayList(); @@ -549,6 +564,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return ret; } + @Override @NotNull public List getFromImports() { return PyPsiUtils.collectStubChildren(this, getStub(), PyElementTypes.FROM_IMPORT_STATEMENT, PyFromImportStatement.class); @@ -581,7 +597,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { private boolean myFoundDunderAll = false; // hashlib builds __all__ by concatenating multiple lists of strings, and we want to understand this - private Map> myDunderLike = new HashMap>(); + private final Map> myDunderLike = new HashMap>(); @Override public void visitPyTargetExpression(PyTargetExpression node) { @@ -654,6 +670,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return null; } + @Override public boolean hasImportFromFuture(FutureFeature feature) { final StubElement stub = getStub(); if (stub instanceof PyFileStub) { @@ -718,6 +735,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { } + @Override public PyType getType(@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key) { if (myType == null) myType = new PyModuleType(this); return myType; @@ -741,6 +759,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression { return DocStringUtil.findDocStringExpression(this); } + @Override public void subtreeChanged() { super.subtreeChanged(); ControlFlowCache.clear(this); diff --git a/python/src/com/jetbrains/python/psi/resolve/AssignmentCollectProcessor.java b/python/src/com/jetbrains/python/psi/resolve/AssignmentCollectProcessor.java index 1f02473d5632..dc5052a92035 100644 --- a/python/src/com/jetbrains/python/psi/resolve/AssignmentCollectProcessor.java +++ b/python/src/com/jetbrains/python/psi/resolve/AssignmentCollectProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -49,7 +49,8 @@ public class AssignmentCollectProcessor implements PsiScopeProcessor { mySeenNames = new HashSet(); } - public boolean execute(@NotNull final PsiElement element, final ResolveState state) { + @Override + public boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) { if (element instanceof PyAssignmentStatement) { final PyAssignmentStatement assignment = (PyAssignmentStatement)element; for (PyExpression ex : assignment.getTargets()) { @@ -81,11 +82,13 @@ public class AssignmentCollectProcessor implements PsiScopeProcessor { return myResult; } + @Override public T getHint(@NotNull final Key hintKey) { return null; } - public void handleEvent(final Event event, final Object associated) { + @Override + public void handleEvent(@NotNull final Event event, final Object associated) { // empty } diff --git a/python/src/com/jetbrains/python/psi/resolve/ResolveProcessor.java b/python/src/com/jetbrains/python/psi/resolve/ResolveProcessor.java index 6c43f7ab59f0..4f00bfa399f1 100644 --- a/python/src/com/jetbrains/python/psi/resolve/ResolveProcessor.java +++ b/python/src/com/jetbrains/python/psi/resolve/ResolveProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -70,7 +70,8 @@ public class ResolveProcessor implements PsiScopeProcessor { return PyUtil.nvl(myName) + ", " + PyUtil.nvl(myResult); } - public boolean execute(@NotNull PsiElement element, ResolveState substitutor) { + @Override + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) { if (element instanceof PyFile) { final VirtualFile file = ((PyFile)element).getVirtualFile(); if (file != null) { @@ -173,12 +174,14 @@ public class ResolveProcessor implements PsiScopeProcessor { return definer.getElementNamed(myName); } + @Override @Nullable public T getHint(@NotNull Key hintKey) { return null; } - public void handleEvent(Event event, Object associated) { + @Override + public void handleEvent(@NotNull Event event, Object associated) { } private boolean setResult(PsiElement result, @Nullable PsiElement definer) { diff --git a/python/src/com/jetbrains/python/psi/resolve/VariantsProcessor.java b/python/src/com/jetbrains/python/psi/resolve/VariantsProcessor.java index 704ed60a7bed..1e83f383b5b7 100644 --- a/python/src/com/jetbrains/python/psi/resolve/VariantsProcessor.java +++ b/python/src/com/jetbrains/python/psi/resolve/VariantsProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -60,7 +60,8 @@ public abstract class VariantsProcessor implements PsiScopeProcessor { } - public boolean execute(@NotNull PsiElement element, ResolveState substitutor) { + @Override + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) { if (myNodeFilter != null && !myNodeFilter.value(element)) return true; // skip whatever the filter rejects // TODO: refactor to look saner; much code duplication if (element instanceof PsiNamedElement) { @@ -141,12 +142,14 @@ public abstract class VariantsProcessor implements PsiScopeProcessor { return true; } + @Override @Nullable public T getHint(@NotNull Key hintKey) { return null; } - public void handleEvent(Event event, Object associated) { + @Override + public void handleEvent(@NotNull Event event, Object associated) { } public void setAllowedNames(List namesFilter) { diff --git a/python/src/com/jetbrains/python/psi/types/PyModuleType.java b/python/src/com/jetbrains/python/psi/types/PyModuleType.java index f58f8f879c3b..f2dc67c10c70 100644 --- a/python/src/com/jetbrains/python/psi/types/PyModuleType.java +++ b/python/src/com/jetbrains/python/psi/types/PyModuleType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -218,7 +218,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje final List visibleImports = new ArrayList(); PyResolveUtil.scopeCrawlUp(new PsiScopeProcessor() { @Override - public boolean execute(@NotNull PsiElement element, ResolveState state) { + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { if (element instanceof PyImportElement) { visibleImports.add((PyImportElement)element); } @@ -232,7 +232,7 @@ public class PyModuleType implements PyType { // Modules don't descend from obje } @Override - public void handleEvent(Event event, @Nullable Object associated) { + public void handleEvent(@NotNull Event event, @Nullable Object associated) { } }, owner, null, null); return visibleImports; diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNameImpl.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNameImpl.java index b1cf38bd2a0f..1959e08095a8 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNameImpl.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/compact/psi/impl/RncNameImpl.java @@ -65,12 +65,14 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference super(node); } + @Override @Nullable public String getPrefix() { final String[] parts = EscapeUtil.unescapeText(getNode()).split(":", 2); return parts.length == 2 ? parts[0] : null; } + @Override @NotNull public String getLocalPart() { final String[] parts = EscapeUtil.unescapeText(getNode()).split(":", 2); @@ -87,14 +89,17 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference return getPrefix() == null ? null : this; } + @Override public PsiElement getElement() { return this; } + @Override public TextRange getRangeInElement() { return TextRange.from(0, getText().indexOf(':')); } + @Override @Nullable public PsiElement resolve() { final MyResolver resolver = new MyResolver(getPrefix(), getKind()); @@ -111,11 +116,13 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference } } + @Override @NotNull public String getCanonicalText() { return getRangeInElement().substring(getText()); } + @Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { final ASTNode node = getNode(); final ASTNode child = RenameUtil.createPrefixedNode(getManager(), newElementName, getLocalPart()); @@ -123,24 +130,29 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference return child.getPsi(); } + @Override public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException { throw new UnsupportedOperationException(); } + @Override public boolean isReferenceTo(PsiElement element) { return element instanceof RncElement && Comparing.equal(resolve(), element); } + @Override @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } + @Override public boolean isSoft() { final String prefix = getPrefix(); return "xsd".equals(prefix) || "xml".equals(prefix); } + @Override @NotNull public String getUnresolvedMessagePattern() { return "Unresolved namespace prefix ''{0}''"; @@ -165,7 +177,8 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference myKind = kind; } - public boolean execute(@NotNull PsiElement element, ResolveState substitutor) { + @Override + public boolean execute(@NotNull PsiElement element, @NotNull ResolveState substitutor) { final ASTNode node = element.getNode(); if (node == null) return true; @@ -203,11 +216,13 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference myReference = reference; } + @Override @NotNull public String getName() { return getFamilyName() + " '" + myReference.getPrefix() + "'"; } + @Override @NotNull public String getFamilyName() { return "Create " + myReference.getKind().name().toLowerCase() + " declaration"; @@ -265,14 +280,17 @@ public class RncNameImpl extends RncElementImpl implements RncName, PsiReference final Template t = manager.createTemplate("", ""); t.addTextSegment(" \""); final Expression expression = new Expression() { + @Override public Result calculateResult(ExpressionContext context) { return new TextResult(""); } + @Override public Result calculateQuickResult(ExpressionContext context) { return calculateResult(context); } + @Override public LookupItem[] calculateLookupItems(ExpressionContext context) { return LookupItem.EMPTY_ARRAY; }