I am using Mvel expression language in CodeMirror for my web project. As know CodeMirror is not providing lint supports for MVEL language. However I am able to validate my MVEL text from a ajax call, in response of ajax, contains success and error both callbacks, and good thing is in error callback, i have err.code , err.line, err.column and err.message.
I am trying to set CodeMirror gutter but its not working. The below is code
Code Mirror editor code
const codemirrorEditor = CodeMirror.fromTextArea(document.getElementById('codearea'), {
lineNumbers: true,
mode: "application/text",
theme: "base16-dark",
extraKeys: {"Ctrl-Space": "autocomplete"},
matchBrackets: true,
gutters: ["CodeMirror-lint-markers"],
lint: true,
autoCloseBrackets: true,
autoCloseTags: true
}
});
Highlight the error
function highlightError(errors) {
codemirrorEditor.clearGutter(‘gutter-error’);
for(var i=0;i<errors.length;i++) {
var error = errors[i];
var errorLine = error['line'] - 1;
var marker = document.createElement("div");
marker.setAttribute('class', 'CodeMirror-lint-marker-error');
marker.setAttribute('data-toggle', 'tooltip');
marker.setAttribute('data-placement', 'right');
marker.setAttribute('title', '(Error '+ error['code'] +') '+ error['message']);
codemirrorEditor.setGutterMarker(errorLine,'gutter-error',marker);
}
$('[data-toggle="tooltip"]').tooltip();
}
Scripts are below
<script src= "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.min.css">
<script src= "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/mode/javascript/javascript.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/cm/addon/hint/show-hint.css">
<script src="${pageContext.request.contextPath}/resources/cm/addon/hint/show-hint.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/addon/hint/anyword-hint.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/mode/javascript/javascript.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/mode/markdown/markdown.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/cm/addon/lint/lint.css">
<script src="${pageContext.request.contextPath}/resources/cm/mode/javascript/javascript.js"></script>
<script src="https://unpkg.com/jshint@2.9.6/dist/jshint.js"></script>
<script src="https://unpkg.com/jsonlint@1.6.3/web/jsonlint.js"></script>
<script src="https://unpkg.com/csslint@1.0.5/dist/csslint.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/addon/lint/lint.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/addon/lint/javascript-lint.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/addon/lint/json-lint.js"></script>
<script src="${pageContext.request.contextPath}/resources/cm/addon/lint/css-lint.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/cm/addon/lint/lint.css">
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"></script>
<script type="text/javascript">
But still gutters are not working and also giving error $(’[data-toggle=“tooltip”]’).tooltip(); on tooltip not found.
Thanks in advance.