本文整理汇总了Java中com.intellij.psi.xml.XmlToken.getTokenType方法的典型用法代码示例。如果您正苦于以下问题:Java XmlToken.getTokenType方法的具体用法?Java XmlToken.getTokenType怎么用?Java XmlToken.getTokenType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlToken
的用法示例。
在下文中一共展示了XmlToken.getTokenType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildVisitor
import com.intellij.psi.xml.XmlToken; //导入方法依赖的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);
}
};
}
示例2: getDeclarationRange
import com.intellij.psi.xml.XmlToken; //导入方法依赖的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);
}
示例3: getDeclarationRange
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@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);
}
示例4: isInternalReference
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Override
public boolean isInternalReference()
{
for(ASTNode e = getFirstChildNode(); e != null; e = e.getTreeNext())
{
if(e.getElementType() instanceof IXmlLeafElementType)
{
XmlToken token = (XmlToken) SourceTreeToPsiMap.treeElementToPsi(e);
if(token.getTokenType() == XmlTokenType.XML_DOCTYPE_PUBLIC || token.getTokenType() == XmlTokenType.XML_DOCTYPE_SYSTEM)
{
return false;
}
}
}
return true;
}
示例5: findXMLElement
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
/**
* Further refine search in order to match the exact XML Camel route.
*
* @param route the complete Camel route to search for
* @param psiElement the {@link PsiElement} that might contain the complete route definition
* @return the {@link PsiElement} that contains the exact match of the Camel route
*/
private PsiElement findXMLElement(String route, XmlToken psiElement) {
if (psiElement.getTokenType() == XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN) {
if (Arrays.stream(XML_ROUTE_CALL).anyMatch(s -> s.equals(PsiTreeUtil.getParentOfType(psiElement, XmlTag.class).getLocalName()))) {
if (psiElement.getText().equals(route)) {
return psiElement;
}
}
}
return null;
}
示例6: handleContentChange
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Override
public XmlToken handleContentChange(@NotNull XmlToken xmlToken, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
String oldText = xmlToken.getText();
String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset());
IElementType tokenType = xmlToken.getTokenType();
FileElement holder = DummyHolderFactory.createHolder(xmlToken.getManager(), null).getTreeElement();
LeafElement leaf = ASTFactory.leaf(tokenType, holder.getCharTable().intern(newText));
holder.rawAddChildren(leaf);
return (XmlToken)xmlToken.replace(leaf.getPsi());
}
示例7: findXmlTag
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Nullable
private static XmlTag findXmlTag(PsiFile file, int offset){
if (!(file instanceof XmlFile)) return null;
PsiElement element = file.findElementAt(offset);
if (element == null) return null;
element = element.getParent();
while (element != null) {
if (element instanceof XmlTag) {
XmlTag tag = (XmlTag)element;
final PsiElement[] children = tag.getChildren();
if (offset <= children[0].getTextRange().getStartOffset()) return null;
for (PsiElement child : children) {
final TextRange range = child.getTextRange();
if (range.getStartOffset() <= offset && range.getEndOffset() > offset) return tag;
if (child instanceof XmlToken) {
XmlToken token = (XmlToken)child;
if (token.getTokenType() == XmlTokenType.XML_TAG_END) return null;
}
}
return null;
}
element = element.getParent();
}
return null;
}
示例8: select
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
PsiElement[] children = e.getChildren();
PsiElement first = null;
PsiElement last = null;
for (PsiElement child : children) {
if (child instanceof XmlToken) {
XmlToken token = (XmlToken)child;
if (token.getTokenType() == XmlTokenType.XML_CDATA_START) {
first = token.getNextSibling();
}
if (token.getTokenType() == XmlTokenType.XML_CDATA_END) {
last = token.getPrevSibling();
break;
}
}
}
if (first != null && last != null) {
result.addAll(expandToWholeLine(editorText,
new TextRange(first.getTextRange().getStartOffset(),
last.getTextRange().getEndOffset()),
false));
}
return result;
}
示例9: select
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
PsiElement[] children = e.getChildren();
PsiElement first = null;
PsiElement last = null;
for (PsiElement child : children) {
if (child instanceof XmlToken) {
XmlToken token = (XmlToken)child;
if (token.getTokenType() == XmlTokenType.XML_TAG_END) {
last = token;
break;
}
if (token.getTokenType() == XmlTokenType.XML_ELEMENT_DECL_START ||
token.getTokenType() == XmlTokenType.XML_ATTLIST_DECL_START
) {
first = token;
}
}
}
List<TextRange> result = new ArrayList<TextRange>(1);
if (first != null && last != null) {
final int offset = last.getTextRange().getEndOffset() + 1;
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText,
new TextRange(first.getTextRange().getStartOffset(), offset < editorText.length() ? offset:editorText.length()),
false));
}
return result;
}
示例10: shouldSelectToken
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
static boolean shouldSelectToken(final XmlToken token) {
return token.getTokenType() != XmlTokenType.XML_DATA_CHARACTERS &&
token.getTokenType() != XmlTokenType.XML_START_TAG_START &&
token.getTokenType() != XmlTokenType.XML_END_TAG_START &&
token.getTokenType() != XmlTokenType.XML_EMPTY_ELEMENT_END &&
token.getTokenType() != XmlTokenType.XML_TAG_END;
}
示例11: restoreElement
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement restoreElement(@NotNull PsiElement anchor) {
if (anchor instanceof XmlToken) {
XmlToken token = (XmlToken)anchor;
return token.getTokenType() == XmlTokenType.XML_NAME ? token.getParent() : null;
}
return null;
}
示例12: select
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
PsiElement[] children = e.getChildren();
PsiElement first = null;
PsiElement last = null;
for (PsiElement child : children) {
if (child instanceof XmlToken) {
XmlToken token = (XmlToken)child;
if (token.getTokenType() == XmlTokenType.XML_CDATA_START) {
first = token.getNextSibling();
}
if (token.getTokenType() == XmlTokenType.XML_CDATA_END) {
last = token.getPrevSibling();
break;
}
}
}
if (first != null && last != null) {
result.addAll(expandToWholeLine(editorText,
new TextRange(first.getTextRange().getStartOffset(),
last.getTextRange().getEndOffset()),
false));
}
return result;
}
示例13: select
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
PsiElement[] children = e.getChildren();
PsiElement first = null;
PsiElement last = null;
for (PsiElement child : children) {
if (child instanceof XmlToken) {
XmlToken token = (XmlToken)child;
if (token.getTokenType() == XmlTokenType.XML_TAG_END) {
last = token;
break;
}
if (token.getTokenType() == XmlTokenType.XML_ELEMENT_DECL_START ||
token.getTokenType() == XmlTokenType.XML_ATTLIST_DECL_START
) {
first = token;
}
}
}
List<TextRange> result = new ArrayList<TextRange>(1);
if (first != null && last != null) {
final int offset = last.getTextRange().getEndOffset() + 1;
result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText,
new TextRange(first.getTextRange().getStartOffset(), offset < editorText.length() ? offset:editorText.length()),
false));
}
return result;
}
示例14: handleContentChange
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
public XmlToken handleContentChange(XmlToken xmlToken, TextRange range, String newContent) throws IncorrectOperationException {
String oldText = xmlToken.getText();
String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText.substring(range.getEndOffset());
IElementType tokenType = xmlToken.getTokenType();
FileElement holder = DummyHolderFactory.createHolder(xmlToken.getManager(), null).getTreeElement();
LeafElement leaf = ASTFactory.leaf(tokenType, holder.getCharTable().intern(newText));
holder.rawAddChildren(leaf);
return (XmlToken)xmlToken.replace(leaf.getPsi());
}
示例15: restoreElement
import com.intellij.psi.xml.XmlToken; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement restoreElement(@NotNull PsiElement anchor)
{
if(anchor instanceof XmlToken)
{
XmlToken token = (XmlToken) anchor;
return token.getTokenType() == XmlTokenType.XML_NAME ? token.getParent() : null;
}
return null;
}