mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OC-4427
This commit is contained in:
@@ -32,6 +32,6 @@ public class ForeignLeafType extends TokenWrapper implements ILeafElementType {
|
||||
@Override
|
||||
@NotNull
|
||||
public ASTNode createLeafNode(CharSequence leafText) {
|
||||
return new ForeignLeafPsiElement(getDelegate(), getValue());
|
||||
return new ForeignLeafPsiElement(this, getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1367,15 +1367,13 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder, AS
|
||||
return ourAnyLanguageWhitespaceTokens.contains(n2.getTokenType()) ||
|
||||
n2 instanceof Token && ((Token)n2).myBuilder.myWhitespaces.contains(n2.getTokenType());
|
||||
}
|
||||
IElementType n1t;
|
||||
if (n1 instanceof ForeignLeafPsiElement)
|
||||
n1t = ((ForeignLeafPsiElement)n1).getForeignType();
|
||||
else
|
||||
n1t = n1.getElementType();
|
||||
|
||||
return dereferenceToken(n1.getElementType()) == dereferenceToken(n2.getTokenType());
|
||||
}
|
||||
|
||||
public static IElementType dereferenceToken(IElementType probablyWrapper) {
|
||||
if (probablyWrapper instanceof TokenWrapper) {
|
||||
return dereferenceToken(((TokenWrapper)probablyWrapper).getDelegate());
|
||||
}
|
||||
return probablyWrapper;
|
||||
return Comparing.equal(n1t, n2.getTokenType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
-2
@@ -19,13 +19,25 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.ForeignLeafType;
|
||||
import com.intellij.lang.TokenWrapper;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ForeignLeafPsiElement extends LeafPsiElement {
|
||||
public ForeignLeafPsiElement(IElementType type, CharSequence text) {
|
||||
super(type, text);
|
||||
private ForeignLeafType myForeignType;
|
||||
|
||||
public ForeignLeafPsiElement(ForeignLeafType type, CharSequence text) {
|
||||
super(dereferenceElementType(type.getDelegate()), text);
|
||||
myForeignType = type;
|
||||
}
|
||||
|
||||
private static IElementType dereferenceElementType(IElementType type) {
|
||||
while ( type instanceof TokenWrapper)
|
||||
type = (( TokenWrapper ) type ).getDelegate();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,6 +75,10 @@ public class ForeignLeafPsiElement extends LeafPsiElement {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ForeignLeafType getForeignType() {
|
||||
return myForeignType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForeignLeaf(" + getElementType() + ": " + getText() + ")";
|
||||
|
||||
Reference in New Issue
Block a user