Java Code Examples for com.intellij.openapi.util.JDOMUtil#writeElement()

The following examples show how to use com.intellij.openapi.util.JDOMUtil#writeElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsefulTestCase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected static void checkSettingsEqual(JDOMExternalizable expected, JDOMExternalizable settings, String message) throws Exception {
  if (expected == null) {
    return;
  }
  if (settings == null) {
    return;
  }
  Element oldS = new Element("temp");
  expected.writeExternal(oldS);
  Element newS = new Element("temp");
  settings.writeExternal(newS);

  String newString = JDOMUtil.writeElement(newS, "\n");
  String oldString = JDOMUtil.writeElement(oldS, "\n");
  assertEquals(message, oldString, newString);
}
 
Example 2
Source File: XQueryRunConfigurationSerializer.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
protected ElementWriter getElementWriter() {
    return new ElementWriter() {
        @Override
        public void writeElement(Element element, Writer writer, String lineSeparator) throws IOException {
            JDOMUtil.writeElement(element, writer, lineSeparator);
        }
    };
}
 
Example 3
Source File: DefaultInspectionToolPresentation.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void writeOutput(@Nonnull final CommonProblemDescriptor[] descriptions, @Nonnull RefEntity refElement) {
  final Element parentNode = new Element(InspectionsBundle.message("inspection.problems"));
  exportResults(descriptions, refElement, parentNode);
  final List list = parentNode.getChildren();

  @NonNls final String ext = ".xml";
  final String fileName = ourOutputPath + File.separator + myToolWrapper.getShortName() + ext;
  final PathMacroManager pathMacroManager = PathMacroManager.getInstance(getContext().getProject());
  PrintWriter printWriter = null;
  try {
    new File(ourOutputPath).mkdirs();
    final File file = new File(fileName);
    final CharArrayWriter writer = new CharArrayWriter();
    if (!file.exists()) {
      writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextImpl.LOCAL_TOOL_ATTRIBUTE + "=\"")
              .append(Boolean.toString(myToolWrapper instanceof LocalInspectionToolWrapper)).append("\">\n");
    }
    for (Object o : list) {
      final Element element = (Element)o;
      pathMacroManager.collapsePaths(element);
      JDOMUtil.writeElement(element, writer, "\n");
    }
    printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), "UTF-8")));
    printWriter.append("\n");
    printWriter.append(writer.toString());
  }
  catch (IOException e) {
    LOG.error(e);
  }
  finally {
    if (printWriter != null) {
      printWriter.close();
    }
  }
}
 
Example 4
Source File: PlatformTestUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String printElement(final Element element) throws IOException {
  final StringWriter writer = new StringWriter();
  JDOMUtil.writeElement(element, writer, "\n");
  return writer.getBuffer().toString();
}