當前位置: 首頁>>代碼示例>>Java>>正文


Java TokenType.ERROR_ELEMENT屬性代碼示例

本文整理匯總了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());
  } 
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:JavaFormattingModelBuilder.java

示例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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:PsiBuilderImpl.java

示例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);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:XmlBuilderDriver.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:XmlBlock.java

示例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();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:XmlBlock.java

示例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);
            }
        }
    };
}
 
開發者ID:SeeSharpSoft,項目名稱:intellij-csv-validator,代碼行數:28,代碼來源:CsvValidationInspection.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:PsiBuilderImpl.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:PsiBuilderImpl.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:FormatterUtil.java

示例10: error

@Override
public void error(String message) {
  myType = TokenType.ERROR_ELEMENT;
  myBuilder.error(this, message);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:PsiBuilderImpl.java

示例11: errorBefore

@Override
public void errorBefore(final String message, @NotNull final Marker before) {
  myType = TokenType.ERROR_ELEMENT;
  myBuilder.errorBefore(this, message, before);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:PsiBuilderImpl.java

示例12: getTokenType

@NotNull
@Override
public IElementType getTokenType() {
  return TokenType.ERROR_ELEMENT;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:PsiBuilderImpl.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:56,代碼來源:PsiBuilderImpl.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:FormatterUtil.java


注:本文中的com.intellij.psi.TokenType.ERROR_ELEMENT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。