当前位置: 首页>>代码示例>>Java>>正文


Java XmlToken.getTokenType方法代码示例

本文整理汇总了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);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:HtmlLocalInspectionTool.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TagDeclarationRangeHandler.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:TagDeclarationRangeHandler.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:18,代码来源:XmlEntityDeclImpl.java

示例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;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:18,代码来源:CamelRouteLineMarkerProvider.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:XmlTokenManipulator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:XmlParameterInfoHandler.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:XmlCDATAContentSelectioner.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:DtdSelectioner.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XmlTokenSelectioner.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:XmlAnchorProvider.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:XmlCDATAContentSelectioner.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:DtdSelectioner.java

示例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());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:XmlTokenManipulator.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:12,代码来源:XmlAnchorProvider.java


注:本文中的com.intellij.psi.xml.XmlToken.getTokenType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。