diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java index 28a3560a7774..57b455b445b2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/MethodEvaluator.java @@ -32,7 +32,6 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.VirtualMachineProxyImpl; import com.intellij.openapi.diagnostic.Logger; import com.intellij.rt.debugger.DefaultMethodInvoker; -import com.intellij.util.containers.ContainerUtil; import com.sun.jdi.*; import java.util.ArrayList; @@ -127,18 +126,7 @@ public class MethodEvaluator implements Evaluator { final String methodName = DebuggerUtilsEx.methodName(referenceType.name(), myMethodName, signature); if (isInvokableType(object)) { if (isInvokableType(referenceType)) { - Method jdiMethod; - if (signature != null) { - if (referenceType instanceof ClassType) { - jdiMethod = ((ClassType)referenceType).concreteMethodByName(myMethodName, signature); - } - else { - jdiMethod = ContainerUtil.getFirstItem(referenceType.methodsByName(myMethodName, signature)); - } - } - else { - jdiMethod = ContainerUtil.getFirstItem(referenceType.methodsByName(myMethodName)); - } + Method jdiMethod = DebuggerUtils.findMethod(referenceType, myMethodName, signature); if (jdiMethod != null && jdiMethod.isStatic()) { if (referenceType instanceof ClassType) { return debugProcess.invokeMethod(context, (ClassType)referenceType, jdiMethod, args); diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java index 92e2e0498a59..7819a3dd076d 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/DebuggerUtils.java @@ -42,6 +42,7 @@ import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.StringBuilderSpinAllocator; +import com.intellij.util.containers.ContainerUtil; import com.sun.jdi.*; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -149,7 +150,7 @@ public abstract class DebuggerUtils { } @Nullable - public static Method findMethod(@NotNull ReferenceType refType, @NonNls String methodName, @NonNls String methodSignature) { + public static Method findMethod(@NotNull ReferenceType refType, @NonNls String methodName, @Nullable @NonNls String methodSignature) { if (refType instanceof ArrayType) { // for array types methodByName() in JDI always returns empty list final Method method = findMethod(refType.virtualMachine().classesByName(CommonClassNames.JAVA_LANG_OBJECT).get(0), methodName, methodSignature); @@ -164,20 +165,11 @@ public abstract class DebuggerUtils { method = ((ClassType)refType).concreteMethodByName(methodName, methodSignature); } if (method == null) { - final List methods = refType.methodsByName(methodName, methodSignature); - if (methods.size() > 0) { - method = methods.get(0); - } + method = ContainerUtil.getFirstItem(refType.methodsByName(methodName, methodSignature)); } } else { - List methods = null; - if (refType instanceof ClassType) { - methods = refType.methodsByName(methodName); - } - if (methods != null && methods.size() > 0) { - method = methods.get(0); - } + method = ContainerUtil.getFirstItem(refType.methodsByName(methodName)); } return method; } diff --git a/platform/core-api/src/com/intellij/psi/ElementManipulator.java b/platform/core-api/src/com/intellij/psi/ElementManipulator.java index 15127f8c24ae..ab9767695fa4 100644 --- a/platform/core-api/src/com/intellij/psi/ElementManipulator.java +++ b/platform/core-api/src/com/intellij/psi/ElementManipulator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,20 +21,16 @@ import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; /** - * Created by IntelliJ IDEA. - * User: ik - * Date: 03.04.2003 - * Time: 11:22:05 - * - * @see com.intellij.psi.ElementManipulators + * @see AbstractElementManipulator + * @see ElementManipulators */ public interface ElementManipulator { /** - * Changes the element's text to a new value + * Changes the element's text to the given new text. * - * @param element element to be changed - * @param range range within the element + * @param element element to be changed + * @param range range within the element * @param newContent new element text * @return changed element * @throws IncorrectOperationException if something goes wrong diff --git a/platform/core-api/src/org/jetbrains/concurrency/Promise.java b/platform/core-api/src/org/jetbrains/concurrency/Promise.java index d40e46b2e01a..6382231487a1 100644 --- a/platform/core-api/src/org/jetbrains/concurrency/Promise.java +++ b/platform/core-api/src/org/jetbrains/concurrency/Promise.java @@ -158,8 +158,16 @@ public abstract class Promise { @SuppressWarnings("ExceptionClassNameDoesntEndWithException") public static class MessageError extends RuntimeException { + private final boolean log; + public MessageError(@NotNull String error) { + this(error, false); + } + + public MessageError(@NotNull String error, boolean log) { super(error); + + this.log = log; } @NotNull @@ -174,7 +182,7 @@ public abstract class Promise { */ public static void logError(@NotNull Logger logger, @NotNull Throwable e) { if (!(e instanceof ProcessCanceledException) && - (!(e instanceof MessageError) || ApplicationManager.getApplication().isUnitTestMode())) { + (!(e instanceof MessageError) || ((MessageError)e).log || ApplicationManager.getApplication().isUnitTestMode())) { logger.error(e); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerComponent.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerComponent.java index d0eabaddaa31..2771da8448b1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerComponent.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateCheckerComponent.java @@ -118,11 +118,11 @@ public class UpdateCheckerComponent implements ApplicationComponent { app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() { @Override public void appFrameCreated(String[] commandLineArgs, @NotNull Ref willOpenProject) { - String currentBuild = ApplicationInfo.getInstance().getBuild().asString(); + BuildNumber currentBuild = ApplicationInfo.getInstance().getBuild(); + BuildNumber lastBuildChecked = BuildNumber.fromString(mySettings.getLasBuildChecked()); long timeToNextCheck = mySettings.getLastTimeChecked() + CHECK_INTERVAL - System.currentTimeMillis(); - if (BuildNumber.fromString(mySettings.getLasBuildChecked()).compareTo(BuildNumber.fromString(currentBuild)) < 0 || - timeToNextCheck <= 0) { + if (lastBuildChecked == null || currentBuild.compareTo(lastBuildChecked) > 0 || timeToNextCheck <= 0) { myCheckRunnable.run(); } else { diff --git a/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt b/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt index 01b55722a8fd..93303db912a8 100644 --- a/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt +++ b/platform/platform-impl/src/org/jetbrains/concurrency/promise.kt @@ -34,9 +34,7 @@ abstract class ObsolescentConsumer(private val obsolescent: Obsolescent) : Ob } -inline fun Promise.then(crossinline handler: (T) -> SUB_RESULT) = then(object : Function { - override fun `fun`(param: T) = handler(param) -}) +inline fun Promise.then(crossinline handler: (T) -> SUB_RESULT) = then(Function { param -> handler(param) }) inline fun Promise.then(obsolescent: Obsolescent, crossinline handler: (T) -> SUB_RESULT) = then(object : ObsolescentFunction { override fun `fun`(param: T) = handler(param) @@ -50,9 +48,7 @@ inline fun Promise.done(node: Obsolescent, crossinline handler: (T) -> Un }) -inline fun Promise.thenAsync(crossinline handler: (T) -> Promise) = then(object : AsyncFunction { - override fun `fun`(param: T) = handler(param) -}) +inline fun Promise.thenAsync(crossinline handler: (T) -> Promise) = then(AsyncFunction { param -> handler(param) }) inline fun Promise.thenAsync(node: Obsolescent, crossinline handler: (T) -> Promise) = then(object : ValueNodeAsyncFunction(node) { override fun `fun`(param: T) = handler(param) @@ -110,4 +106,6 @@ fun collectResults(promises: List>): Promise> { promise.done { results.add(it) } } return Promise.all(promises, results) -} \ No newline at end of file +} + +fun createError(error: String, log: Boolean = false): RuntimeException = Promise.MessageError(error, log) \ No newline at end of file diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 4b0fb52662c2..752af8b5383e 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -106,13 +106,19 @@ action.EditorMoveDownAndScroll.text=Move Down and Scroll action.EditorMoveUpAndScrollWithSelection.text=Move Up and Scroll with Selection action.EditorMoveDownAndScrollWithSelection.text=Move Down and Scroll with Selection action.EditorAddOrRemoveCaret.text=Add or Remove Caret +action.EditorAddOrRemoveCaret.description=Set multiple cursors in the current file to edit multiple lines of code simultaneously. action.EditorCreateRectangularSelection.text=Create Rectangular Selection action.EditorAddRectangularSelectionOnMouseDrag.text=Add Rectangular Selection on Mouse Drag action.EditorCloneCaretBelow.text=Clone Caret Below +action.EditorCloneCaretBelow.description=Insert a secondary cursor in the line below to edit multiple lines of code simultaneously. action.EditorCloneCaretAbove.text=Clone Caret Above +action.EditorCloneCaretAbove.description=Insert a secondary cursor in the line above to edit multiple lines of code simultaneously. action.SelectNextOccurrence.text=Add Selection for Next Occurrence +action.SelectNextOccurrence.description=Set multiple cursors by adding the next occurrence of the current word to the selection. action.SelectAllOccurrences.text=Select All Occurrences +action.SelectAllOccurrences.description=Set multiple cursors by adding all occurrences of the current word to the selection. action.UnselectPreviousOccurrence.text=Unselect Occurrence +action.UnselectPreviousOccurrence.description=Remove the current occurrence of the word from the selection. action.EditorToggleStickySelection.text=Toggle Sticky Selection action.EditorSwapSelectionBoundaries.text=Swap selection boundaries action.EditorLineStart.text=Move Caret to Line Start diff --git a/platform/script-debugger/protocol/protocol-model-generator/src/DomainGenerator.kt b/platform/script-debugger/protocol/protocol-model-generator/src/DomainGenerator.kt index 4c9536b2f5f2..7e11f74f28da 100644 --- a/platform/script-debugger/protocol/protocol-model-generator/src/DomainGenerator.kt +++ b/platform/script-debugger/protocol/protocol-model-generator/src/DomainGenerator.kt @@ -269,7 +269,7 @@ internal class DomainGenerator(val generator: Generator, val domain: ProtocolMet if (description != null) { out.doc(description) } - out.append("@JsonType").newLine() +// out.append("@JsonType").newLine() } } diff --git a/platform/script-debugger/protocol/protocol-model-generator/src/InputClassScope.kt b/platform/script-debugger/protocol/protocol-model-generator/src/InputClassScope.kt index 640244800f0d..01a32889fe03 100644 --- a/platform/script-debugger/protocol/protocol-model-generator/src/InputClassScope.kt +++ b/platform/script-debugger/protocol/protocol-model-generator/src/InputClassScope.kt @@ -30,7 +30,6 @@ internal class InputClassScope(generator: DomainGenerator, namePath: NamePath) : addMember { out -> out.newLine().newLine().doc(description) if (properties == null) { - out.append("@JsonType(allowsOtherProperties=true)").newLine() out.append("interface ").append(objectName).append(" : JsonObjectBased").openBlock() } else { diff --git a/platform/script-debugger/protocol/protocol-reader-runtime/src/annotations.kt b/platform/script-debugger/protocol/protocol-reader-runtime/src/annotations.kt index a76dd5e40f72..33667d711a6d 100644 --- a/platform/script-debugger/protocol/protocol-reader-runtime/src/annotations.kt +++ b/platform/script-debugger/protocol/protocol-reader-runtime/src/annotations.kt @@ -22,7 +22,7 @@ annotation class JsonField( val primitiveValue: String = "") @Target(AnnotationTarget.CLASS) -annotation class JsonType(val allowsOtherProperties: Boolean = false) +annotation class JsonType() @Target(AnnotationTarget.FUNCTION) annotation class JsonSubtypeCasting(val reinterpret: Boolean = false) diff --git a/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt b/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt index f8f8479667f5..69a78606aa37 100644 --- a/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt +++ b/platform/script-debugger/protocol/protocol-reader-runtime/src/org/jetbrains/jsonProtocol/OutMessage.kt @@ -71,7 +71,11 @@ open class OutMessage() { writer.endArray() } - fun writeIntArray(name: String, value: IntArray) { + fun writeIntArray(name: String, value: IntArray? = null) { + if (value == null) { + return + } + beginArguments() writer.name(name) writer.beginArray() diff --git a/platform/script-debugger/protocol/protocol-reader/src/FieldProcessor.kt b/platform/script-debugger/protocol/protocol-reader/src/FieldProcessor.kt index 1b9d937715b8..9bd7ee14cb4d 100644 --- a/platform/script-debugger/protocol/protocol-reader/src/FieldProcessor.kt +++ b/platform/script-debugger/protocol/protocol-reader/src/FieldProcessor.kt @@ -79,7 +79,7 @@ internal class FieldProcessor(private val reader: InterfaceReader, typeClass: Cl methodHandler = createMethodHandler(member, method, skippedNames.contains(method.name)) ?: continue } else { - methodHandler = processManualSubtypeMethod(method, jsonSubtypeCaseAnnotation) + methodHandler = processManualSubtypeMethod(member, method, jsonSubtypeCaseAnnotation) lazyRead = true } methodHandlerMap.put(method, methodHandler) @@ -109,7 +109,7 @@ internal class FieldProcessor(private val reader: InterfaceReader, typeClass: Cl } } - val fieldTypeParser = reader.getFieldTypeParser(genericReturnType, false, method) + val fieldTypeParser = reader.getFieldTypeParser(member, genericReturnType, false, method) val isProperty = member is KProperty<*> val isAsImpl = isProperty && !isNotNull if (fieldTypeParser != VOID_PARSER) { @@ -154,18 +154,17 @@ internal class FieldProcessor(private val reader: InterfaceReader, typeClass: Cl } } - private fun processManualSubtypeMethod(m: Method, jsonSubtypeCaseAnn: JsonSubtypeCasting): MethodHandler { - val fieldTypeParser = reader.getFieldTypeParser(m.genericReturnType, !jsonSubtypeCaseAnn.reinterpret, null) + private fun processManualSubtypeMethod(member: KCallable<*>, m: Method, jsonSubtypeCaseAnn: JsonSubtypeCasting): MethodHandler { + val fieldTypeParser = reader.getFieldTypeParser(member, m.genericReturnType, !jsonSubtypeCaseAnn.reinterpret, null) val fieldInfo = allocateVolatileField(fieldTypeParser, true) val handler = LazyCachedMethodHandler(fieldTypeParser, fieldInfo) val parserAsObjectValueParser = fieldTypeParser.asJsonTypeParser() if (parserAsObjectValueParser != null && parserAsObjectValueParser.isSubtyping()) { - val subtypeCaster = object : SubtypeCaster(parserAsObjectValueParser.type) { + reader.subtypeCasters.add(object : SubtypeCaster(parserAsObjectValueParser.type) { override fun writeJava(out: TextOutput) { out.append(m.name).append("()") } - } - reader.subtypeCasters.add(subtypeCaster) + }) } return handler } @@ -186,3 +185,13 @@ internal class FieldProcessor(private val reader: InterfaceReader, typeClass: Cl } internal inline fun KCallable<*>.annotation(): T? = annotations.firstOrNull() { it is T } as? T ?: (this as? KFunction<*>)?.javaMethod?.getAnnotation(T::class.java) + +/** + * An internal facility for navigating from object of base type to object of subtype. Used only + * when user wants to parse JSON object as subtype. + */ +internal abstract class SubtypeCaster(private val subtypeRef: TypeRef<*>) { + abstract fun writeJava(out: TextOutput) + + fun getSubtypeHandler() = subtypeRef.type!! +} \ No newline at end of file diff --git a/platform/script-debugger/protocol/protocol-reader/src/InterfaceReader.kt b/platform/script-debugger/protocol/protocol-reader/src/InterfaceReader.kt index f51eede3eac8..1469fd7c28b1 100644 --- a/platform/script-debugger/protocol/protocol-reader/src/InterfaceReader.kt +++ b/platform/script-debugger/protocol/protocol-reader/src/InterfaceReader.kt @@ -11,6 +11,7 @@ import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.lang.reflect.WildcardType import java.util.* +import kotlin.reflect.KCallable internal fun InterfaceReader(protocolInterfaces: List>): InterfaceReader { val map = LinkedHashMap, TypeWriter<*>?>(protocolInterfaces.size) @@ -132,7 +133,7 @@ internal class InterfaceReader(val typeToTypeHandler: LinkedHashMap, Ty typeToTypeHandler.put(typeClass, typeWriter) } - fun getFieldTypeParser(type: Type, isSubtyping: Boolean, method: Method?): ValueReader { + fun getFieldTypeParser(member: KCallable<*>?, type: Type, isSubtyping: Boolean, method: Method?): ValueReader { if (type is Class<*>) { @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") return when { @@ -144,7 +145,7 @@ internal class InterfaceReader(val typeToTypeHandler: LinkedHashMap, Ty type == Void.TYPE -> VOID_PARSER type == String::class.java -> { if (method != null) { - val jsonField = method.getAnnotation(JsonField::class.java) + val jsonField = member?.annotation() if (jsonField != null && jsonField.allowAnyPrimitiveValue) { return RAW_STRING_PARSER } @@ -157,7 +158,7 @@ internal class InterfaceReader(val typeToTypeHandler: LinkedHashMap, Ty type == Any::class.java -> RAW_STRING_OR_MAP_PARSER type == JsonReaderEx::class.java -> JSON_PARSER type == StringIntPair::class.java -> STRING_INT_PAIR_PARSER - type.isArray -> ArrayReader(getFieldTypeParser(type.componentType, false, null), false) + type.isArray -> ArrayReader(getFieldTypeParser(null, type.componentType, false, null), false) type.isEnum -> EnumReader(type as Class>) else -> { val ref = getTypeRef(type) ?: throw UnsupportedOperationException("Method return type $type (simple class) not supported") @@ -175,7 +176,7 @@ internal class InterfaceReader(val typeToTypeHandler: LinkedHashMap, Ty argumentType = wildcard.upperBounds[0] } } - val componentParser = getFieldTypeParser(argumentType, false, method) + val componentParser = getFieldTypeParser(null, argumentType, false, method) return if (isList) ArrayReader(componentParser, true) else MapReader(componentParser) } else { diff --git a/platform/script-debugger/protocol/protocol-reader/src/SubtypeCaster.kt b/platform/script-debugger/protocol/protocol-reader/src/SubtypeCaster.kt deleted file mode 100644 index 428ea24cfb48..000000000000 --- a/platform/script-debugger/protocol/protocol-reader/src/SubtypeCaster.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.protocolReader - -/** - * An internal facility for navigating from object of base type to object of subtype. Used only - * when user wants to parse JSON object as subtype. - */ -internal abstract class SubtypeCaster(private val subtypeRef: TypeRef<*>) { - abstract fun writeJava(out: TextOutput) - - fun getSubtypeHandler() = subtypeRef.type!! -} \ No newline at end of file diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java index 9493390fd410..074933c0c45b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java @@ -186,9 +186,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme public AbstractVcs findVcsByName(String name) { if (name == null) return null; AbstractVcs result = myProject.isDisposed() ? null : AllVcses.getInstance(myProject).getByName(name); - if (result == null) { - ProgressManager.checkCanceled(); - } + ProgressManager.checkCanceled(); return result; } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java index 53e05009bcfc..e73b2de7de3b 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.dgm; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Couple; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.CachedValueProvider; @@ -27,6 +28,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import java.util.List; import java.util.concurrent.ConcurrentMap; @@ -42,6 +44,8 @@ public class DGMMemberContributor extends NonCodeMembersContributor { @NotNull PsiScopeProcessor processor, @NotNull PsiElement place, @NotNull ResolveState state) { + if (!ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) return; + final Project project = place.getProject(); ConcurrentMap> map = CachedValuesManager.getManager(project).getCachedValue( diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/geb/GebPageMemberContributor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/geb/GebPageMemberContributor.java index 3753c0bbd994..140b195b8f86 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/geb/GebPageMemberContributor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/geb/GebPageMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.geb; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; @@ -24,7 +25,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethod import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.ClassUtil; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.Map; @@ -44,8 +44,7 @@ public class GebPageMemberContributor extends NonCodeMembersContributor { @NotNull PsiScopeProcessor processor, @NotNull PsiElement place, @NotNull ResolveState state) { - ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) return; + if (!ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return; PsiElement grCall = place.getParent(); if (grCall instanceof GrMethodCall) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java index f4e40c3292f0..2a7e988627f9 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/GroovyConstructorNamedArgumentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -169,7 +169,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP private abstract static class MyPsiScopeProcessor implements PsiScopeProcessor, NameHint, ClassHint, ElementClassHint { private String myNameHint; - private EnumSet myResolveTargetKinds; + private EnumSet myResolveTargetKinds; @Override public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) { @@ -178,7 +178,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP PsiType type; if (element instanceof PsiMethod) { - if (!myResolveTargetKinds.contains(ResolveKind.METHOD)) return true; + if (!myResolveTargetKinds.contains(DeclarationKind.METHOD)) return true; PsiMethod method = (PsiMethod)element; if (!GroovyPropertyUtils.isSimplePropertySetter(method)) return true; @@ -189,7 +189,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP type = method.getParameterList().getParameters()[0].getType(); } else { - if (!myResolveTargetKinds.contains(ResolveKind.PROPERTY)) return true; + if (!myResolveTargetKinds.contains(DeclarationKind.FIELD)) return true; type = ((PsiField)element).getType(); propertyName = ((PsiField)element).getName(); @@ -214,7 +214,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP @Override public T getHint(@NotNull Key hintKey) { - if ((NameHint.KEY == hintKey && myNameHint != null) || ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) { + if (NameHint.KEY == hintKey && myNameHint != null || ElementClassHint.KEY == hintKey) { //noinspection unchecked return (T) this; } @@ -227,31 +227,9 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP } - @Override - public boolean shouldProcess(ResolveKind resolveKind) { - return myResolveTargetKinds.contains(resolveKind); - } - @Override public boolean shouldProcess(DeclarationKind kind) { - switch (kind) { - case CLASS: - return shouldProcess(ResolveKind.CLASS); - - case ENUM_CONST: - case VARIABLE: - case FIELD: - return shouldProcess(ResolveKind.PROPERTY); - - case METHOD: - return shouldProcess(ResolveKind.METHOD); - - case PACKAGE: - return shouldProcess(ResolveKind.PACKAGE); - - default: - return false; - } + return myResolveTargetKinds.contains(kind); } @Override @@ -263,7 +241,7 @@ public class GroovyConstructorNamedArgumentProvider extends GroovyNamedArgumentP myNameHint = nameHint; } - public void setResolveTargetKinds(EnumSet resolveTargetKinds) { + public void setResolveTargetKinds(EnumSet resolveTargetKinds) { myResolveTargetKinds = resolveTargetKinds; } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java index 9c0c0a920050..eceb3b9d46d7 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.NameHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.stubs.StubElement; @@ -53,7 +54,6 @@ import org.jetbrains.plugins.groovy.lang.psi.stubs.GrPackageDefinitionStub; import org.jetbrains.plugins.groovy.lang.resolve.MethodTypeInferencer; import org.jetbrains.plugins.groovy.lang.resolve.PackageSkippingProcessor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.concurrent.ConcurrentMap; @@ -127,7 +127,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - ClassHint classHint = processor.getHint(ClassHint.KEY); + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if (myContext != null) { if (ResolveUtil.shouldProcessProperties(classHint)) { @@ -225,9 +225,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { final String name = nameHint.getName(state); if (name == null) return true; - final ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) return true; - + if (!ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return true; final ConcurrentMap bindings = getBindings(); @@ -257,7 +255,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile { @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - if (ResolveUtil.shouldProcessClasses(processor.getHint(ClassHint.KEY))) { + if (ResolveUtil.shouldProcessClasses(processor.getHint(ElementClassHint.KEY))) { PsiPackage aPackage = JavaPsiFacade.getInstance(getProject()).findPackage(getPackageName()); if (aPackage != null) { return aPackage.processDeclarations(new PackageSkippingProcessor(processor), state, lastParent, place); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyImportHelper.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyImportHelper.java index 931c0ee6af51..88af18659ea4 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyImportHelper.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyImportHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -26,7 +27,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatem import org.jetbrains.plugins.groovy.lang.resolve.DefaultImportContributor; import org.jetbrains.plugins.groovy.lang.resolve.PackageSkippingProcessor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.LinkedHashSet; @@ -88,7 +88,7 @@ public class GroovyImportHelper { @Nullable PsiElement lastParent, @NotNull PsiElement place, @NotNull GroovyFile file) { - if (!ResolveUtil.shouldProcessClasses(processor.getHint(ClassHint.KEY))) return true; + if (!ResolveUtil.shouldProcessClasses(processor.getHint(ElementClassHint.KEY))) return true; JavaPsiFacade facade = JavaPsiFacade.getInstance(file.getProject()); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrCatchClauseImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrCatchClauseImpl.java index d1ca28ed9c8b..eed6cfd551ac 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrCatchClauseImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrCatchClauseImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; @@ -30,7 +31,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList; import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; /** * @author ilyas @@ -62,7 +62,7 @@ public class GrCatchClauseImpl extends GroovyPsiElementImpl implements GrCatchCl @Override public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) { - if (!ResolveUtil.shouldProcessProperties(processor.getHint(ClassHint.KEY))) return true; + if (!ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return true; GrParameter parameter = getParameter(); return parameter == null || ResolveUtil.processElement(processor, parameter, state); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrForStatementImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrForStatementImpl.java index 986deee14c27..432e7e15240f 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrForStatementImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrForStatementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; @@ -35,7 +36,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClaus import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl; import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; /** * @autor: ilyas @@ -71,7 +71,7 @@ public class GrForStatementImpl extends GroovyPsiElementImpl implements GrForSta @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - if (!ResolveUtil.shouldProcessProperties(processor.getHint(ClassHint.KEY))) return true; + if (!ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return true; GrForClause forClause = getClause(); final GrVariable varScope = PsiTreeUtil.getParentOfType(place, GrVariable.class); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java index 5637b5769ca0..0b0828a0524e 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.stubs.EmptyStub; import com.intellij.util.IncorrectOperationException; @@ -47,7 +48,6 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.ArrayList; import java.util.List; @@ -197,7 +197,7 @@ public class GrVariableDeclarationImpl extends GrStubElementBase impl @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - if (!ResolveUtil.shouldProcessProperties(processor.getHint(ClassHint.KEY))) return true; + if (!ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return true; if (lastParent != null && !(getParent() instanceof GrTypeDefinitionBody) && lastParent == getTupleInitializer()) { return true; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java index 07eba1828b58..93341fc24a99 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.blocks; import com.intellij.lang.ASTNode; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.CachedValueProvider; @@ -41,10 +42,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper; -import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager; -import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil; +import org.jetbrains.plugins.groovy.lang.psi.impl.*; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.params.GrParameterListImpl; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.ClosureSyntheticParameter; @@ -53,7 +51,6 @@ import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.resolve.MethodTypeInferencer; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; -import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyNamesUtil; /** * @author ilyas @@ -98,7 +95,7 @@ public class GrClosableBlockImpl extends GrBlockImpl implements GrClosableBlock if (!super.processDeclarations(processor, state, lastParent, place)) return false; if (!processParameters(processor, state, place)) return false; - if (ResolveUtil.shouldProcessProperties(processor.getHint(ClassHint.KEY)) && !ResolveUtil.processElement(processor, getOwner(), state)) return false; + if (ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY)) && !ResolveUtil.processElement(processor, getOwner(), state)) return false; if (!processClosureClassMembers(processor, state, lastParent, place)) return false; return true; @@ -171,7 +168,7 @@ public class GrClosableBlockImpl extends GrBlockImpl implements GrClosableBlock private boolean processParameters(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place) { - if (!ResolveUtil.shouldProcessProperties(processor.getHint(ClassHint.KEY))) return true; + if (!ResolveUtil.shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return true; if (hasParametersSection()) { for (GrParameter parameter : getParameters()) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java index b8a99b2f8ac1..cea6b499d9ce 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java @@ -22,6 +22,7 @@ import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.ResolveCache; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PropertyUtil; @@ -163,7 +164,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl kinds = getParent() instanceof GrReferenceExpression + EnumSet kinds = getParent() instanceof GrReferenceExpression ? ClassHint.RESOLVE_KINDS_CLASS_PACKAGE : ClassHint.RESOLVE_KINDS_CLASS; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java index 29f1888816cb..95f38834a228 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumTypeDefinitionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.impl.light.LightMethodBuilder; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.NameHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.util.CachedValueProvider; @@ -40,7 +41,6 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUt import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; /** * @author Dmitry.Krasilschikov @@ -119,7 +119,7 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - if (ResolveUtil.shouldProcessMethods(processor.getHint(ClassHint.KEY))) { + if (ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) { final NameHint nameHint = processor.getHint(NameHint.KEY); final String name = nameHint == null ? null : nameHint.getName(state); for (PsiMethod method : getDefEnumMethods()) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java index c9c2685ba450..8913f5167383 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.psi.impl.ElementPresentationUtil; import com.intellij.psi.impl.PsiClassImplUtil; import com.intellij.psi.impl.PsiSuperMethodImplUtil; import com.intellij.psi.presentation.java.JavaPresentationUtil; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.SearchScope; import com.intellij.psi.stubs.IStubElementType; @@ -71,7 +72,6 @@ import org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import org.jetbrains.plugins.groovy.lang.resolve.MethodTypeInferencer; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import javax.swing.*; import java.util.Collections; @@ -171,7 +171,7 @@ public abstract class GrMethodBaseImpl extends GrStubElementBase i @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - ClassHint classHint = processor.getHint(ClassHint.KEY); + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if (ResolveUtil.shouldProcessClasses(classHint)) { for (final GrTypeParameter typeParameter : getTypeParameters()) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java index f0a10e588ab0..b11cb6e30ef8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.scope.DelegatingScopeProcessor; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.NameHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.stubs.IStubElementType; @@ -46,6 +47,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import org.jetbrains.plugins.groovy.lang.resolve.processors.GrDelegatingScopeProcessorWithHints; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_METHOD; + /** * @author ilyas */ @@ -160,7 +163,7 @@ public class GrImportStatementImpl extends GrStubElementBase kinds = ClassHint.RESOLVE_KINDS_CLASS; + EnumSet kinds = ClassHint.RESOLVE_KINDS_CLASS; ResolverProcessor processor = new ClassResolverProcessor(refName, ref, kinds); GrCodeReferenceElement qualifier = ref.getQualifier(); if (qualifier != null) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GdkMethodUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GdkMethodUtil.java index a24d855919f1..4fcc1c11609b 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GdkMethodUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GdkMethodUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.openapi.util.RecursionManager; import com.intellij.openapi.util.Trinity; import com.intellij.psi.*; import com.intellij.psi.scope.DelegatingScopeProcessor; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.*; @@ -90,9 +91,8 @@ public class GdkMethodUtil { } public static boolean categoryIteration(GrClosableBlock place, final PsiScopeProcessor processor, ResolveState state) { - final ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return true; - + if (!ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) return true; + final GrMethodCall call = checkMethodCall(place, USE); if (call == null) return true; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java index 2805108b6496..e347ce2fb1f4 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java @@ -25,6 +25,7 @@ import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.impl.PsiClassImplUtil; import com.intellij.psi.infos.CandidateInfo; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.NameHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.util.*; @@ -59,7 +60,6 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrScriptField; import org.jetbrains.plugins.groovy.lang.resolve.CollectClassMembersUtil; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import org.jetbrains.plugins.groovy.lang.resolve.ast.AstTransformContributor; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.*; @@ -254,7 +254,7 @@ public class GrClassImplUtil { NameHint nameHint = processor.getHint(NameHint.KEY); String name = nameHint == null ? null : nameHint.getName(state); - ClassHint classHint = processor.getHint(ClassHint.KEY); + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); final PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(place.getProject()); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DeclarationCacheKey.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DeclarationCacheKey.java index 1ef4979defa9..abd7116c4ab9 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DeclarationCacheKey.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/DeclarationCacheKey.java @@ -19,6 +19,8 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiElement; import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.ElementClassHint; +import com.intellij.psi.scope.ElementClassHint.DeclarationKind; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; @@ -29,7 +31,6 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import org.jetbrains.plugins.groovy.lang.resolve.processors.GrScopeProcessorWithHints; import java.util.EnumSet; @@ -50,20 +51,20 @@ class DeclarationCacheKey { } }; @Nullable private final String name; - @NotNull private final EnumSet kinds; + @NotNull private final EnumSet kinds; private final boolean nonCode; @NotNull private final PsiElement place; - DeclarationCacheKey(@Nullable String name, ClassHint hint, boolean nonCode, @NotNull PsiElement place) { + DeclarationCacheKey(@Nullable String name, ElementClassHint hint, boolean nonCode, @NotNull PsiElement place) { this.name = name; this.kinds = getResolveKinds(hint); this.nonCode = nonCode; this.place = place; } - private static EnumSet getResolveKinds(ClassHint hint) { - EnumSet set = EnumSet.noneOf(ClassHint.ResolveKind.class); - for (ClassHint.ResolveKind kind : ClassHint.ResolveKind.values()) { + private static EnumSet getResolveKinds(ElementClassHint hint) { + EnumSet set = EnumSet.noneOf(DeclarationKind.class); + for (DeclarationKind kind : DeclarationKind.values()) { if (hint.shouldProcess(kind)) { set.add(kind); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GdkMethodDslProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GdkMethodDslProvider.java index 265a3f696a19..c21208166433 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GdkMethodDslProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GdkMethodDslProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.resolve; import com.intellij.openapi.util.VolatileNotNullLazyValue; import com.intellij.psi.PsiClass; import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; @@ -61,6 +62,7 @@ public class GdkMethodDslProvider implements GdslMembersProvider { @Override public boolean processMembers(GroovyClassDescriptor descriptor, PsiScopeProcessor processor, ResolveState state) { + if (!ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) return true; return methodsMap.getValue().processMethods(processor, state, descriptor.getPsiType(), descriptor.getProject()); } }); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/PackageSkippingProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/PackageSkippingProcessor.java index 599d1f4e2778..ea401b8de710 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/PackageSkippingProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/PackageSkippingProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ package org.jetbrains.plugins.groovy.lang.resolve; import com.intellij.psi.scope.PsiScopeProcessor; import org.jetbrains.plugins.groovy.lang.resolve.processors.GrDelegatingScopeProcessorWithHints; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_CLASS; + /** * Created by Max Medvedev on 27/03/14 */ diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java index 68f7f8440945..c71d499d10bf 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java @@ -22,6 +22,8 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; +import com.intellij.psi.scope.ElementClassHint.DeclarationKind; import com.intellij.psi.scope.JavaScopeProcessorEvent; import com.intellij.psi.scope.NameHint; import com.intellij.psi.scope.PsiScopeProcessor; @@ -73,6 +75,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.processors.*; import java.util.*; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_CONTEXT; + /** * @author ven */ @@ -111,7 +115,7 @@ public class ResolveUtil { boolean processNonCodeMethods, @NotNull final ResolveState state) { try { - ClassHint hint = processor.getHint(ClassHint.KEY); + ElementClassHint hint = processor.getHint(ElementClassHint.KEY); if (hint != null) { return new DeclarationCacheKey(getNameHint(processor), hint, processNonCodeMethods, originalPlace).processCachedDeclarations(place, processor); } @@ -239,7 +243,7 @@ public class ResolveUtil { @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) { - if (!shouldProcessProperties(processor.getHint(ClassHint.KEY))) return true; + if (!shouldProcessProperties(processor.getHint(ElementClassHint.KEY))) return true; PsiElement run = lastParent == null ? element.getLastChild() : lastParent.getPrevSibling(); while (run != null) { @@ -940,27 +944,28 @@ public class ResolveUtil { return expectedParams; } - public static boolean shouldProcessClasses(ClassHint classHint) { - return classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.CLASS); + public static boolean shouldProcessClasses(ElementClassHint classHint) { + return classHint == null || classHint.shouldProcess(DeclarationKind.CLASS); } - public static boolean shouldProcessMethods(ClassHint classHint) { - return classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.METHOD); + public static boolean shouldProcessMethods(ElementClassHint classHint) { + return classHint == null || classHint.shouldProcess(DeclarationKind.METHOD); } - public static boolean shouldProcessProperties(ClassHint classHint) { - return classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY); + public static boolean shouldProcessProperties(ElementClassHint classHint) { + return classHint == null || classHint.shouldProcess(DeclarationKind.VARIABLE) + || classHint.shouldProcess(DeclarationKind.FIELD) || classHint.shouldProcess(DeclarationKind.ENUM_CONST); } - public static boolean shouldProcessPackages(ClassHint classHint) { - return classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.PACKAGE); + public static boolean shouldProcessPackages(ElementClassHint classHint) { + return classHint == null || classHint.shouldProcess(DeclarationKind.PACKAGE); } public static boolean processStaticImports(@NotNull PsiScopeProcessor resolver, @NotNull PsiFile file, @NotNull ResolveState state, @NotNull PsiElement place) { - if (!shouldProcessMethods(resolver.getHint(ClassHint.KEY))) return true; + if (!shouldProcessMethods(resolver.getHint(ElementClassHint.KEY))) return true; return file.processDeclarations(new GrDelegatingScopeProcessorWithHints(resolver, null, ClassHint.RESOLVE_KINDS_METHOD) { @Override diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java index a862a56c9995..e21a8ba6c388 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/noncode/GrCollectionTypeMembersProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import org.jetbrains.plugins.groovy.lang.resolve.processors.GrDelegatingScopeProcessorWithHints; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_PROPERTY; + /** * @author Maxim.Medvedev */ diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java index 2bc7e4a022ae..8b20f70ca383 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatem import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_CONTEXT; + /** * @author Maxim.Medvedev */ diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassHint.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassHint.java index fa970dd3ebf0..55eb9429b63a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassHint.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassHint.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,27 +18,20 @@ package org.jetbrains.plugins.groovy.lang.resolve.processors; import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; +import com.intellij.psi.scope.ElementClassHint.DeclarationKind; import java.util.EnumSet; +import static com.intellij.psi.scope.ElementClassHint.DeclarationKind.*; + /** * @author ven */ public interface ClassHint { - Key KEY = Key.create("ClassHint"); Key RESOLVE_CONTEXT = Key.create("RESOLVE_CONTEXT"); - EnumSet RESOLVE_KINDS_CLASS_PACKAGE = EnumSet.of(ResolveKind.CLASS, ResolveKind.PACKAGE); - EnumSet RESOLVE_KINDS_CLASS = EnumSet.of(ResolveKind.CLASS); - EnumSet RESOLVE_KINDS_METHOD = EnumSet.of(ResolveKind.METHOD); - EnumSet RESOLVE_KINDS_METHOD_PROPERTY = EnumSet.of(ResolveKind.METHOD, ResolveKind.PROPERTY); - EnumSet RESOLVE_KINDS_PROPERTY = EnumSet.of(ResolveKind.PROPERTY); - - enum ResolveKind { - CLASS, - PACKAGE, - METHOD, - PROPERTY - } - - boolean shouldProcess(ResolveKind resolveKind); + EnumSet RESOLVE_KINDS_CLASS_PACKAGE = EnumSet.of(CLASS, PACKAGE); + EnumSet RESOLVE_KINDS_CLASS = EnumSet.of(CLASS); + EnumSet RESOLVE_KINDS_METHOD = EnumSet.of(METHOD); + EnumSet RESOLVE_KINDS_PROPERTY = EnumSet.of(VARIABLE, FIELD, ENUM_CONST); + EnumSet RESOLVE_KINDS_METHOD_PROPERTY = EnumSet.of(METHOD, VARIABLE, FIELD, ENUM_CONST); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassResolverProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassResolverProcessor.java index 8cc60df162a8..c931af1d2b3c 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassResolverProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ClassResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,13 @@ import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement; import java.util.EnumSet; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_CLASS; + /** * @author ven */ public class ClassResolverProcessor extends ResolverProcessor { - public ClassResolverProcessor(String refName, GrReferenceElement ref, EnumSet kinds) { + public ClassResolverProcessor(String refName, GrReferenceElement ref, EnumSet kinds) { super(refName, kinds, ref, ref.getTypeArguments()); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java index 45b1099187f0..25e671880274 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/CompletionProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,14 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import java.util.EnumSet; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_CLASS_PACKAGE; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_METHOD_PROPERTY; + /** * @author ven */ public class CompletionProcessor extends ResolverProcessor { - private CompletionProcessor(PsiElement place, final EnumSet resolveTargets, final String name) { + private CompletionProcessor(PsiElement place, final EnumSet resolveTargets, final String name) { super(name, resolveTargets, place, PsiType.EMPTY_ARRAY); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrDelegatingScopeProcessorWithHints.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrDelegatingScopeProcessorWithHints.java index a6a7da845c5a..1e0828623916 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrDelegatingScopeProcessorWithHints.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrDelegatingScopeProcessorWithHints.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public class GrDelegatingScopeProcessorWithHints extends GrScopeProcessorWithHin public GrDelegatingScopeProcessorWithHints(@NotNull PsiScopeProcessor delegate, @Nullable String name, - @Nullable EnumSet resolveTargets) { + @Nullable EnumSet resolveTargets) { super(name, resolveTargets); myDelegate = delegate; } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrScopeProcessorWithHints.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrScopeProcessorWithHints.java index a8cd2ec5497e..cbb93ff7caac 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrScopeProcessorWithHints.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/GrScopeProcessorWithHints.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,12 +28,12 @@ import java.util.EnumSet; /** * Created by Max Medvedev on 31/03/14 */ -public abstract class GrScopeProcessorWithHints implements PsiScopeProcessor, NameHint, ClassHint, ElementClassHint { - protected final EnumSet myResolveTargetKinds; - protected final String myName; +public abstract class GrScopeProcessorWithHints implements PsiScopeProcessor, NameHint, ElementClassHint { + protected final @Nullable EnumSet myResolveTargetKinds; + protected final @Nullable String myName; public GrScopeProcessorWithHints(@Nullable String name, - @Nullable EnumSet resolveTargets) { + @Nullable EnumSet resolveTargets) { myName = name; myResolveTargetKinds = resolveTargets; } @@ -45,51 +45,27 @@ public abstract class GrScopeProcessorWithHints implements PsiScopeProcessor, Na return (T)this; } - if ((ClassHint.KEY == hintKey || ElementClassHint.KEY == hintKey) && myResolveTargetKinds != null) { + if (ElementClassHint.KEY == hintKey && myResolveTargetKinds != null) { return (T)this; } return null; } - @Override - public boolean shouldProcess(ResolveKind resolveKind) { - assert myResolveTargetKinds != null : "don't invoke shouldProcess if resolveTargets are not declared"; - return myResolveTargetKinds.contains(resolveKind); - } - @Override public boolean shouldProcess(DeclarationKind kind) { - switch (kind) { - case CLASS: - return shouldProcess(ResolveKind.CLASS); - - case ENUM_CONST: - case VARIABLE: - case FIELD: - return shouldProcess(ResolveKind.PROPERTY); - - case METHOD: - return shouldProcess(ResolveKind.METHOD); - - case PACKAGE: - return shouldProcess(ResolveKind.PACKAGE); - } - - return false; + assert myResolveTargetKinds != null : "don't invoke shouldProcess if resolveTargets are not declared"; + return myResolveTargetKinds.contains(kind); } + @NotNull @Override public String getName(@NotNull ResolveState state) { - return myName; - } - - public String getName() { + assert myName != null : "don't invoke getName if myName is not declared"; return myName; } @Override public void handleEvent(@NotNull Event event, @Nullable Object associated) { } - } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java index 403c1d9f0a10..81352eb884ea 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,9 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_CONTEXT; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_METHOD_PROPERTY; + /** * @author ven */ diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java index 1adbd3e285f9..58f28ef47910 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrBindingVariable; import java.util.List; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_KINDS_PROPERTY; + /** * @author ven */ diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java index 2cf8528d8764..3fdfe74622aa 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,8 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import java.util.*; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_CONTEXT; + /** * @author ven */ @@ -44,7 +46,7 @@ public class ResolverProcessor extends GrScopeProcessorWithHints { private List myCandidates; protected ResolverProcessor(@Nullable String name, - @NotNull EnumSet resolveTargets, + @NotNull EnumSet resolveTargets, @NotNull PsiElement place, @NotNull PsiType[] typeArguments) { super(name, resolveTargets); @@ -58,11 +60,11 @@ public class ResolverProcessor extends GrScopeProcessorWithHints { return true; // the debugger creates a Java code block context and our expressions to evaluate resolve there } - if (myResolveTargetKinds.contains(getResolveKind(element))) { + if (myResolveTargetKinds == null || myResolveTargetKinds.contains(getDeclarationKind(element))) { //hack for resolve of java local vars and parameters //don't check field for name because they can be aliased imported if (element instanceof PsiVariable && !(element instanceof PsiField) && - getName() != null && !getName().equals(((PsiVariable)element).getName())) { + myName != null && !myName.equals(((PsiVariable)element).getName())) { return true; } PsiNamedElement namedElement = (PsiNamedElement)element; @@ -105,7 +107,7 @@ public class ResolverProcessor extends GrScopeProcessorWithHints { String text; if (element instanceof LightElement) { final PsiElement context = element.getContext(); - text = context instanceof LightElement ? context.toString() : + text = context instanceof LightElement ? context.toString() : context != null ? context.getText() : null; } else { @@ -166,21 +168,22 @@ public class ResolverProcessor extends GrScopeProcessorWithHints { return myCandidates != null; } - @Nullable - private static ResolveKind getResolveKind(PsiElement element) { - if (element instanceof PsiVariable) return ResolveKind.PROPERTY; - if (element instanceof PsiMethod) return ResolveKind.METHOD; - if (element instanceof PsiPackage) return ResolveKind.PACKAGE; - if (element instanceof PsiClass) return ResolveKind.CLASS; + private static DeclarationKind getDeclarationKind(PsiElement element) { + if (element instanceof PsiMethod) return DeclarationKind.METHOD; + if (element instanceof PsiEnumConstant) return DeclarationKind.ENUM_CONST; + if (element instanceof PsiField) return DeclarationKind.FIELD; + if (element instanceof PsiVariable) return DeclarationKind.VARIABLE; + if (element instanceof PsiClass) return DeclarationKind.CLASS; + if (element instanceof PsiPackage) return DeclarationKind.PACKAGE; return null; } @Override public String toString() { return "NameHint: '" + - getName() + + myName + "', " + - myResolveTargetKinds.toString() + + myResolveTargetKinds + ", Candidates: " + (myCandidates == null ? 0 : myCandidates.size()); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java index 112be74e1a9d..4e7ec9e4aafc 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/markup/XmlMarkupBuilderNonCodeMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package org.jetbrains.plugins.groovy.markup; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; /** * @author Sergey Evdokimov @@ -45,8 +45,7 @@ public class XmlMarkupBuilderNonCodeMemberContributor extends NonCodeMembersCont if (nameHint == null) return; - ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return; + if (!ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) return; GrLightMethodBuilder res = new GrLightMethodBuilder(aClass.getManager(), nameHint); res.addParameter("attrs", CommonClassNames.JAVA_UTIL_MAP, false); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java index 62b0c87d800e..6d6020735805 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/spock/SpockMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiType; import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; @@ -26,7 +27,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.Map; @@ -41,8 +41,8 @@ public class SpockMemberContributor extends NonCodeMembersContributor { @NotNull PsiScopeProcessor processor, @NotNull PsiElement place, @NotNull ResolveState state) { - ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) { + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); + if (ResolveUtil.shouldProcessProperties(classHint)) { GrMethod method = PsiTreeUtil.getParentOfType(place, GrMethod.class); if (method == null) return; @@ -64,7 +64,7 @@ public class SpockMemberContributor extends NonCodeMembersContributor { } } - if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) { + if (ResolveUtil.shouldProcessMethods(classHint)) { if ("get_".equals(ResolveUtil.getNameHint(processor))) { GrLightMethodBuilder m = new GrLightMethodBuilder(aClass.getManager(), "get_"); m.setReturnType(null); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java index 493ab429a19b..8fedf9f9c32b 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/swingBuilder/SwingBuilderNonCodeMemberContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableMap; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolderEx; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.containers.ContainerUtil; @@ -32,7 +33,6 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrMethodWrapper; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import java.util.Collection; import java.util.HashMap; @@ -834,8 +834,7 @@ public class SwingBuilderNonCodeMemberContributor extends NonCodeMembersContribu @NotNull PsiScopeProcessor processor, @NotNull PsiElement place, @NotNull ResolveState state) { - ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) return; + if (!ResolveUtil.shouldProcessMethods(processor.getHint(ElementClassHint.KEY))) return; MultiMap methodMap = aClass.getUserData(KEY); if (methodMap == null) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/dynamicMembers/DynamicMemberUtils.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/dynamicMembers/DynamicMemberUtils.java index 9996634f7d58..052d13afd4ef 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/dynamicMembers/DynamicMemberUtils.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/util/dynamicMembers/DynamicMemberUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolderEx; import com.intellij.psi.*; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; @@ -37,7 +38,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrRe import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder; import org.jetbrains.plugins.groovy.lang.psi.util.GrStaticChecker; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; import javax.swing.*; import java.util.*; @@ -81,19 +81,19 @@ public class DynamicMemberUtils { } public static boolean process(PsiScopeProcessor processor, boolean isInStaticContext, PsiElement place, String classSource) { - ClassHint classHint = processor.getHint(ClassHint.KEY); + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); String name = ResolveUtil.getNameHint(processor); ClassMemberHolder memberHolder = getMembers(place.getProject(), classSource); - if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.METHOD)) { + if (ResolveUtil.shouldProcessMethods(classHint)) { PsiMethod[] methods = isInStaticContext ? memberHolder.getStaticMethods(name) : memberHolder.getMethods(name); for (PsiMethod method : methods) { if (!processor.execute(method, ResolveState.initial())) return false; } } - if (classHint == null || classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) { + if (ResolveUtil.shouldProcessProperties(classHint)) { PsiField[] fields = isInStaticContext ? memberHolder.getStaticFields(name) : memberHolder.getFields(name); for (PsiField field : fields) { if (!processor.execute(field, ResolveState.initial())) return false; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/CompleteReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/CompleteReferenceExpression.java index 28a56930d044..8cc6174a58b4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/CompleteReferenceExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/CompleteReferenceExpression.java @@ -66,6 +66,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.processors.SubstitutorComputer; import java.util.*; +import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RESOLVE_CONTEXT; + /** * @author ven */ @@ -404,7 +406,7 @@ public class CompleteReferenceExpression { private boolean myIsEmpty = true; protected CompleteReferenceProcessor() { - super(null, EnumSet.allOf(ResolveKind.class), myRefExpr, PsiType.EMPTY_ARRAY); + super(null, EnumSet.allOf(DeclarationKind.class), myRefExpr, PsiType.EMPTY_ARRAY); myConsumer = new Consumer() { @Override public void consume(LookupElement element) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/shell/GroovyShellCodeFragment.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/shell/GroovyShellCodeFragment.java index fc489b146e29..7b90e8f97357 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/shell/GroovyShellCodeFragment.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/shell/GroovyShellCodeFragment.java @@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.shell; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.impl.source.PsiImmediateClassType; +import com.intellij.psi.scope.ElementClassHint; import com.intellij.psi.scope.NameHint; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.testFramework.LightVirtualFile; @@ -28,7 +29,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightVariable; -import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; import java.util.Map; @@ -89,10 +90,9 @@ public class GroovyShellCodeFragment extends GroovyCodeFragment { } private boolean processVariables(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state) { - ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && - !classHint.shouldProcess(ClassHint.ResolveKind.METHOD) && - !classHint.shouldProcess(ClassHint.ResolveKind.PROPERTY)) { + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); + if (!ResolveUtil.shouldProcessMethods(classHint) && + !ResolveUtil.shouldProcessProperties(classHint)) { return true; } @@ -119,8 +119,8 @@ public class GroovyShellCodeFragment extends GroovyCodeFragment { } private boolean processTypeDefinitions(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state) { - ClassHint classHint = processor.getHint(ClassHint.KEY); - if (classHint != null && !classHint.shouldProcess(ClassHint.ResolveKind.CLASS)) { + ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); + if (!ResolveUtil.shouldProcessClasses(classHint)) { return true; }