33
33
import org .jetbrains .annotations .NotNull ;
34
34
35
35
/**
36
- * Validate JSonPath expression and annotated the specific jsonpath expression to highlight the error in the editor
36
+ * Validate language expression such as JSonPath/JQ to highlight the error in the editor
37
37
*/
38
- public class CamelJSonPathAnnotator extends AbstractCamelAnnotator {
38
+ public class CamelLanguageAnnotator extends AbstractCamelAnnotator {
39
39
40
40
private static final Logger LOG = Logger .getInstance (CamelEndpointAnnotator .class );
41
41
@@ -45,29 +45,27 @@ boolean isEnabled() {
45
45
}
46
46
47
47
/**
48
- * Validate jsonpath expression. eg jsonpath("$.store.book[?(@.price < 10)]")
48
+ * Validate language expression, such as jsonpath("$.store.book[?(@.price < 10)]")
49
49
* if the expression is not valid an error annotation is created and highlight the invalid value.
50
50
*/
51
51
void validateText (@ NotNull PsiElement element , @ NotNull AnnotationHolder holder , @ NotNull String text ) {
52
-
53
52
final CamelIdeaUtils camelIdeaUtils = CamelIdeaUtils .getService ();
54
- // only validate if the element is jsonpath element
53
+
55
54
boolean json = CamelPreferenceService .getService ().isRealTimeJSonPathValidation () && camelIdeaUtils .isCamelExpression (element , "jsonpath" );
56
55
boolean jq = CamelPreferenceService .getService ().isRealTimeJQValidation () && camelIdeaUtils .isCamelExpression (element , "jq" );
57
56
if (json || jq ) {
58
57
Project project = element .getProject ();
59
58
CamelCatalog catalogService = project .getService (CamelCatalogService .class ).get ();
60
59
CamelService camelService = project .getService (CamelService .class );
61
60
62
- // must have camel-json library
61
+ // must have the supporting library
63
62
String lib = json ? "camel-jsonpath" : "camel-jq" ;
64
- String lan = json ? "jsonpath" : "jq" ;
65
- boolean jsonLib = camelService .containsLibrary (lib , false );
66
- if (!jsonLib ) {
67
- camelService .showMissingJSonPathJarNotification (lib );
63
+ if (!camelService .containsLibrary (lib , false )) {
64
+ camelService .showMissingLanguageJarNotification (lib );
68
65
return ;
69
66
}
70
67
68
+ String lan = json ? "jsonpath" : "jq" ;
71
69
try {
72
70
// need to use the classloader that can load classes from the project
73
71
ClassLoader loader = camelService .getProjectClassloader ();
0 commit comments