本文整理汇总了Java中com.intellij.psi.xml.XmlTokenType类的典型用法代码示例。如果您正苦于以下问题:Java XmlTokenType类的具体用法?Java XmlTokenType怎么用?Java XmlTokenType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlTokenType类属于com.intellij.psi.xml包,在下文中一共展示了XmlTokenType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull final AnnotationHolder holder) {
psiElement.accept(new XmlElementVisitor() {
@Override public void visitXmlTag(XmlTag tag) {
XmlAttribute attribute = tag.getAttribute("aaa", "");
if (attribute != null) {
holder.createWarningAnnotation(attribute, "AAATTR");
}
}
@Override public void visitXmlToken(XmlToken token) {
if (token.getTokenType() == XmlTokenType.XML_ENTITY_REF_TOKEN) {
holder.createWarningAnnotation(token, "ENTITY");
}
}
});
}
示例2: buildVisitor
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override public void visitXmlToken(final XmlToken token) {
if (token.getTokenType() == XmlTokenType.XML_NAME) {
PsiElement element = token.getPrevSibling();
while(element instanceof PsiWhiteSpace) element = element.getPrevSibling();
if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
PsiElement parent = element.getParent();
if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
XmlTag tag = (XmlTag)parent;
checkTag(tag, holder, isOnTheFly);
}
}
}
}
@Override public void visitXmlAttribute(final XmlAttribute attribute) {
checkAttribute(attribute, holder, isOnTheFly);
}
};
}
示例3: findEndTagName
import com.intellij.psi.xml.XmlTokenType; //导入依赖的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;
}
示例4: shouldHighlightErrorElement
import com.intellij.psi.xml.XmlTokenType; //导入依赖的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;
}
示例5: buildVisitor
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override public void visitXmlTag(final XmlTag tag) {
if (!CheckEmptyTagInspection.isTagWithEmptyEndNotAllowed(tag)) {
final ASTNode child = XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode());
if (child != null) {
final ASTNode node = child.getTreeNext();
if (node != null &&
node.getElementType() == XmlTokenType.XML_END_TAG_START) {
final LocalQuickFix localQuickFix = new Fix();
holder.registerProblem(
tag,
XmlBundle.message("xml.inspections.tag.empty.body"),
isCollapsibleTag(tag) ? localQuickFix : null
);
}
}
}
}
};
}
示例6: getTag
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
private static TextRange getTag(XmlToken tagName, IElementType tagStart) {
if (tagName != null) {
PsiElement s = tagName.getPrevSibling();
while (s != null && s.getNode().getElementType() != tagStart) {
s = s.getPrevSibling();
}
PsiElement f = tagName.getNextSibling();
while (f != null &&
!(f.getNode().getElementType() == XmlTokenType.XML_TAG_END ||
f.getNode().getElementType() == XmlTokenType.XML_EMPTY_ELEMENT_END)) {
f = f.getNextSibling();
}
if (s != null && f != null) {
return new TextRange(s.getTextRange().getStartOffset(), f.getTextRange().getEndOffset());
}
}
return null;
}
示例7: canStickTokensTogetherByLexerInXml
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
public static SpaceRequirements canStickTokensTogetherByLexerInXml(final ASTNode left,
final ASTNode right,
final Lexer lexer,
int state) {
if (left.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN ||
right.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN) {
return SpaceRequirements.MUST_NOT;
}
if (left.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER && right.getElementType() == XmlTokenType.XML_NAME) {
return SpaceRequirements.MUST;
}
if (left.getElementType() == XmlTokenType.XML_NAME && right.getElementType() == XmlTokenType.XML_NAME) {
return SpaceRequirements.MUST;
}
return SpaceRequirements.MAY;
}
示例8: parseHeader
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
private void parseHeader(String tagName) {
boolean freeMakerTag = !tagName.isEmpty() && '#' == tagName.charAt(0);
do {
final IElementType tt = token();
if (freeMakerTag) {
if (tt == XmlTokenType.XML_EMPTY_ELEMENT_END ||
tt == XmlTokenType.XML_TAG_END ||
tt == XmlTokenType.XML_END_TAG_START ||
tt == XmlTokenType.XML_START_TAG_START) break;
advance();
}
else {
if (tt == XmlTokenType.XML_NAME) {
parseAttribute();
}
else if (tt == XmlTokenType.XML_CHAR_ENTITY_REF || tt == XmlTokenType.XML_ENTITY_REF_TOKEN) {
parseReference();
}
else {
break;
}
}
}
while (!eof());
}
示例9: getReferences
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
@NotNull
public PsiReference[] getReferences() {
final IElementType elementType = getElementType();
if (elementType == XmlTokenType.XML_DATA_CHARACTERS ||
elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
return ReferenceProvidersRegistry.getReferencesFromProviders(this);
} else if (elementType == XmlTokenType.XML_NAME && getParent() instanceof PsiErrorElement) {
final PsiElement element = getPrevSibling();
if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_END_TAG_START) {
return new PsiReference[] {TagNameReference.createTagNameReference(this, getNode(), false)};
}
}
return super.getReferences();
}
示例10: fun
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
public ThreeState fun(ASTNode oldNode,
LighterASTNode newNode,
FlyweightCapableTreeStructure<LighterASTNode> structure) {
if (oldNode instanceof XmlTag && newNode.getTokenType() == XmlElementType.XML_TAG) {
String oldName = ((XmlTag)oldNode).getName();
Ref<LighterASTNode[]> childrenRef = Ref.create(null);
int count = structure.getChildren(newNode, childrenRef);
if (count < 3) return ThreeState.UNSURE;
LighterASTNode[] children = childrenRef.get();
if (children[0].getTokenType() != XmlTokenType.XML_START_TAG_START) return ThreeState.UNSURE;
if (children[1].getTokenType() != XmlTokenType.XML_NAME) return ThreeState.UNSURE;
if (children[2].getTokenType() != XmlTokenType.XML_TAG_END) return ThreeState.UNSURE;
LighterASTTokenNode name = (LighterASTTokenNode)children[1];
CharSequence newName = name.getText();
if (!Comparing.equal(oldName, newName)) return ThreeState.NO;
}
return ThreeState.UNSURE;
}
示例11: parseConditionalCommentBoundaries
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
/**
* Tries to parse given element as <a href="http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx">conditional comment</a>.
*
* @param host target element to parse
* @return <code>null</code> if given element is not a conditional comment;
* pair like <code>(conditional comment start element; conditional comment end element)</code> otherwise
*/
@Nullable
private static Pair<ASTNode, ASTNode> parseConditionalCommentBoundaries(@NotNull PsiElement host) {
if (!(host instanceof XmlComment)) {
return null;
}
final ASTNode comment = host.getNode();
if (comment == null) {
return null;
}
final ASTNode conditionalStart = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_START_END));
if (conditionalStart == null) {
return null;
}
final ASTNode conditionalEnd = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_END_START));
if (conditionalEnd == null) {
return null;
}
final ASTNode endOfEnd = comment.findChildByType(TokenSet.create(XmlTokenType.XML_CONDITIONAL_COMMENT_END));
return endOfEnd == null ? null : Pair.create(conditionalStart, conditionalEnd);
}
示例12: getTokenType
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
public IElementType getTokenType() {
IElementType tokenType = getDelegate().getTokenType();
if (tokenType == null) return tokenType;
int state = getState() & 0xF;
tokenType = fixWrongTokenTypes(tokenType, state);
if (tokenType != XmlTokenType.XML_COMMENT_CHARACTERS &&
tokenType != XmlTokenType.XML_COMMENT_END &&
tokenType != XmlTokenType.XML_COMMENT_START &&
tokenType != XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {
// TODO: do not know when this happens!
switch (state) {
case __XmlLexer.DOCTYPE:
tokenType = XmlTokenType.XML_DECL_START;
break;
}
}
return tokenType;
}
示例13: getReferencesByElement
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (element instanceof XmlProcessingInstruction) {
final ASTNode importNode = element.getNode().findChildByType(XmlTokenType.XML_TAG_CHARACTERS);
if (importNode != null) {
final PsiElement importInstr = importNode.getPsi();
final String instructionTarget = JavaFxPsiUtil.getInstructionTarget("import", (XmlProcessingInstruction)element);
if (instructionTarget != null && instructionTarget.equals(importInstr.getText())) {
final PsiReference[] references =
FxmlReferencesContributor.CLASS_REFERENCE_PROVIDER.getReferencesByString(instructionTarget, element, importInstr.getStartOffsetInParent());
if (instructionTarget.endsWith(".*")) {
return ArrayUtil.remove(references, references.length - 1);
}
else {
return references;
}
}
}
}
return PsiReference.EMPTY_ARRAY;
}
示例14: getDeclarationRange
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@Override
@NotNull
public TextRange getDeclarationRange(@NotNull final PsiElement container) {
XmlTag xmlTag = (XmlTag)container;
int endOffset = xmlTag.getTextRange().getStartOffset();
for (PsiElement child = xmlTag.getFirstChild(); child != null; child = child.getNextSibling()) {
endOffset = child.getTextRange().getEndOffset();
if (child instanceof XmlToken) {
XmlToken token = (XmlToken)child;
IElementType tokenType = token.getTokenType();
if (tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END || tokenType == XmlTokenType.XML_TAG_END) break;
}
}
return new TextRange(xmlTag.getTextRange().getStartOffset(), endOffset);
}
示例15: shouldSkipAutopopup
import com.intellij.psi.xml.XmlTokenType; //导入依赖的package包/类
@NotNull
@Override
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
ASTNode node = contextElement.getNode();
if (node != null && node.getElementType() == XmlTokenType.XML_DATA_CHARACTERS) {
PsiElement parent = contextElement.getParent();
if (parent instanceof XmlText || parent instanceof XmlDocument) {
String contextElementText = contextElement.getText();
int endOffset = offset - contextElement.getTextRange().getStartOffset();
String prefix = contextElementText.substring(0, Math.min(contextElementText.length(), endOffset));
if (!StringUtil.startsWithChar(prefix, '<') && !StringUtil.startsWithChar(prefix, '&')) {
return ThreeState.YES;
}
}
}
return ThreeState.UNSURE;
}