本文整理汇总了Java中com.intellij.psi.PsiErrorElement类的典型用法代码示例。如果您正苦于以下问题:Java PsiErrorElement类的具体用法?Java PsiErrorElement怎么用?Java PsiErrorElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiErrorElement类属于com.intellij.psi包,在下文中一共展示了PsiErrorElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasErrorElements
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
private static boolean hasErrorElements(@NotNull final PsiElement element) {
if (element instanceof PsiErrorElement) {
HighlightErrorFilter[] errorFilters = Extensions.getExtensions(HighlightErrorFilter.EP_NAME, element.getProject());
for (HighlightErrorFilter errorFilter : errorFilters) {
if (!errorFilter.shouldHighlightErrorElement((PsiErrorElement)element)) {
return false;
}
}
return true;
}
for (PsiElement child : element.getChildren()) {
if (hasErrorElements(child)) {
return true;
}
}
return false;
}
示例2: createReport
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
public String createReport() {
StringBuilder builder = new StringBuilder("\n\n\n");
builder.append("Language: ")
.append(myLang.getDisplayName())
.append(". Setting: ")
.append(mySettingsType)
.append(". Errors found: ")
.append(myErrors.size())
.append('\n');
for (PsiErrorElement error : myErrors) {
builder.append(" ")
.append(error.getErrorDescription())
.append(". Previous sibling: ")
.append(error.getPrevSibling())
.append('\n');
}
builder.append("\nCode sample:\n")
.append(myCode)
.append('\n');
return builder.toString();
}
示例3: hashCodesEqual
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@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();
}
示例4: getNodeHash
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Override
public int getNodeHash(PsiElement node) {
if (node == null) {
return 0;
}
if (node instanceof PsiWhiteSpace || node instanceof PsiErrorElement) {
return 0;
}
else if (node instanceof LeafElement) {
if (isToSkipAsLiteral(node)) {
return 0;
}
return node.getText().hashCode();
}
return node.getClass().getName().hashCode();
}
示例5: isIgnoredNode
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
public static boolean isIgnoredNode(PsiElement element) {
// ex. "var i = 0" in AS: empty JSAttributeList should be skipped
/*if (element.getText().length() == 0) {
return true;
}*/
if (element instanceof PsiWhiteSpace || element instanceof PsiErrorElement || element instanceof PsiComment) {
return true;
}
if (!(element instanceof LeafElement)) {
return false;
}
if (CharArrayUtil.containsOnlyWhiteSpaces(element.getText())) {
return true;
}
EquivalenceDescriptorProvider descriptorProvider = EquivalenceDescriptorProvider.getInstance(element);
if (descriptorProvider == null) {
return false;
}
final IElementType elementType = ((LeafElement)element).getElementType();
return descriptorProvider.getIgnoredTokens().contains(elementType);
}
示例6: select
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
TextRange stringRange = e.getTextRange();
PsiElement firstChild = e.getFirstChild().getNextSibling();
if (firstChild instanceof PsiErrorElement) {
return Collections.emptyList();
}
int startShift = 1;
if (firstChild instanceof PsiWhiteSpace)
startShift += firstChild.getTextLength();
PsiElement lastChild = e.getLastChild().getPrevSibling();
int endShift = 1;
if (lastChild instanceof PsiWhiteSpace && lastChild != firstChild)
endShift += lastChild.getTextLength();
final TextRange offsetRange = new TextRange(stringRange.getStartOffset() + startShift, stringRange.getEndOffset() - endShift);
if (offsetRange.contains(cursorOffset) && offsetRange.getLength() > 1) {
return Collections.singletonList(offsetRange);
}
return Collections.emptyList();
}
示例7: doFix
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
private static void doFix(@NotNull final PsiElement element) throws IncorrectOperationException {
final XmlToken endNameToken = (XmlToken)element;
final PsiElement tagElement = endNameToken.getParent();
if (!(tagElement instanceof XmlTag) && !(tagElement instanceof PsiErrorElement)) return;
if (tagElement instanceof PsiErrorElement) {
tagElement.delete();
}
else {
final ASTNode astNode = tagElement.getNode();
if (astNode != null) {
final ASTNode endTagStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(astNode);
if (endTagStart != null) {
final Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(tagElement.getContainingFile());
if (document != null) {
document.deleteString(endTagStart.getStartOffset(), tagElement.getLastChild().getTextRange().getEndOffset());
}
}
}
}
}
示例8: findEndTagName
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Nullable
static XmlToken findEndTagName(@Nullable final PsiErrorElement element) {
if (element == null) return null;
final ASTNode astNode = element.getNode();
if (astNode == null) return null;
ASTNode current = astNode.getLastChildNode();
ASTNode prev = current;
while (current != null) {
final IElementType elementType = prev.getElementType();
if ((elementType == XmlTokenType.XML_NAME || elementType == XmlTokenType.XML_TAG_NAME) &&
current.getElementType() == XmlTokenType.XML_END_TAG_START) {
return (XmlToken)prev.getPsi();
}
prev = current;
current = current.getTreePrev();
}
return null;
}
示例9: shouldHighlightErrorElement
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Override
public boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element) {
final PsiFile psiFile = element.getContainingFile();
if (psiFile == null || psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
&& HTMLLanguage.INSTANCE != element.getLanguage()) return true;
final PsiElement[] children = element.getChildren();
if (children.length > 0) {
if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
return false;
}
}
}
return true;
}
示例10: isInContext
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
public static boolean isInContext(@NotNull PsiElement element) {
if (PsiTreeUtil.getParentOfType(element, XmlComment.class) != null) {
return false;
}
if (PsiTreeUtil.getParentOfType(element, XmlText.class) != null) {
return true;
}
if (element.getNode().getElementType() == XmlTokenType.XML_START_TAG_START) {
return true;
}
PsiElement parent = element.getParent();
if (parent instanceof PsiErrorElement) {
parent = parent.getParent();
}
return parent instanceof XmlDocument;
}
示例11: shouldHighlightErrorElement
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Override
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement error) {
final Project project = error.getProject();
final Language language = error.getLanguage();
// if ("CSS".equals(language.getID()) && PsiTreeUtil.getParentOfType(error, XmlAttribute.class) != null &&
// AngularIndexUtil.hasAngularJS(project)) {
// final PsiFile file = error.getContainingFile();
//
// PsiErrorElement nextError = error;
// while (nextError != null) {
// if (hasAngularInjectionAt(project, file, nextError.getTextOffset())) return false;
// nextError = PsiTreeUtil.getNextSiblingOfType(nextError, PsiErrorElement.class);
// }
// }
if (HTMLLanguage.INSTANCE.is(language) && error.getErrorDescription().endsWith("not closed")) {
System.out.println(error.getErrorDescription());
final PsiElement parent = error.getParent();
final XmlElementDescriptor descriptor = parent instanceof XmlTag ? ((XmlTag) parent).getDescriptor() : null;
return !(descriptor instanceof RTRequireTagDescriptor);
}
return true;
}
示例12: getDeclarations
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@NotNull
public GLSLDeclaration[] getDeclarations() {
// convert the list of children to a list of GLSLStatement objects while performing sanity check.
PsiElement[] children = getChildren();
List<GLSLDeclaration> result = new ArrayList<GLSLDeclaration>(children.length);
for (PsiElement child : children) {
if (child instanceof GLSLDeclaration) {
result.add((GLSLDeclaration) child);
} else if (!(child instanceof PsiErrorElement)) {
final ASTNode node = child.getNode();
if (node != null) {
final IElementType type = node.getElementType();
if (!GLSLTokenTypes.COMMENTS.contains(type)) {
Logger.getLogger("GLSLDeclarationList").warning("Parameter declaration list contains non-comment, non-expression element. ("+type+")");
}
}
}
}
return result.toArray(new GLSLDeclaration[result.size()]);
}
示例13: hashCodesEqual
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Override
public boolean hashCodesEqual(final ASTNode n1, 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();
}
示例14: findEndTagName
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
@Nullable
static XmlToken findEndTagName(@Nullable final PsiErrorElement element) {
if (element == null) return null;
final ASTNode astNode = element.getNode();
if (astNode == null) return null;
ASTNode current = astNode.getLastChildNode();
ASTNode prev = current;
while (current != null) {
final IElementType elementType = prev.getElementType();
if ((elementType == XmlElementType.XML_NAME || elementType == XmlElementType.XML_TAG_NAME) &&
current.getElementType() == XmlElementType.XML_END_TAG_START) {
return (XmlToken)prev.getPsi();
}
prev = current;
current = current.getTreePrev();
}
return null;
}
示例15: shouldHighlightErrorElement
import com.intellij.psi.PsiErrorElement; //导入依赖的package包/类
public boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element) {
final PsiFile psiFile = element.getContainingFile();
if (psiFile == null || (psiFile.getViewProvider().getBaseLanguage() != HTMLLanguage.INSTANCE
&& HTMLLanguage.INSTANCE != element.getLanguage())) return true;
final PsiElement[] children = element.getChildren();
if (children.length > 0) {
if (children[0] instanceof XmlToken && XmlTokenType.XML_END_TAG_START == ((XmlToken)children[0]).getTokenType()) {
if (XmlErrorMessages.message("xml.parsing.closing.tag.matches.nothing").equals(element.getErrorDescription())) {
return false;
}
}
}
return true;
}