Search in sources :

Example 1 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class TestFormatProcessorHTML method testAttributeFormat.

public void testAttributeFormat() throws UnsupportedEncodingException, IOException, CoreException {
    // BUG113584
    IStructuredFormatPreferences formatPreferences = formatProcessor.getFormatPreferences();
    ((StructuredFormatPreferencesXML) formatPreferences).setSplitMultiAttrs(true);
    ((StructuredFormatPreferencesXML) formatPreferences).setAlignEndBracket(true);
    formatAndAssertEquals("testfiles/html/attributesformat.html", "testfiles/html/attributesformat-fmt.html", false);
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)

Example 2 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class HTMLFormatProcessorImpl method getFormatPreferences.

public IStructuredFormatPreferences getFormatPreferences() {
    if (fFormatPreferences == null) {
        fFormatPreferences = new StructuredFormatPreferencesXML();
        Preferences preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
        if (preferences != null) {
            fFormatPreferences.setLineWidth(preferences.getInt(HTMLCorePreferenceNames.LINE_WIDTH));
            ((StructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
            ((StructuredFormatPreferencesXML) fFormatPreferences).setAlignEndBracket(preferences.getBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET));
            fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
            char indentChar = ' ';
            String indentCharPref = preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR);
            if (HTMLCorePreferenceNames.TAB.equals(indentCharPref)) {
                indentChar = '\t';
            }
            int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.INDENTATION_SIZE);
            StringBuffer indent = new StringBuffer();
            for (int i = 0; i < indentationWidth; i++) {
                indent.append(indentChar);
            }
            fFormatPreferences.setIndent(indent.toString());
        }
    }
    return fFormatPreferences;
}
Also used : StructuredFormatPreferencesXML(org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML) IStructuredFormatPreferences(org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences) Preferences(org.eclipse.core.runtime.Preferences)

Example 3 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class FormatTester method testFormatOneChar.

public void testFormatOneChar() {
    // get model
    IStructuredModel structuredModel = getModel("oneChar.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 = "oneChar.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 4 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences in project webtools.sourceediting by eclipse.

the class FormatTester method testFormatInlineComments.

public void testFormatInlineComments() {
    // get model
    IStructuredModel structuredModel = getModel("inlineComments.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 = "inlineComments.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 5 with IStructuredFormatPreferences

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences 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)

Aggregations

IStructuredFormatPreferences (org.eclipse.wst.sse.core.internal.format.IStructuredFormatPreferences)28 StructuredFormatPreferencesXML (org.eclipse.wst.xml.core.internal.provisional.format.StructuredFormatPreferencesXML)26 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)17 Preferences (org.eclipse.core.runtime.Preferences)4