• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XmlToken类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.xml.XmlToken的典型用法代码示例。如果您正苦于以下问题:Java XmlToken类的具体用法?Java XmlToken怎么用?Java XmlToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmlToken类属于com.intellij.psi.xml包,在下文中一共展示了XmlToken类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isAvailable

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {

    if (!WeexFileUtil.isOnWeexFile(element)) {
        return false;
    }

    int offset = editor.getCaretModel().getOffset();
    Document document = editor.getDocument();
    if (!element.isWritable() || element.getContext() == null || !element.getContext().isWritable()) {
        return false;
    }

    if (element instanceof XmlToken && ((XmlToken) element).getTokenType().toString().equals("XML_END_TAG_START")) {
        String next = document.getText(new TextRange(offset, offset + 1));
        if (next != null && next.equals("<")) {
            return true;
        }
    }

    return available(element);
}
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:23,代码来源:TagTextIntention.java


示例2: adjustSectionElement

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
private static PsiElement adjustSectionElement(PsiFile file, PsiElement element){
    PsiElement psiElement = element;
    if(file instanceof PsiJavaFile) {
        if (psiElement instanceof PsiJavaToken) {
            if (((PsiJavaToken) psiElement).getTokenType() == ElementType.SEMICOLON) {
                psiElement = psiElement.getPrevSibling();
                if (psiElement instanceof PsiLiteralExpression) {
                    return psiElement;
                }
            } else if (((PsiJavaToken) psiElement).getTokenType() == ElementType.STRING_LITERAL) {
                return psiElement;
            }
        }
    }else if(file instanceof XmlFile) {
        if(psiElement instanceof XmlToken){
            psiElement = psiElement.getParent();
            if(psiElement instanceof XmlAttributeValue) {
                return psiElement;
            }
        }
    }
    return null;
}
 
开发者ID:Androidyuan,项目名称:AndroidResourceGeneratedPlugin,代码行数:24,代码来源:TextUtils.java


示例3: extractTextFromElement

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
@Override
public Optional<String> extractTextFromElement(PsiElement element, boolean concatString, boolean stripWhitespace) {
    // maybe its xml then try that
    if (element instanceof XmlAttributeValue) {
        return Optional.ofNullable(((XmlAttributeValue) element).getValue());
    } else if (element instanceof XmlText) {
        return Optional.ofNullable(((XmlText) element).getValue());
    } else if (element instanceof XmlToken) {
        // it may be a token which is a part of an combined attribute
        if (concatString) {
            XmlAttributeValue xml = PsiTreeUtil.getParentOfType(element, XmlAttributeValue.class);
            if (xml != null) {
                return Optional.ofNullable(getInnerText(xml.getValue()));
            }
        } else {
            String returnText = element.getText();
            final PsiElement prevSibling = element.getPrevSibling();
            if (prevSibling != null && prevSibling.getText().equalsIgnoreCase("&amp;")) {
                returnText = prevSibling.getText() + returnText;
            }
            return Optional.ofNullable(getInnerText(returnText));
        }
    }
    return Optional.empty();
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:26,代码来源:XmlIdeaUtils.java


示例4: testCamelGutterForToD

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
public void testCamelGutterForToD() {
    myFixture.configureByFiles("XmlCamelRouteLineMarkerProviderToDTestData.xml");
    List<GutterMark> gutters = myFixture.findAllGutters();
    assertNotNull(gutters);

    assertEquals("Should contain 1 Camel gutter", 1, gutters.size());

    assertSame("Gutter should have the Camel icon", ServiceManager.getService(CamelPreferenceService.class).getCamelIcon(), gutters.get(0).getIcon());
    assertEquals("Camel route", gutters.get(0).getTooltipText());

    LineMarkerInfo.LineMarkerGutterIconRenderer gutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);

    assertTrue(gutter.getLineMarkerInfo().getElement() instanceof XmlToken);
    assertEquals("The navigation start element doesn't match", "file:inbox",
            PsiTreeUtil.getParentOfType(gutter.getLineMarkerInfo().getElement(), XmlTag.class).getAttribute("uri").getValue());

    List<GotoRelatedItem> gutterTargets = getGutterNavigationDestinationElements(gutter);
    assertEquals("Navigation should have one target", 1, gutterTargets.size());
    assertEquals("The navigation target route doesn't match", "file:inbox", gutterTargets.get(0).getElement().getText());
    assertEquals("The navigation target tag name doesn't match", "toD",
            getGuttersWithXMLTarget(gutterTargets).get(0).getLocalName());

}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:24,代码来源:XmlCamelRouteLineMarkerProviderTestIT.java


示例5: canSelectBasic

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
public static boolean canSelectBasic(final PsiElement e) {
  return
    !(e instanceof PsiWhiteSpace) &&
    !(e instanceof PsiComment) &&
    !(e instanceof PsiCodeBlock) &&
    !(e instanceof PsiArrayInitializerExpression) &&
    !(e instanceof PsiParameterList) &&
    !(e instanceof PsiExpressionList) &&
    !(e instanceof PsiBlockStatement) &&
    !(e instanceof PsiJavaCodeReferenceElement) &&
    !(e instanceof PsiJavaToken &&
    !(e instanceof PsiKeyword)) &&
    !(e instanceof XmlToken) &&
    !(e instanceof XmlElement) &&
    !(e instanceof PsiDocTag);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:BasicSelectioner.java


示例6: annotate

import com.intellij.psi.xml.XmlToken; //导入依赖的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");
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LightAdvHighlightingTest.java


示例7: 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


示例8: doFix

import com.intellij.psi.xml.XmlToken; //导入依赖的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());
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RemoveExtraClosingTagIntentionAction.java


示例9: registerProblemStart

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
private static void registerProblemStart(@NotNull final AnnotationHolder holder,
                                    @NotNull final XmlTag tag,
                                    @NotNull final XmlToken start,
                                    @NotNull final XmlToken end) {
  PsiElement context = tag.getContainingFile().getContext();
  if (context != null) {
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
    if (parserDefinition != null) {
      ASTNode contextNode = context.getNode();
      if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
        // TODO: we should check for concatenations here
        return;
      }
    }
  }
  final String tagName = tag.getName();
  final String endTokenText = end.getText();

  final RenameTagBeginOrEndIntentionAction renameEndAction = new RenameTagBeginOrEndIntentionAction(tagName, endTokenText, false);
  final RenameTagBeginOrEndIntentionAction renameStartAction = new RenameTagBeginOrEndIntentionAction(endTokenText, tagName, true);

  final Annotation annotation = holder.createErrorAnnotation(start, XmlErrorMessages.message("tag.has.wrong.closing.tag.name"));
  annotation.registerFix(renameEndAction);
  annotation.registerFix(renameStartAction);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlWrongClosingTagNameInspection.java


示例10: registerProblemEnd

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
private static void registerProblemEnd(@NotNull final AnnotationHolder holder,
                                       @NotNull final XmlTag tag,
                                       @NotNull final XmlToken end) {
  PsiElement context = tag.getContainingFile().getContext();
  if (context != null) {
    ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
    if (parserDefinition != null) {
      ASTNode contextNode = context.getNode();
      if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
        // TODO: we should check for concatenations here
        return;
      }
    }
  }
  final String tagName = tag.getName();
  final String endTokenText = end.getText();

  final RenameTagBeginOrEndIntentionAction renameEndAction = new RenameTagBeginOrEndIntentionAction(tagName, endTokenText, false);
  final RenameTagBeginOrEndIntentionAction renameStartAction = new RenameTagBeginOrEndIntentionAction(endTokenText, tagName, true);

  final Annotation annotation = holder.createErrorAnnotation(end, XmlErrorMessages.message("wrong.closing.tag.name"));
  annotation.registerFix(new RemoveExtraClosingTagIntentionAction());
  annotation.registerFix(renameEndAction);
  annotation.registerFix(renameStartAction);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlWrongClosingTagNameInspection.java


示例11: findEndTagName

import com.intellij.psi.xml.XmlToken; //导入依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:XmlWrongClosingTagNameInspection.java


示例12: shouldHighlightErrorElement

import com.intellij.psi.xml.XmlToken; //导入依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:HtmlClosingTagErrorFilter.java


示例13: addMessagesForTreeChild

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
private static void addMessagesForTreeChild(final XmlToken childByRole,
                                            final Validator.ValidationHost.ErrorType type,
                                            final String message,
                                            AnnotationHolder myHolder, IntentionAction... actions) {
  if (childByRole != null) {
    Annotation annotation;
    if (type == Validator.ValidationHost.ErrorType.ERROR) {
      annotation = myHolder.createErrorAnnotation(childByRole, message);
    }
    else {
      annotation = myHolder.createWarningAnnotation(childByRole, message);
    }

    appendFixes(annotation, actions);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XMLExternalAnnotator.java


示例14: getReferences

import com.intellij.psi.xml.XmlToken; //导入依赖的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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XmlTokenImpl.java


示例15: getQuantifierImpl

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
public static Quantifier getQuantifierImpl(PsiElement element) {
  PsiElement nextSibling = element.getNextSibling();
  while (nextSibling instanceof PsiWhiteSpace) {
    nextSibling = nextSibling.getNextSibling();
  }

  if (nextSibling instanceof XmlToken) {
    IElementType tokenType = ((XmlToken)nextSibling).getTokenType();
    if (tokenType == XML_PLUS) {
      return Quantifier.ONE_OR_MORE;
    }
    else if (tokenType == XML_STAR) {
      return Quantifier.ZERO_OR_MORE;
    }
    else if (tokenType == XML_QUESTION) {
      return Quantifier.OPTIONAL;
    }
  }
  return Quantifier.REQUIRED;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:XmlContentParticleImpl.java


示例16: 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


示例17: findPrefix

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
@Override
public String findPrefix(PsiElement insertedElement, int offset) {
  String prefix = super.findPrefix(insertedElement, offset);

  boolean searchForEntities =
    insertedElement instanceof XmlToken &&
    ( ((XmlToken)insertedElement).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS ||
      ((XmlToken)insertedElement).getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN
    );

  if (searchForEntities) {
    if (prefix.startsWith("&")) {
      prefix = prefix.substring(1);
    } else if (prefix.contains("&")) {
      prefix = prefix.substring(prefix.indexOf("&") + 1);
    }
  }

  return prefix;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:HtmlCompletionData.java


示例18: handleUserSelection

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
private static void handleUserSelection(InsertionContext context, @NotNull Function<Color, String> colorToStringConverter) {
  Color myColorAtCaret = null;

  Editor selectedTextEditor = context.getEditor();
  PsiElement element = context.getFile().findElementAt(selectedTextEditor.getCaretModel().getOffset());

  if (element instanceof XmlToken) {
    myColorAtCaret = getColorFromElement(element);
  }

  context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());

  List<ColorPickerListener> listeners = ColorPickerListenerFactory.createListenersFor(element);
  Color color = ColorChooser.chooseColor(WindowManager.getInstance().suggestParentWindow(context.getProject()),
                                         XmlBundle.message("choose.color.dialog.title"), myColorAtCaret, true, listeners, true);

  if (color != null) {
    String colorString = colorToStringConverter.fun(color);
    context.getDocument().insertString(context.getStartOffset(), colorString);
    context.getEditor().getCaretModel().moveToOffset(context.getTailOffset());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UserColorLookup.java


示例19: getElementsToSurround

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
@Override
@NotNull public PsiElement[] getElementsToSurround(PsiFile file, int startOffset, int endOffset) {
  final Pair<XmlTagChild, XmlTagChild> childrenInRange = XmlUtil.findTagChildrenInRange(file, startOffset, endOffset);
  if (childrenInRange == null) {
    final PsiElement elementAt = file.findElementAt(startOffset);
    if (elementAt instanceof XmlToken &&
        ((XmlToken)elementAt).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      return new PsiElement[] {elementAt};
    }
    return PsiElement.EMPTY_ARRAY;
  }
  List<PsiElement> result = new ArrayList<PsiElement>();
  PsiElement first = childrenInRange.getFirst();
  PsiElement last = childrenInRange.getSecond();
  while(true) {
    result.add(first);
    if (first == last) break;
    first = first.getNextSibling();
  }

  return PsiUtilCore.toPsiElementArray(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XmlSurroundDescriptor.java


示例20: getEndTagNameElement

import com.intellij.psi.xml.XmlToken; //导入依赖的package包/类
@Nullable
public static XmlToken getEndTagNameElement(@NotNull XmlTag tag) {
  final ASTNode node = tag.getNode();
  if (node == null) return null;

  ASTNode current = node.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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XmlTagUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AuthenticationFailedException类代码示例发布时间:2022-05-21
下一篇:
Java ConnectableObservable类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap