本文整理匯總了Java中com.intellij.psi.TokenType.ERROR_ELEMENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java TokenType.ERROR_ELEMENT屬性的具體用法?Java TokenType.ERROR_ELEMENT怎麽用?Java TokenType.ERROR_ELEMENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.intellij.psi.TokenType
的用法示例。
在下文中一共展示了TokenType.ERROR_ELEMENT屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: combineWithErrorElementIfPossible
/**
* Checks if previous non-white space leaf of the given node is error element and combines formatting range relevant for it
* with the range of the given node.
*
* @param node target node
* @return given node range if there is no error-element before it; combined range otherwise
*/
@Nullable
private static TextRange combineWithErrorElementIfPossible(@NotNull ASTNode node) {
if (node.getElementType() == TokenType.ERROR_ELEMENT) {
return node.getTextRange();
}
final ASTNode prevLeaf = FormatterUtil.getPreviousLeaf(node, TokenType.WHITE_SPACE);
if (prevLeaf == null || prevLeaf.getElementType() != TokenType.ERROR_ELEMENT) {
return node.getTextRange();
}
final TextRange range = doGetRangeAffectingIndent(prevLeaf);
if (range == null) {
return node.getTextRange();
}
else {
return new TextRange(range.getStartOffset(), node.getTextRange().getEndOffset());
}
}
示例2: hashCodesEqual
@Override
public boolean hashCodesEqual(@NotNull final ASTNode n1, @NotNull final LighterASTNode n2) {
if (n1 instanceof LeafElement && n2 instanceof Token) {
boolean isForeign1 = n1 instanceof ForeignLeafPsiElement;
boolean isForeign2 = n2.getTokenType() instanceof ForeignLeafType;
if (isForeign1 != isForeign2) return false;
if (isForeign1) {
return n1.getText().equals(((ForeignLeafType)n2.getTokenType()).getValue());
}
return ((LeafElement)n1).textMatches(((Token)n2).getText());
}
if (n1 instanceof PsiErrorElement && n2.getTokenType() == TokenType.ERROR_ELEMENT) {
final PsiErrorElement e1 = (PsiErrorElement)n1;
if (!Comparing.equal(e1.getErrorDescription(), getErrorMessage(n2))) return false;
}
return ((TreeElement)n1).hc() == ((Node)n2).hc();
}
示例3: processPrologNode
private void processPrologNode(PsiBuilder psiBuilder,
XmlBuilder builder,
FlyweightCapableTreeStructure<LighterASTNode> structure,
LighterASTNode prolog) {
final Ref<LighterASTNode[]> prologChildren = new Ref<LighterASTNode[]>(null);
final int prologChildrenCount = structure.getChildren(structure.prepareForGetChildren(prolog), prologChildren);
for (int i = 0; i < prologChildrenCount; i++) {
LighterASTNode node = prologChildren.get()[i];
IElementType type = node.getTokenType();
if (type == XmlElementType.XML_DOCTYPE) {
processDoctypeNode(builder, structure, node);
break;
}
if (type == TokenType.ERROR_ELEMENT) {
processErrorNode(psiBuilder, node, builder);
}
}
}
示例4: splitAttribute
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) {
final ArrayList<Block> result = new ArrayList<Block>(3);
ASTNode child = node.getFirstChildNode();
while (child != null) {
if (child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace()));
}
else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) {
// Fix for EA-20311:
// In case of another embedded language create a splittable XML block which can be
// merged with other language's code blocks.
createLeafBlocks(child, result);
}
else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) {
result.add(new ReadOnlyBlock(child));
}
child = child.getTreeNext();
}
return result;
}
示例5: createLeafBlocks
private void createLeafBlocks(ASTNode node, List<Block> result) {
if (node instanceof OuterLanguageElement) {
processChild(result, node, null, null, null);
return;
}
ASTNode child = node.getFirstChildNode();
if (child == null && !(node instanceof PsiWhiteSpace) && node.getElementType() != TokenType.ERROR_ELEMENT && node.getTextLength() > 0) {
result.add(new ReadOnlyBlock(node));
return;
}
while (child != null) {
createLeafBlocks(child, result);
child = child.getTreeNext();
}
}
示例6: buildVisitor
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element == null || !holder.getFile().getLanguage().isKindOf(CsvLanguage.INSTANCE)) {
return;
}
IElementType elementType = CsvIntentionHelper.getElementType(element);
PsiElement firstChild = element.getFirstChild();
PsiElement nextSibling = element.getNextSibling();
if (elementType == TokenType.ERROR_ELEMENT && CsvIntentionHelper.getElementType(firstChild) == TokenType.BAD_CHARACTER) {
if (firstChild.getText().equals("\"")) {
holder.registerProblem(element, UNESCAPED_SEQUENCE, fixUnescapedSequence);
} else {
holder.registerProblem(element, SEPARATOR_MISSING, fixSeparatorMissing);
holder.registerProblem(element, UNESCAPED_SEQUENCE, fixUnescapedSequence);
}
} else if ((elementType == CsvTypes.TEXT || elementType == CsvTypes.ESCAPED_TEXT)
&& CsvIntentionHelper.getElementType(nextSibling) == TokenType.ERROR_ELEMENT
&& nextSibling.getFirstChild() == null) {
holder.registerProblem(element, CLOSING_QUOTE_MISSING, fixClosingQuoteMissing);
}
}
};
}
示例7: createComposite
@NotNull
private static CompositeElement createComposite(@NotNull StartMarker marker) {
final IElementType type = marker.myType;
if (type == TokenType.ERROR_ELEMENT) {
String message = marker.myDoneMarker instanceof DoneWithErrorMarker ? ((DoneWithErrorMarker)marker.myDoneMarker).myMessage : null;
return Factory.createErrorElement(message);
}
if (type == null) {
throw new RuntimeException(UNBALANCED_MESSAGE);
}
return ASTFactory.composite(type);
}
示例8: getErrorMessage
@Nullable
public static String getErrorMessage(@NotNull LighterASTNode node) {
if (node instanceof ErrorItem) return ((ErrorItem)node).myMessage;
if (node instanceof StartMarker) {
final StartMarker marker = (StartMarker)node;
if (marker.myType == TokenType.ERROR_ELEMENT && marker.myDoneMarker instanceof DoneWithErrorMarker) {
return ((DoneWithErrorMarker)marker.myDoneMarker).myMessage;
}
}
return null;
}
示例9: isIncomplete
public static boolean isIncomplete(@Nullable ASTNode node) {
ASTNode lastChild = node == null ? null : node.getLastChildNode();
while (lastChild != null && lastChild.getElementType() == TokenType.WHITE_SPACE) {
lastChild = lastChild.getTreePrev();
}
if (lastChild == null) return false;
if (lastChild.getElementType() == TokenType.ERROR_ELEMENT) return true;
return isIncomplete(lastChild);
}
示例10: error
@Override
public void error(String message) {
myType = TokenType.ERROR_ELEMENT;
myBuilder.error(this, message);
}
示例11: errorBefore
@Override
public void errorBefore(final String message, @NotNull final Marker before) {
myType = TokenType.ERROR_ELEMENT;
myBuilder.errorBefore(this, message, before);
}
示例12: getTokenType
@NotNull
@Override
public IElementType getTokenType() {
return TokenType.ERROR_ELEMENT;
}
示例13: deepEqual
@NotNull
@Override
public ThreeState deepEqual(@NotNull final ASTNode oldNode, @NotNull final LighterASTNode newNode) {
ProgressIndicatorProvider.checkCanceled();
boolean oldIsErrorElement = oldNode instanceof PsiErrorElement;
boolean newIsErrorElement = newNode.getTokenType() == TokenType.ERROR_ELEMENT;
if (oldIsErrorElement != newIsErrorElement) return ThreeState.NO;
if (oldIsErrorElement) {
final PsiErrorElement e1 = (PsiErrorElement)oldNode;
return Comparing.equal(e1.getErrorDescription(), getErrorMessage(newNode)) ? ThreeState.UNSURE : ThreeState.NO;
}
if (custom != null) {
ThreeState customResult = custom.fun(oldNode, newNode, myTreeStructure);
if (customResult != ThreeState.UNSURE) {
return customResult;
}
}
if (newNode instanceof Token) {
final IElementType type = newNode.getTokenType();
final Token token = (Token)newNode;
if (oldNode instanceof ForeignLeafPsiElement) {
return type instanceof ForeignLeafType && ((ForeignLeafType)type).getValue().equals(oldNode.getText())
? ThreeState.YES
: ThreeState.NO;
}
if (oldNode instanceof LeafElement) {
if (type instanceof ForeignLeafType) return ThreeState.NO;
return ((LeafElement)oldNode).textMatches(token.getText())
? ThreeState.YES
: ThreeState.NO;
}
if (type instanceof ILightLazyParseableElementType) {
return ((TreeElement)oldNode).textMatches(token.getText())
? ThreeState.YES
: TreeUtil.isCollapsedChameleon(oldNode)
? ThreeState.NO // do not dive into collapsed nodes
: ThreeState.UNSURE;
}
if (oldNode.getElementType() instanceof ILazyParseableElementType && type instanceof ILazyParseableElementType ||
oldNode.getElementType() instanceof CustomParsingType && type instanceof CustomParsingType) {
return ((TreeElement)oldNode).textMatches(token.getText())
? ThreeState.YES
: ThreeState.NO;
}
}
return ThreeState.UNSURE;
}
示例14: isWhitespaceOrEmpty
public static boolean isWhitespaceOrEmpty(@Nullable ASTNode node) {
if (node == null) return false;
IElementType type = node.getElementType();
return type == TokenType.WHITE_SPACE || (type != TokenType.ERROR_ELEMENT && node.getTextLength() == 0);
}