Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,14 @@ private static String removeTrailingCommas(final String jsonString) {
return null;
}

// ex: {"lineComment": "//","blockComment": [ "/*", "*/" ]}
final var jsonObj = json.getAsJsonObject();
final var lineComment = getAsString(jsonObj.get("lineComment")); //$NON-NLS-1$
final var lineCommentElem = jsonObj.get("lineComment"); //$NON-NLS-1$
// VS Code also permits {"comment":"#","noIndent":true} here.
// TM4E always inserts line comments at the start of the line, so noIndent
// currently has no effect and is intentionally ignored.
final var lineComment = lineCommentElem != null && lineCommentElem.isJsonObject()
? getAsString(lineCommentElem.getAsJsonObject().get("comment")) //$NON-NLS-1$
: getAsString(lineCommentElem);
final var blockCommentElem = jsonObj.get("blockComment"); //$NON-NLS-1$
CharacterPair blockComment = null;
if (blockCommentElem != null && blockCommentElem.isJsonArray()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ void testCanLoadRustLanguageConfig() throws Exception {
assertThat(languageConfiguration.getFolding()).isNull();
}

@Test
void testCanLoadObjectLineComment() {
final var languageConfiguration = loadLanguageConfigFromString("""
{
"comments": {
"lineComment": {
"comment": "#",
"noIndent": true
}
}
}""");

assertThat(castNonNull(languageConfiguration.getComments()).lineComment).isEqualTo("#");
}

@Test
void testLanguagePackLangConfigs() throws IOException {
final var count = new AtomicInteger();
Expand Down