-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#26] add missing contentTypeBindings
The org.eclipse.tm4e.language_pack plug-in adds content types for C/C++ files. These content types needs to be considered during filtering This is a fix for eclipse-tm4e/tm4e#499
- Loading branch information
1 parent
1f3aa8c
commit b4f87cf
Showing
6 changed files
with
210 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
bundles/org.eclipse.cdt.lsp.test/src/org/eclipse/cdt/lsp/test/LspUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.eclipse.cdt.lsp.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.eclipse.cdt.core.CCorePlugin; | ||
import org.eclipse.cdt.lsp.LspUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class LspUtilsTest { | ||
|
||
@Test | ||
void testIsCContentType_EmptyId() { | ||
assertTrue(!LspUtils.isCContentType("")); | ||
} | ||
|
||
@Test | ||
void testIsCContentType_CppContentTypeFromTM4E() { | ||
assertTrue(LspUtils.isCContentType("lng.cpp")); | ||
} | ||
|
||
@Test | ||
void testIsCContentType_CONTENT_TYPE_CSOURCE() { | ||
assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CSOURCE)); | ||
} | ||
|
||
@Test | ||
void testIsCContentType_CONTENT_TYPE_CHEADER() { | ||
assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CHEADER)); | ||
} | ||
|
||
@Test | ||
void testIsCContentType_CONTENT_TYPE_CXXSOURCE() { | ||
assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE)); | ||
} | ||
|
||
@Test | ||
void testIsCContentType_CONTENT_TYPE_CXXHEADER() { | ||
assertTrue(LspUtils.isCContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
bundles/org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/LspUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.eclipse.cdt.lsp; | ||
|
||
public class LspUtils { | ||
|
||
/** | ||
* Checks if given ContentType id matches the content types for C/C++ files. | ||
* | ||
* @param id ContentType id | ||
* @return {@code true} if C/C++ content type | ||
*/ | ||
public static boolean isCContentType(String id) { | ||
// TODO: The content type definition from TM4E "lng.cpp" can be omitted if either https://github.com/eclipse-cdt/cdt/pull/310 or | ||
// https://github.com/eclipse/tm4e/pull/500 has been merged. | ||
return ( id.startsWith("org.eclipse.cdt.core.c") && (id.endsWith("Source") || id.endsWith("Header")) ) || "lng.cpp".equals(id); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters