mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
adding refs to implements & extends lists
This commit is contained in:
+7
@@ -17,7 +17,9 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
|
||||
@@ -33,6 +35,11 @@ public class GrExtendsClauseImpl extends GrReferenceListImpl implements GrExtend
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IElementType getKeywordType() {
|
||||
return GroovyTokenTypes.kEXTENDS;
|
||||
}
|
||||
|
||||
public GrExtendsClauseImpl(final GrReferenceListStub stub) {
|
||||
super(stub, GroovyElementTypes.EXTENDS_CLAUSE);
|
||||
}
|
||||
|
||||
+7
@@ -17,7 +17,9 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
|
||||
@@ -33,6 +35,11 @@ public class GrImplementsClauseImpl extends GrReferenceListImpl implements GrImp
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IElementType getKeywordType() {
|
||||
return GroovyTokenTypes.kIMPLEMENTS;
|
||||
}
|
||||
|
||||
public GrImplementsClauseImpl(final GrReferenceListStub stub) {
|
||||
super(stub, GroovyElementTypes.IMPLEMENTS_CLAUSE);
|
||||
}
|
||||
|
||||
+14
-9
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.StubBasedPsiElement;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
@@ -88,16 +89,20 @@ public abstract class GrReferenceListImpl extends GrStubElementBase<GrReferenceL
|
||||
|
||||
@Override
|
||||
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (element instanceof GrCodeReferenceElement && findChildByClass(GrCodeReferenceElement.class) != null) {
|
||||
PsiElement lastChild = getLastChild();
|
||||
lastChild = PsiUtil.skipWhitespaces(lastChild, false);
|
||||
if (!lastChild.getNode().getElementType().equals(GroovyTokenTypes.mCOMMA)) {
|
||||
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
|
||||
if (element instanceof GrCodeReferenceElement) {
|
||||
if (findChildByType(getKeywordType()) == null) {
|
||||
getNode().addLeaf(getKeywordType(), getKeywordType().toString(), null);
|
||||
}
|
||||
else if (findChildByClass(GrCodeReferenceElement.class) != null) {
|
||||
PsiElement lastChild = getLastChild();
|
||||
lastChild = PsiUtil.skipWhitespaces(lastChild, false);
|
||||
if (!lastChild.getNode().getElementType().equals(GroovyTokenTypes.mCOMMA)) {
|
||||
getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", null);
|
||||
}
|
||||
}
|
||||
return super.add(element);
|
||||
}
|
||||
else {
|
||||
return super.add(element);
|
||||
}
|
||||
return super.add(element);
|
||||
}
|
||||
|
||||
protected abstract IElementType getKeywordType();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user