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


Java XMLLanguage类代码示例

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


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

示例1: _testLexerPerformance1

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
public void _testLexerPerformance1() throws Exception {
  final String text = loadFile("pallada.xml");
  XmlLexer lexer = new XmlLexer();
  doLex(lexer, text);
  final FilterLexer filterLexer = new FilterLexer(new XmlLexer(),
                                                  new FilterLexer.SetFilter(
                                                    LanguageParserDefinitions.INSTANCE.forLanguage(XMLLanguage.INSTANCE)
                                                      .getWhitespaceTokens()));
  doLex(filterLexer, text);
  doLex(lexer, text);
  doLex(filterLexer, text);
  doLex(filterLexer, text);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:XmlParsingTest.java

示例2: isInXmlContext

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
public static boolean isInXmlContext(Lookup lookup) {
  if (!lookup.isCompletion()) return false;

  PsiElement psiElement = lookup.getPsiElement();
  PsiFile file = lookup.getPsiFile();
  if (!(file instanceof XmlFile) && psiElement != null) {
    file = psiElement.getContainingFile();
  }


  if (file instanceof XmlFile) {
    if (psiElement != null) {
      PsiElement elementToTest = psiElement;
      if (elementToTest instanceof PsiWhiteSpace) {
        elementToTest = elementToTest.getParent(); // JSPX has whitespace with language Java
      }

      final Language language = elementToTest.getLanguage();
      if (!(language instanceof XMLLanguage)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XmlCharFilter.java

示例3: isLanguageRelevant

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
private static boolean isLanguageRelevant(final PsiElement element,
                                          final PsiFile file,
                                          final Ref<Boolean> isRelevantLanguage,
                                          final Ref<Boolean> isAnt) {
  Boolean isAntFile = isAnt.get();
  if (isAntFile == null) {
    isAntFile = XmlUtil.isAntFile(file);
    isAnt.set(isAntFile);
  }
  Boolean result = isRelevantLanguage.get();
  if (result == null) {
    Language language = element.getLanguage();
    PsiElement parent = element.getParent();
    if (element instanceof PsiWhiteSpace && parent != null) {
      language = parent.getLanguage();
    }
    result = language instanceof XMLLanguage || HtmlUtil.supportsXmlTypedHandlers(file) || isAntFile.booleanValue();
    isRelevantLanguage.set(result);
  }
  return result.booleanValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XmlAutoPopupHandler.java

示例4: charTyped

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@Override
public Result charTyped(char c, Project project, @NotNull Editor editor, @NotNull PsiFile file) {
  if (c == '?' && file.getLanguage() == XMLLanguage.INSTANCE) {
    int offset = editor.getCaretModel().getOffset();
    if (offset >= 2 && editor.getDocument().getCharsSequence().charAt(offset - 2) == '<') {
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
      PsiElement at = file.findElementAt(offset - 2);
      if (at != null && at.getNode().getElementType() == XmlTokenType.XML_PI_START &&
          editor.getDocument().getText().indexOf("?>", offset) == -1) {

        editor.getDocument().insertString(offset, " ?>");
        AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
      }
    }
  }
  return super.charTyped(c, project, editor, file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XmlPiTypedHandler.java

示例5: expandEmptyTagIfNecessary

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@NotNull
private static XmlTag expandEmptyTagIfNecessary(@NotNull XmlTag tag) {
  StringBuilder builder = new StringBuilder();
  boolean flag = false;

  for (PsiElement child : tag.getChildren()) {
    if (child instanceof XmlToken && XmlTokenType.XML_EMPTY_ELEMENT_END.equals(((XmlToken)child).getTokenType())) {
      flag = true;
      break;
    }
    builder.append(child.getText());
  }

  if (flag) {
    builder.append("></").append(tag.getName()).append('>');
    return XmlElementFactory.getInstance(tag.getProject()).createTagFromText(builder.toString(), XMLLanguage.INSTANCE);
  }
  return tag;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GenerationNode.java

示例6: splitAttribute

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) {
  final ArrayList<Block> result = new ArrayList<Block>(3);
  ASTNode child = node.getFirstChildNode();
  while (child != null) {
    if (child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
        child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace()));
    }
    else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) {
      // Fix for EA-20311:
      // In case of another embedded language create a splittable XML block which can be
      // merged with other language's code blocks.
      createLeafBlocks(child, result);
    }
    else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) {
      result.add(new ReadOnlyBlock(child));
    }
    child = child.getTreeNext();
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XmlBlock.java

示例7: doRenameXmlAttributeValue

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
private static void doRenameXmlAttributeValue(@NotNull XmlAttributeValue value,
                                              String newName,
                                              UsageInfo[] infos,
                                              @Nullable RefactoringElementListener listener)
  throws IncorrectOperationException {
  LOG.assertTrue(value.isValid());

  renameAll(value, infos, newName, value.getValue());

  PsiManager psiManager = value.getManager();
  LOG.assertTrue(psiManager != null);
  XmlFile file = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()).createFileFromText("dummy.xml", XMLLanguage.INSTANCE, "<a attr=\"" + newName + "\"/>");
  @SuppressWarnings("ConstantConditions")
  PsiElement element = value.replace(file.getRootTag().getAttributes()[0].getValueElement());
  if (listener != null) {
    listener.elementRenamed(element);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:RenameXmlAttributeProcessor.java

示例8: checkAutoPopup

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
public Result checkAutoPopup(final char charTyped, final Project project, final Editor editor, final PsiFile file) {
  final boolean isXmlLikeFile = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage;
  boolean spaceInTag = isXmlLikeFile && charTyped == ' ';

  if (spaceInTag) {
    spaceInTag = false;
    final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());

    if (at != null) {
      final PsiElement parent = at.getParent();
      if (parent instanceof XmlTag) {
        spaceInTag = true;
      }
    }
  }

  if ((charTyped == '<' || charTyped == '{' || charTyped == '/' || spaceInTag) && isXmlLikeFile) {
    autoPopupXmlLookup(project, editor);
    return Result.STOP;
  }
  return Result.CONTINUE;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:XmlAutoPopupHandler.java

示例9: isLanguageRelevant

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
private static boolean isLanguageRelevant(final PsiElement element,
                                          final PsiFile file,
                                          final Ref<Boolean> isRelevantLanguage,
                                          final Ref<Boolean> isAnt) {
  Boolean isAntFile = isAnt.get();
  if (isAntFile == null) {
    isAntFile = XmlUtil.isAntFile(file);
    isAnt.set(isAntFile);
  }
  Boolean result = isRelevantLanguage.get();
  if (result == null) {
    Language language = element.getLanguage();
    PsiElement parent = element.getParent();
    if (element instanceof PsiWhiteSpace && parent != null) {
      language = parent.getLanguage();
    }
    result = language instanceof XMLLanguage || isAntFile.booleanValue();
    isRelevantLanguage.set(result);
  }
  return result.booleanValue();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:XmlAutoPopupHandler.java

示例10: beforeCharTyped

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@Override
public Result beforeCharTyped(char c,
                              Project project,
                              Editor editor,
                              PsiFile file,
                              FileType fileType) {
  boolean inXml = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage;
  if (c == '=' && inXml) {
    int offset = editor.getCaretModel().getOffset();
    PsiElement at = file.findElementAt(offset - 1);
    PsiElement atParent = at != null ? at.getParent() : null;
    needToInsertQuotes = atParent instanceof XmlAttribute && ((XmlAttribute)atParent).getValueElement() == null;
  }

  return super.beforeCharTyped(c, project, editor, file, fileType);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:XmlEqTypedHandler.java

示例11: expandEmptyTagIfNeccessary

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@NotNull
private static XmlTag expandEmptyTagIfNeccessary(@NotNull XmlTag tag) {
  StringBuilder builder = new StringBuilder();
  boolean flag = false;

  for (PsiElement child : tag.getChildren()) {
    if (child instanceof XmlToken && XmlTokenType.XML_EMPTY_ELEMENT_END.equals(((XmlToken)child).getTokenType())) {
      flag = true;
      break;
    }
    builder.append(child.getText());
  }

  if (flag) {
    builder.append("></").append(tag.getName()).append('>');
    return XmlElementFactory.getInstance(tag.getProject()).createTagFromText(builder.toString(), XMLLanguage.INSTANCE);
  }
  return tag;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:GenerationNode.java

示例12: initComponent

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@Override
public void initComponent() {
  super.initComponent();
  new PsiTreeChangePreprocessorBase(myPsiManager) {
    @Override
    protected boolean isInsideCodeBlock(PsiElement element) {
      if (element instanceof PsiFileSystemItem) {
        return false;
      }

      if (element == null || element.getParent() == null) return true;

      final boolean isXml = element.getLanguage() instanceof XMLLanguage;
      // any xml element isn't inside a "code block"
      // cause we display even attributes and tag values in structure view
      return !isXml;
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:XmlPsiManager.java

示例13: getElementInfo

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@NotNull
public String getElementInfo(@NotNull final PsiElement e) {
  final XmlTag tag = (XmlTag)e;
  final StringBuffer sb = new StringBuffer();

  sb.append(tag.getName());

  final boolean addHtmlInfo = e.getContainingFile().getLanguage() != XMLLanguage.INSTANCE;

  if (addHtmlInfo) {
    final String id_value = tag.getAttributeValue(ID_ATTRIBUTE_NAME);
    if (null != id_value) {
      sb.append("#").append(id_value);
    }

    final String class_value = tag.getAttributeValue(CLASS_ATTRIBUTE_NAME);
    if (null != class_value) {
      final StringTokenizer tokenizer = new StringTokenizer(class_value, " ");
      while (tokenizer.hasMoreTokens()) {
        sb.append(".").append(tokenizer.nextToken());
      }
    }
  }

  return sb.toString();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:XmlLanguageBreadcrumbsInfoProvider.java

示例14: findInfoProvider

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
@Nullable
public static BreadcrumbsInfoProvider findInfoProvider(@Nullable FileViewProvider viewProvider) {
  BreadcrumbsInfoProvider provider = null;
  if (viewProvider != null) {
    final WebEditorOptions webEditorOptions = WebEditorOptions.getInstance();
    final Language baseLang = viewProvider.getBaseLanguage();
    provider = getInfoProvider(baseLang);
    if (!webEditorOptions.isBreadcrumbsEnabledInXml() && baseLang == XMLLanguage.INSTANCE) return null;
    if (!webEditorOptions.isBreadcrumbsEnabled() && baseLang != XMLLanguage.INSTANCE) return null;
    if (provider == null) {
      for (final Language language : viewProvider.getLanguages()) {
        provider = getInfoProvider(language);
        if (provider != null) {
          break;
        }
      }
    }
  }
  return provider;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:BreadcrumbsXmlWrapper.java

示例15: splitAttribute

import com.intellij.lang.xml.XMLLanguage; //导入依赖的package包/类
private List<Block> splitAttribute(ASTNode node, XmlFormattingPolicy formattingPolicy) {
  final ArrayList<Block> result = new ArrayList<Block>(3);
  ASTNode child = node.getFirstChildNode();
  while (child != null) {
    if (child.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_START_DELIMITER ||
        child.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      result.add(new XmlBlock(child, null, null, formattingPolicy, null, null, isPreserveSpace()));
    }
    else if (!child.getPsi().getLanguage().isKindOf(XMLLanguage.INSTANCE) && containsOuterLanguageElement(child)) {
      // Fix for EA-20311:
      // In case of another embedded language create a splittable XML block which can be
      // merged with other language's code blocks.
      createLeafBlocks(child, result);
    }
    else if (child.getElementType() != TokenType.ERROR_ELEMENT || child.getFirstChildNode() != null) {
      result.add(new ReadOnlyBlock(child));
    }
    child = child.getTreeNext();
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:XmlBlock.java


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