Search in sources :

Example 6 with StructuredFormatPreferencesXML

use of org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML in project webtools.sourceediting by eclipse.

the class FormatTester method testFormatInlineCommentsSplitLinesSplitMultiAttrs.

public void testFormatInlineCommentsSplitLinesSplitMultiAttrs() {
    // get model
    IStructuredModel structuredModel = getModel("inlineComments.xml");
    // init FormatPreferences
    IStructuredFormatPreferences formatPreferences = fFormatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(true);
    formatPreferences.setLineWidth(72);
    formatPreferences.setIndent("\t");
    formatPreferences.setClearAllBlankLines(false);
    // format
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = false;
    fFormatProcessor.formatModel(structuredModel);
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = true;
    // compare
    String formatted = structuredModel.getStructuredDocument().get();
    String expectedFileName = "inlineComments.afterSplitLinesSplitMultiAttrsFormat.xml";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, formatted);
    // release model
    structuredModel.releaseFromRead();
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 7 with StructuredFormatPreferencesXML

use of org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML in project webtools.sourceediting by eclipse.

the class FormatTester method testFormat.

public void testFormat() {
    // get model
    IStructuredModel structuredModel = getModel("small.xml");
    // init FormatPreferences
    IStructuredFormatPreferences formatPreferences = fFormatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(false);
    formatPreferences.setLineWidth(999);
    formatPreferences.setIndent("\t");
    formatPreferences.setClearAllBlankLines(false);
    // format
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = false;
    fFormatProcessor.formatModel(structuredModel);
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = true;
    // compare
    String formatted = structuredModel.getStructuredDocument().get();
    String expectedFileName = "small.afterDefaultFormat.xml";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, formatted);
    // release model
    structuredModel.releaseFromRead();
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 8 with StructuredFormatPreferencesXML

use of org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML in project webtools.sourceediting by eclipse.

the class FormatTester method testFormatOneSpace.

public void testFormatOneSpace() {
    // get model
    IStructuredModel structuredModel = getModel("oneSpace.xml");
    // init FormatPreferences
    IStructuredFormatPreferences formatPreferences = fFormatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(false);
    formatPreferences.setLineWidth(999);
    formatPreferences.setIndent("\t");
    formatPreferences.setClearAllBlankLines(false);
    // format
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = false;
    fFormatProcessor.formatModel(structuredModel);
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = true;
    // compare
    String formatted = structuredModel.getStructuredDocument().get();
    String expectedFileName = "empty.xml";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, formatted);
    // release model
    structuredModel.releaseFromRead();
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 9 with StructuredFormatPreferencesXML

use of org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML in project webtools.sourceediting by eclipse.

the class FormatTester method testFormat261968.

public void testFormat261968() {
    // get model
    IStructuredModel structuredModel = getModel("261968.xml");
    // init FormatPreferences
    IStructuredFormatPreferences formatPreferences = fFormatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(false);
    formatPreferences.setLineWidth(999);
    formatPreferences.setIndent("\t");
    formatPreferences.setClearAllBlankLines(false);
    // format
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = false;
    fFormatProcessor.formatModel(structuredModel);
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = true;
    // compare
    String formatted = structuredModel.getStructuredDocument().get();
    String expectedFileName = "261968.afterDefaultFormat.xml";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, formatted);
    // release model
    structuredModel.releaseFromRead();
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 10 with StructuredFormatPreferencesXML

use of org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML in project webtools.sourceediting by eclipse.

the class FormatTester method testFormatSpaces.

public void testFormatSpaces() {
    // get model
    IStructuredModel structuredModel = getModel("spaces.xml");
    // init FormatPreferences
    IStructuredFormatPreferences formatPreferences = fFormatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(false);
    formatPreferences.setLineWidth(999);
    formatPreferences.setIndent("\t");
    formatPreferences.setClearAllBlankLines(false);
    // format
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = false;
    fFormatProcessor.formatModel(structuredModel);
    ((AbstractStructuredFormatProcessor) fFormatProcessor).refreshFormatPreferences = true;
    // compare
    String formatted = structuredModel.getStructuredDocument().get();
    String expectedFileName = "empty.xml";
    String expected = getFile(expectedFileName);
    compare(expectedFileName, expected, formatted);
    // release model
    structuredModel.releaseFromRead();
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Aggregations

StructuredFormatPreferencesXML (org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML)28 IStructuredFormatPreferences (org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)27 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)17 Preferences (org.eclipse.core.runtime.Preferences)3 Iterator (java.util.Iterator)1 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)1 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1 Attr (org.w3c.dom.Attr)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1