mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] require GrCodeReference for GrClassReferenceType
GrReferenceExpression has another resolution mechanism, which expects transformed classes, while GrCodeReferences are resolved assuming classes are not transformed yet. This breaks the following recursion cycle in Grails DomainDescriptor: transform class -> create type from reference expression in DomainDescriptor -> create light field with this type in GormAstTransformationContributor -> create accessor method for the field in DefaultTransformationSupport -> resolve accessor type in TransformationContext.addMethod -> resolve underlying reference expression -> transform class GitOrigin-RevId: e0e00cd39e3da140ac9d53fc783a125ba2f11393
This commit is contained in:
committed by
intellij-monorepo-bot
parent
003edb5fca
commit
b2e5cfc647
+6
-5
@@ -7,8 +7,8 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
|
||||
|
||||
/**
|
||||
@@ -16,13 +16,13 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
|
||||
*/
|
||||
public final class GrClassReferenceType extends PsiClassType {
|
||||
|
||||
private final @NotNull GrReferenceElement myReferenceElement;
|
||||
private final @NotNull GrCodeReferenceElement myReferenceElement;
|
||||
|
||||
public GrClassReferenceType(@NotNull GrReferenceElement referenceElement) {
|
||||
public GrClassReferenceType(@NotNull GrCodeReferenceElement referenceElement) {
|
||||
this(referenceElement, LanguageLevel.JDK_1_5);
|
||||
}
|
||||
|
||||
public GrClassReferenceType(@NotNull GrReferenceElement referenceElement, @NotNull LanguageLevel languageLevel) {
|
||||
private GrClassReferenceType(@NotNull GrCodeReferenceElement referenceElement, @NotNull LanguageLevel languageLevel) {
|
||||
super(languageLevel);
|
||||
myReferenceElement = referenceElement;
|
||||
}
|
||||
@@ -154,7 +154,8 @@ public final class GrClassReferenceType extends PsiClassType {
|
||||
return new GrClassReferenceType(myReferenceElement, languageLevel);
|
||||
}
|
||||
|
||||
public GrReferenceElement getReference() {
|
||||
@NotNull
|
||||
public GrCodeReferenceElement getReference() {
|
||||
return myReferenceElement;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -25,7 +25,10 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocTag;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GrLambdaExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
@@ -175,10 +178,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
|
||||
@Override
|
||||
public GrCodeReferenceElement createReferenceElementByType(PsiClassType type) {
|
||||
if (type instanceof GrClassReferenceType) {
|
||||
GrReferenceElement reference = ((GrClassReferenceType)type).getReference();
|
||||
if (reference instanceof GrCodeReferenceElement) {
|
||||
return (GrCodeReferenceElement)reference;
|
||||
}
|
||||
return ((GrClassReferenceType)type).getReference();
|
||||
}
|
||||
|
||||
final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
|
||||
|
||||
+5
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.smartPointers;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -23,15 +9,15 @@ import com.intellij.psi.SmartTypePointer;
|
||||
import com.intellij.psi.impl.smartPointers.TypePointerBase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType;
|
||||
|
||||
public class GrClassReferenceTypePointer extends TypePointerBase<GrClassReferenceType> implements SmartTypePointer {
|
||||
private static final Logger LOG = Logger.getInstance(GrClassReferenceTypePointer.class);
|
||||
|
||||
private final SmartPsiElementPointer<GrReferenceElement> mySmartPsiElementPointer;
|
||||
private final SmartPsiElementPointer<GrCodeReferenceElement> mySmartPsiElementPointer;
|
||||
private final String myReferenceText;
|
||||
private final Project myProject;
|
||||
|
||||
@@ -39,7 +25,7 @@ public class GrClassReferenceTypePointer extends TypePointerBase<GrClassReferenc
|
||||
super(type);
|
||||
|
||||
myProject = project;
|
||||
final GrReferenceElement reference = type.getReference();
|
||||
final GrCodeReferenceElement reference = type.getReference();
|
||||
mySmartPsiElementPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(reference);
|
||||
myReferenceText = reference.getText();
|
||||
}
|
||||
@@ -47,7 +33,7 @@ public class GrClassReferenceTypePointer extends TypePointerBase<GrClassReferenc
|
||||
@Nullable
|
||||
@Override
|
||||
protected GrClassReferenceType calcType() {
|
||||
final GrReferenceElement reference = mySmartPsiElementPointer.getElement();
|
||||
final GrCodeReferenceElement reference = mySmartPsiElementPointer.getElement();
|
||||
if (reference != null) {
|
||||
return new GrClassReferenceType(reference);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user