本文整理汇总了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);
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
};
}
示例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();
}
示例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;
}
示例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;
}