mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] fix dynamic members processing
This commit is contained in:
+4
-18
@@ -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;
|
||||
|
||||
+5
-15
@@ -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))
|
||||
}
|
||||
|
||||
+17
-16
@@ -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> T getHint(@NotNull Key<T> hintKey) {
|
||||
if (hintKey == DynamicMembersHint.KEY) {
|
||||
//noinspection unchecked
|
||||
return (T)this;
|
||||
}
|
||||
return super.getHint(hintKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessProperties() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user