diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java index 9ef5e23d3a36..bd95029b62de 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions; @@ -40,13 +26,14 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.statements.GrOperatorExpressio import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrBindingVariable; import org.jetbrains.plugins.groovy.lang.resolve.DependentResolver; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.lang.resolve.processors.DynamicMembersHint; import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.concurrent.ConcurrentMap; +import static org.jetbrains.plugins.groovy.lang.resolve.ResolveUtilKt.shouldProcessDynamicProperties; + /** * @author ilyas */ @@ -116,8 +103,7 @@ public class GrAssignmentExpressionImpl extends GrOperatorExpressionImpl impleme @NotNull PsiElement place) { final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY); if (!ResolveUtil.shouldProcessProperties(classHint)) return false; - final DynamicMembersHint dynamicMembersHint = processor.getHint(DynamicMembersHint.KEY); - if (dynamicMembersHint != null && !dynamicMembersHint.shouldProcessProperties()) return false; + if (!shouldProcessDynamicProperties(processor)) return false; PsiElement parent = owner.getParent(); if (!(parent instanceof GroovyFileImpl)) return false; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt index 0251ad25e51d..c36dd0f77996 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.lang.resolve import com.intellij.openapi.util.Key @@ -40,6 +26,10 @@ fun shouldProcessDynamicMethods(processor: PsiScopeProcessor): Boolean { return processor.getHint(DynamicMembersHint.KEY)?.shouldProcessMethods() ?: false } +fun PsiScopeProcessor.shouldProcessDynamicProperties(): Boolean { + return getHint(DynamicMembersHint.KEY)?.shouldProcessProperties() ?: false +} + fun PsiScopeProcessor.shoudProcessMethods(): Boolean { return ResolveUtil.shouldProcessMethods(getHint(ElementClassHint.KEY)) } 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 d6a4fe4fa010..5d58a41dcbf1 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,21 +1,8 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.lang.resolve.processors; +import com.intellij.openapi.util.Key; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiField; import com.intellij.psi.PsiType; @@ -31,7 +18,7 @@ import static org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint.RES /** * @author ven */ -public class PropertyResolverProcessor extends ResolverProcessorImpl { +public class PropertyResolverProcessor extends ResolverProcessorImpl implements DynamicMembersHint { public PropertyResolverProcessor(String name, PsiElement place) { super(name, RESOLVE_KINDS_PROPERTY, place, PsiType.EMPTY_ARRAY); @@ -71,4 +58,18 @@ public class PropertyResolverProcessor extends ResolverProcessorImpl { last.isStaticsOK() && last.getCurrentFileResolveContext() == null; } + + @Override + public T getHint(@NotNull Key hintKey) { + if (hintKey == DynamicMembersHint.KEY) { + //noinspection unchecked + return (T)this; + } + return super.getHint(hintKey); + } + + @Override + public boolean shouldProcessProperties() { + return true; + } }