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

Java XmlProlog类代码示例

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

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



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

示例1: registerPageLanguage

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
public void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) {
  new WriteCommandAction.Simple(project, getFamilyName()) {
    @Override
    protected void run() {
      final PsiFileFactory factory = PsiFileFactory.getInstance(project);
      final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", StdFileTypes.XML,
                                                                    "<?language " + languageName + "?>");
      final XmlDocument document = dummyFile.getDocument();
      if (document != null) {
        final XmlProlog prolog = document.getProlog();
        final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
        LOG.assertTrue(instructions.size() == 1);
        final XmlDocument xmlDocument = containingFile.getDocument();
        if (xmlDocument != null) {
          final XmlProlog xmlProlog = xmlDocument.getProlog();
          if (xmlProlog != null) {
            final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild());
            xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element);
          }
        }
      }
    }
  }.execute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaFxInjectPageLanguageIntention.java


示例2: registerPageLanguage

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) {
  new WriteCommandAction.Simple(project, getFamilyName()) {
    @Override
    protected void run() {
      final PsiFileFactory factory = PsiFileFactory.getInstance(project);
      final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", StdFileTypes.XML,
                                                                    "<?language " + languageName + "?>");
      final XmlDocument document = dummyFile.getDocument();
      if (document != null) {
        final XmlProlog prolog = document.getProlog();
        final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
        LOG.assertTrue(instructions.size() == 1);
        final XmlDocument xmlDocument = containingFile.getDocument();
        if (xmlDocument != null) {
          final XmlProlog xmlProlog = xmlDocument.getProlog();
          if (xmlProlog != null) {
            final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild());
            xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element);
          }
        }
      }
    }
  }.execute();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:JavaFxInjectPageLanguageIntention.java


示例3: registerPageLanguage

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) {
  new WriteCommandAction.Simple(project, getFamilyName()) {
    @Override
    protected void run() {
      final PsiFileFactory factory = PsiFileFactory.getInstance(project);
      final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", XmlFileType.INSTANCE,
                                                                    "<?language " + languageName + "?>");
      final XmlDocument document = dummyFile.getDocument();
      if (document != null) {
        final XmlProlog prolog = document.getProlog();
        final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
        LOG.assertTrue(instructions.size() == 1);
        final XmlDocument xmlDocument = containingFile.getDocument();
        if (xmlDocument != null) {
          final XmlProlog xmlProlog = xmlDocument.getProlog();
          if (xmlProlog != null) {
            final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild());
            xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element);
          }
        }
      }
    }
  }.execute();
}
 
开发者ID:consulo,项目名称:consulo-javafx,代码行数:25,代码来源:JavaFxInjectPageLanguageIntention.java


示例4: parseInstructions

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private static List<String> parseInstructions(XmlFile file, String instructionName) {
  List<String> definedImports = new ArrayList<String>();
  XmlDocument document = file.getDocument();
  if (document != null) {
    XmlProlog prolog = document.getProlog();

    final Collection<XmlProcessingInstruction>
      instructions = new ArrayList<XmlProcessingInstruction>(PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class));
    for (final XmlProcessingInstruction instruction : instructions) {
      final String instructionTarget = getInstructionTarget(instructionName, instruction);
      if (instructionTarget != null) {
        definedImports.add(instructionTarget);
      }
    }
  }
  return definedImports;
}
 
开发者ID:consulo,项目名称:consulo-javafx,代码行数:18,代码来源:JavaFxPsiUtil.java


示例5: insertImportWhenNeeded

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
public static void insertImportWhenNeeded(XmlFile xmlFile,
                                          String shortName,
                                          String qualifiedName) {
  if (shortName != null && findPsiClass(shortName, xmlFile.getRootTag()) == null) {
    final XmlDocument document = xmlFile.getDocument();
    if (document != null) {
      final XmlProcessingInstruction processingInstruction = createSingleImportInstruction(qualifiedName, xmlFile.getProject());
      final XmlProlog prolog = document.getProlog();
      if (prolog != null) {
        prolog.add(processingInstruction);
      } else {
        document.addBefore(processingInstruction, document.getRootTag());
      }
      PostprocessReformattingAspect.getInstance(xmlFile.getProject()).doPostponedFormatting(xmlFile.getViewProvider());
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-javafx,代码行数:18,代码来源:JavaFxPsiUtil.java


示例6: is23

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private static boolean is23(final ConvertContext context) {
  final DomElement element = DomUtil.getFileElement(context.getInvocationElement()).getRootElement();
  final XmlTag tag = element.getXmlTag();
  if (tag != null && "web-app".equals(element.getXmlElementName()) && tag.getAttribute("version") == null) {
    XmlDocument document = (XmlDocument)tag.getParent();
    final XmlProlog prolog = document.getProlog();
    if (prolog != null) {
      final XmlDoctype doctype = prolog.getDoctype();
      if (doctype != null) {
        final String uri = doctype.getDtdUri();
        if (uri != null && uri.contains("2_3")) return true;
      }
    }
    return false;
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:18,代码来源:ResAuthConverter.java


示例7: invoke

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
    final XmlTag anchor = getAnchor(element);
    if (anchor == null) return;

    PsiElement prevSibling = anchor.getPrevSibling();
    while (prevSibling instanceof PsiWhiteSpace || prevSibling instanceof XmlText) {
        prevSibling = prevSibling.getPrevSibling();
    }
    if (prevSibling instanceof XmlProlog) {
        prevSibling = prevSibling.getLastChild();
        if (prevSibling != null && !(prevSibling instanceof XmlComment)) {
            prevSibling = PsiTreeUtil.getPrevSiblingOfType(prevSibling, XmlComment.class);
        }
    }
    if (prevSibling instanceof XmlComment) {
        final XmlComment comment = (XmlComment)prevSibling;
        final String text = XmlUtil.getCommentText(comment);
        if (text != null && InspectionUtil.SUPPRESSION_PATTERN.matcher(text).matches()) {
            final String s = text.trim() + ", " + myToolId;
            final XmlComment newComment = createComment(project, s);
          CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(comment.replace(newComment));
        } else {
            addNoinspectionComment(project, anchor);
        }
    } else {
        addNoinspectionComment(project, anchor);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:SuppressInspectionAction.java


示例8: addNoinspectionComment

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private void addNoinspectionComment(Project project, XmlTag anchor) throws IncorrectOperationException {
    final XmlComment newComment = createComment(project, "noinspection " + myToolId);
    PsiElement parent = anchor.getParentTag();
    if (parent == null) {
        parent = PsiTreeUtil.getPrevSiblingOfType(anchor, XmlProlog.class);
        if (parent != null) {
          CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(parent.add(newComment));
        }
    } else {
      CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(parent.addBefore(newComment, anchor));
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:SuppressInspectionAction.java


示例9: getHandler

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@NotNull
protected CodeInsightActionHandler getHandler(){
  return new CodeInsightActionHandler(){
    public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
      final XmlDocument document = findSuitableXmlDocument(file);
      if (document != null) {
        final @NonNls StringBuffer buffer = new StringBuffer();
        buffer.append("<!DOCTYPE " + document.getRootTag().getName() + " [\n");
        buffer.append(XmlUtil.generateDocumentDTD(document, true));
        buffer.append("]>\n");
        XmlFile tempFile;
          try{
            final XmlProlog prolog = document.getProlog();
            final PsiElement childOfType = PsiTreeUtil.getChildOfType(prolog, XmlProcessingInstruction.class);
            if (childOfType != null) {
              final String text = childOfType.getText();
              buffer.insert(0,text);
              final PsiElement nextSibling = childOfType.getNextSibling();
              if (nextSibling instanceof PsiWhiteSpace) {
                buffer.insert(text.length(),nextSibling.getText());
              }
            }
            tempFile = (XmlFile)PsiFileFactory.getInstance(file.getProject()).createFileFromText("dummy.xml", buffer.toString());
            prolog.replace(tempFile.getDocument().getProlog());
          }
        catch (IncorrectOperationException e) {
          LOG.error(e);
        }
      }
    }

    public boolean startInWriteAction(){
      return true;
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:GenerateDTDAction.java


示例10: invoke

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
  final XmlTag anchor = getAnchor(element);
  if (anchor == null) return;

  PsiElement prevSibling = anchor.getPrevSibling();
  while (prevSibling instanceof PsiWhiteSpace || prevSibling instanceof XmlText) {
    prevSibling = prevSibling.getPrevSibling();
  }
  if (prevSibling instanceof XmlProlog) {
    prevSibling = prevSibling.getLastChild();
    if (prevSibling != null && !(prevSibling instanceof XmlComment)) {
      prevSibling = PsiTreeUtil.getPrevSiblingOfType(prevSibling, XmlComment.class);
    }
  }
  if (prevSibling instanceof XmlComment) {
    final XmlComment comment = (XmlComment)prevSibling;
    final String text = XmlUtil.getCommentText(comment);
    if (text != null && InspectionUtil.SUPPRESSION_PATTERN.matcher(text).matches()) {
      final String s = text.trim() + ", " + myToolId;
      final XmlComment newComment = createComment(project, s);
      CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(comment.replace(newComment));
    } else {
      addNoinspectionComment(project, anchor);
    }
  } else {
    addNoinspectionComment(project, anchor);
  }
}
 
开发者ID:consulo,项目名称:consulo-xslt,代码行数:29,代码来源:SuppressInspectionAction.java


示例11: addNoinspectionComment

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private void addNoinspectionComment(Project project, XmlTag anchor) throws IncorrectOperationException {
  final XmlComment newComment = createComment(project, "noinspection " + myToolId);
  PsiElement parent = anchor.getParentTag();
  if (parent == null) {
    parent = PsiTreeUtil.getPrevSiblingOfType(anchor, XmlProlog.class);
    if (parent != null) {
      CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(parent.add(newComment));
    }
  } else {
    CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(parent.addBefore(newComment, anchor));
  }
}
 
开发者ID:consulo,项目名称:consulo-xslt,代码行数:13,代码来源:SuppressInspectionAction.java


示例12: hasDtdDeclaration

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
private boolean hasDtdDeclaration() {
  XmlDocument document = myFile.getDocument();
  if (document == null) return false;
  XmlProlog prolog = document.getProlog();
  if (prolog == null) return false;
  XmlDoctype doctype = prolog.getDoctype();
  if (doctype == null) return false;

  return true;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:11,代码来源:ValidateXmlActionHandler.java


示例13: hasNonHtml5Doctype

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
public static boolean hasNonHtml5Doctype(XmlElement context)
{
	XmlDocument doc = PsiTreeUtil.getParentOfType(context, XmlDocument.class);
	if(doc == null)
	{
		return false;
	}
	XmlProlog prolog = doc.getProlog();
	XmlDoctype doctype = prolog != null ? prolog.getDoctype() : null;
	return doctype != null && !isHtml5Doctype(doctype);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:12,代码来源:HtmlUtil.java


示例14: getRootElementsDescriptors

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@Override
@NotNull
public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable final XmlDocument document)
{
	// Suggest more appropriate variant if DOCTYPE <element_name> exists
	final XmlProlog prolog = document != null ? document.getProlog() : null;

	if(prolog != null)
	{
		final XmlDoctype doctype = prolog.getDoctype();

		if(doctype != null)
		{
			final XmlElement element = doctype.getNameElement();

			if(element != null)
			{
				final XmlElementDescriptor descriptor = getElementDescriptor(element.getText());

				if(descriptor != null)
				{
					return new XmlElementDescriptor[]{descriptor};
				}
			}
		}
	}

	return getElements();
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:30,代码来源:XmlNSDescriptorImpl.java


示例15: getChildrenBase

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
  final XmlDocument document = getElement().getDocument();
  List<XmlTag> rootTags = new ArrayList<XmlTag>();
  if (document != null) {
    for (PsiElement element : document.getChildren())
      if (element instanceof XmlTag) rootTags.add((XmlTag)element);
  }

  Collection<StructureViewTreeElement> structureViewTreeElements =
    AbstractXmlTagTreeElement.getStructureViewTreeElements(rootTags.toArray(new XmlTag[rootTags.size()]));

  Collection<StructureViewTreeElement> dtdStructureViewTreeElements = null;
  final XmlProlog prolog = document != null ? document.getProlog():null;
  if (prolog != null) {
    final XmlDoctype doctype = prolog.getDoctype();

    if (doctype != null) {
      final XmlMarkupDecl xmlMarkupDecl = doctype.getMarkupDecl();
      if (xmlMarkupDecl != null) {
        dtdStructureViewTreeElements = DtdFileTreeElement.collectElements(xmlMarkupDecl);
      }
    }
  }

  if (dtdStructureViewTreeElements != null) {
    final ArrayList<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(
      dtdStructureViewTreeElements.size() + structureViewTreeElements.size()
    );

    result.addAll(dtdStructureViewTreeElements);
    result.addAll(structureViewTreeElements);
    structureViewTreeElements = result;
  }
  return structureViewTreeElements;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:37,代码来源:XmlFileTreeElement.java


示例16: getPreviousSibling

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@Override
protected PsiElement getPreviousSibling(PsiElement element)
{
	if(element == null)
	{
		return null;
	}

	PsiElement res = element.getPrevSibling();
	if(res != null)
	{
		if(res instanceof XmlProlog)
		{
			XmlProlog prolog = (XmlProlog) res;
			if(prolog.getChildren().length > 0)
			{
				res = prolog.getLastChild();
			}
			else
			{
				res = prolog.getPrevSibling();
			}
		}
	}
	else
	{
		if(element.getParent() instanceof XmlProlog)
		{
			res = element.getParent().getPrevSibling();
		}
	}

	return res;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:35,代码来源:UpdateXmlCopyrightsProvider.java


示例17: getNextSibling

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@Override
protected PsiElement getNextSibling(PsiElement element)
{
	if(element == null)
	{
		return null;
	}

	PsiElement res = element instanceof XmlProlog ? element : element.getNextSibling();
	if(res != null)
	{
		if(res instanceof XmlProlog)
		{
			XmlProlog prolog = (XmlProlog) res;
			if(prolog.getChildren().length > 0)
			{
				res = prolog.getFirstChild();
			}
			else
			{
				res = prolog.getNextSibling();
			}
		}
	}
	else
	{
		if(element.getParent() instanceof XmlProlog)
		{
			res = element.getParent().getNextSibling();
		}
	}

	return res;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:35,代码来源:UpdateXmlCopyrightsProvider.java


示例18: getProlog

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@Override
public XmlProlog getProlog() {
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:RncDocument.java


示例19: getProlog

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
public XmlProlog getProlog() {
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:RncDocument.java


示例20: processFile

import com.intellij.psi.xml.XmlProlog; //导入依赖的package包/类
@NotNull
@Override
public Runnable processFile(final PsiFile file) {
  VirtualFile vFile = file.getVirtualFile();
  if (vFile instanceof VirtualFileWindow) vFile = ((VirtualFileWindow)vFile).getDelegate();
  final Project project = file.getProject();
  if (vFile == null || !ProjectRootManager.getInstance(project).getFileIndex().isInSourceContent(vFile)) {
    return EmptyRunnable.INSTANCE;
  }
  final List<Pair<String, Boolean>> names = new ArrayList<Pair<String, Boolean>>();
  collectNamesToImport(names, (XmlFile)file);
  Collections.sort(names, new Comparator<Pair<String, Boolean>>() {
    @Override
    public int compare(Pair<String, Boolean> o1, Pair<String, Boolean> o2) {
      return StringUtil.compare(o1.first, o2.first, true);
    }
  });
  final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
  final List<Pair<String, Boolean>> sortedNames = ImportHelper.sortItemsAccordingToSettings(names, settings);
  final HashSet<String> onDemand = new HashSet<String>();
  ImportHelper.collectOnDemandImports(sortedNames, onDemand, settings);
  final Set<String> imported = new HashSet<String>();
  final List<String> imports = new ArrayList<String>();
  for (Pair<String, Boolean> pair : sortedNames) {
    final String qName = pair.first;
    final String packageName = StringUtil.getPackageName(qName);
    if (imported.contains(packageName) || imported.contains(qName)) {
      continue;
    }
    if (onDemand.contains(packageName)) {
      imported.add(packageName);
      imports.add("<?import " + packageName + ".*?>");
    } else {
      imported.add(qName);
      imports.add("<?import " + qName + "?>");
    }
  }
  final PsiFileFactory factory = PsiFileFactory.getInstance(file.getProject());
  
  final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", XmlFileType.INSTANCE, StringUtil.join(imports, "\n"));
  final XmlDocument document = dummyFile.getDocument();
  final XmlProlog newImportList = document.getProlog();
  if (newImportList == null) return EmptyRunnable.getInstance();
  return new Runnable() {
    @Override
    public void run() {
      final XmlDocument xmlDocument = ((XmlFile)file).getDocument();
      final XmlProlog prolog = xmlDocument.getProlog();
      if (prolog != null) {
        final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
        for (final XmlProcessingInstruction instruction : instructions) {
          final ASTNode node = instruction.getNode();
          final ASTNode nameNode = node.findChildByType(XmlTokenType.XML_NAME);
          if (nameNode != null && nameNode.getText().equals("import")) {
            instruction.delete();
          }
        }
        prolog.add(newImportList);
      } else {
        document.addBefore(newImportList, document.getRootTag());
      }
    }
  };
}
 
开发者ID:consulo,项目名称:consulo-javafx,代码行数:65,代码来源:JavaFxImportsOptimizer.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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