Skip to content

Commit 8999a87

Browse files
angelozerrmickaelistria
authored andcommitted
XML: Closing tags should be included in the code folding range
Fixes #857 Signed-off-by: azerr <[email protected]>
1 parent 802425f commit 8999a87

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLPreferenceConstants.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ public static class LemminxPreference {
3333
*/
3434
public final String lemminxOptionPath;
3535

36-
public LemminxPreference(String preferenceId, String lemminxOptionPath) {
37-
this.preferenceId = preferenceId;
36+
public LemminxPreference(String lemminxOptionPath) {
37+
this.preferenceId = getPreferenceId(lemminxOptionPath);
3838
this.lemminxOptionPath = lemminxOptionPath;
3939
}
40+
41+
private static String getPreferenceId(String lemminxOptionPath) {
42+
return Activator.PLUGIN_ID + "." + lemminxOptionPath.replace("/", ".");
43+
}
4044

4145
public void storeToLemminxOptions(Object value, Map<String, Object> options) {
4246
Map<String, Object> result = options;
@@ -57,15 +61,16 @@ public void storeToLemminxOptions(Object value, Map<String, Object> options) {
5761
}
5862
}
5963

60-
public static final LemminxPreference XML_PREFERENCES_CATAGLOGS = new LemminxPreference(Activator.PLUGIN_ID + ".catalogs", "catalogs");
61-
public static final LemminxPreference XML_PREFERENCES_CODELENS_ENABLED = new LemminxPreference(Activator.PLUGIN_ID + ".codeLens.enabled", "codeLens/enabled");
62-
public static final LemminxPreference XML_PREFERENCES_VALIDATION_ENABLED = new LemminxPreference(Activator.PLUGIN_ID + ".validation.enabled", "validation/enabled");
63-
public static final LemminxPreference XML_PREFERENCES_VALIDATION_NAMESPACES_ENABLED = new LemminxPreference(Activator.PLUGIN_ID + ".validation.namespaces.enabled", "validation/namespaces/enabled");
64-
public static final LemminxPreference XML_PREFERENCES_VALIDATION_SCHEMA_ENABLED = new LemminxPreference(Activator.PLUGIN_ID + ".validation.schema.enabled", "validation/schema/enabled");
65-
public static final LemminxPreference XML_PREFERENCES_VALIDATION_DISALLOW_DOCTYPE_DECL = new LemminxPreference(Activator.PLUGIN_ID + ".validation.disallowDocTypeDecl", "validation/disallowDocTypeDecl");
66-
public static final LemminxPreference XML_PREFERENCES_VALIDATION_RESOLVE_EXTERNAL_ENTITIES = new LemminxPreference(Activator.PLUGIN_ID + ".validation.resolveExternalEntities", "validation/resolveExternalEntities");
67-
public static final LemminxPreference XML_PREFERENCES_VALIDATION_NO_GRAMMAR = new LemminxPreference(Activator.PLUGIN_ID + ".validation.noGrammar", "validation/noGrammar");
68-
64+
public static final LemminxPreference XML_PREFERENCES_CATAGLOGS = new LemminxPreference("catalogs");
65+
public static final LemminxPreference XML_PREFERENCES_CODELENS_ENABLED = new LemminxPreference("codeLens/enabled");
66+
public static final LemminxPreference XML_PREFERENCES_VALIDATION_ENABLED = new LemminxPreference("validation/enabled");
67+
public static final LemminxPreference XML_PREFERENCES_VALIDATION_NAMESPACES_ENABLED = new LemminxPreference("validation/namespaces/enabled");
68+
public static final LemminxPreference XML_PREFERENCES_VALIDATION_SCHEMA_ENABLED = new LemminxPreference("validation/schema/enabled");
69+
public static final LemminxPreference XML_PREFERENCES_VALIDATION_DISALLOW_DOCTYPE_DECL = new LemminxPreference("validation/disallowDocTypeDecl");
70+
public static final LemminxPreference XML_PREFERENCES_VALIDATION_RESOLVE_EXTERNAL_ENTITIES = new LemminxPreference("validation/resolveExternalEntities");
71+
public static final LemminxPreference XML_PREFERENCES_VALIDATION_NO_GRAMMAR = new LemminxPreference("validation/noGrammar");
72+
public static final LemminxPreference XML_PREFERENCES_FOLDING_INCLUDE_CLOSING_TAG_IN_FOLD = new LemminxPreference("foldings/includeClosingTagInFold");
73+
6974
private static final LemminxPreference[] ALL_LEMMINX_PREFERENCES = {
7075
XML_PREFERENCES_CATAGLOGS,
7176
XML_PREFERENCES_CODELENS_ENABLED,
@@ -74,7 +79,8 @@ public void storeToLemminxOptions(Object value, Map<String, Object> options) {
7479
XML_PREFERENCES_VALIDATION_SCHEMA_ENABLED,
7580
XML_PREFERENCES_VALIDATION_DISALLOW_DOCTYPE_DECL,
7681
XML_PREFERENCES_VALIDATION_RESOLVE_EXTERNAL_ENTITIES,
77-
XML_PREFERENCES_VALIDATION_NO_GRAMMAR
82+
XML_PREFERENCES_VALIDATION_NO_GRAMMAR,
83+
XML_PREFERENCES_FOLDING_INCLUDE_CLOSING_TAG_IN_FOLD
7884
};
7985

8086
public static Optional<LemminxPreference> getLemminxPreference(PropertyChangeEvent event) {
@@ -100,5 +106,6 @@ public static void storePreferencesToLemminxOptions(IPreferenceStore store, Map<
100106
store.getBoolean(XML_PREFERENCES_VALIDATION_RESOLVE_EXTERNAL_ENTITIES.preferenceId), xmlOpts);
101107
XML_PREFERENCES_VALIDATION_NO_GRAMMAR.storeToLemminxOptions(store.getString(XML_PREFERENCES_VALIDATION_NO_GRAMMAR.preferenceId),
102108
xmlOpts);
109+
XML_PREFERENCES_FOLDING_INCLUDE_CLOSING_TAG_IN_FOLD.storeToLemminxOptions(store.getBoolean(XML_PREFERENCES_FOLDING_INCLUDE_CLOSING_TAG_IN_FOLD.preferenceId), xmlOpts);
103110
}
104111
}

org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLPreferenceInitializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import static org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.XML_PREFERENCES_CATAGLOGS;
1515
import static org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.XML_PREFERENCES_CODELENS_ENABLED;
16+
import static org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.XML_PREFERENCES_FOLDING_INCLUDE_CLOSING_TAG_IN_FOLD;
1617
import static org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.XML_PREFERENCES_VALIDATION_DISALLOW_DOCTYPE_DECL;
1718
import static org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.XML_PREFERENCES_VALIDATION_ENABLED;
1819
import static org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceConstants.XML_PREFERENCES_VALIDATION_NAMESPACES_ENABLED;
@@ -37,6 +38,7 @@ public void initializeDefaultPreferences() {
3738
STORE.setDefault(XML_PREFERENCES_VALIDATION_DISALLOW_DOCTYPE_DECL.preferenceId, false);
3839
STORE.setDefault(XML_PREFERENCES_VALIDATION_RESOLVE_EXTERNAL_ENTITIES.preferenceId, false);
3940
STORE.setDefault(XML_PREFERENCES_VALIDATION_NO_GRAMMAR.preferenceId, "hint");
41+
STORE.setDefault(XML_PREFERENCES_FOLDING_INCLUDE_CLOSING_TAG_IN_FOLD.preferenceId, true);
4042
}
4143

4244
}

0 commit comments

Comments
 (0)