Highlight lines with syntax errors
This commit is contained in:
parent
e720d57ec0
commit
21977a601d
|
@ -2,7 +2,8 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const CM_END = {type: '', suggest: '\n', then: {}};
|
const CM_END = {type: '', suggest: '\n', then: {}};
|
||||||
const CM_ERROR = {type: 'error', then: {'': 0}};
|
const CM_HIDDEN_END = {type: '', then: {}};
|
||||||
|
const CM_ERROR = {type: 'error line-error', then: {'': 0}};
|
||||||
|
|
||||||
function makeCMCommaBlock(type, suggest, exits = {}) {
|
function makeCMCommaBlock(type, suggest, exits = {}) {
|
||||||
return {type, suggest, then: Object.assign({
|
return {type, suggest, then: Object.assign({
|
||||||
|
@ -22,11 +23,18 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
});
|
});
|
||||||
const CM_AGENT_TO_OPTTEXT = {type: 'variable', suggest: 'Agent', then: {
|
const CM_AGENT_TO_OPTTEXT = {type: 'variable', suggest: 'Agent', then: {
|
||||||
'': 0,
|
'': 0,
|
||||||
':': {type: 'operator', suggest: true, then: {'': CM_TEXT_TO_END}},
|
':': {type: 'operator', suggest: true, then: {
|
||||||
|
'': CM_TEXT_TO_END,
|
||||||
|
'\n': CM_HIDDEN_END,
|
||||||
|
}},
|
||||||
'\n': CM_END,
|
'\n': CM_END,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const CM_NOTE_SIDE_THEN = {
|
function makeCMSideNote(side) {
|
||||||
|
return {
|
||||||
|
type: 'keyword',
|
||||||
|
suggest: [side + ' of ', side + ': '],
|
||||||
|
then: {
|
||||||
'of': {type: 'keyword', suggest: true, then: {
|
'of': {type: 'keyword', suggest: true, then: {
|
||||||
'': CM_AGENT_LIST_TO_TEXT,
|
'': CM_AGENT_LIST_TO_TEXT,
|
||||||
}},
|
}},
|
||||||
|
@ -34,13 +42,7 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
'': CM_TEXT_TO_END,
|
'': CM_TEXT_TO_END,
|
||||||
}},
|
}},
|
||||||
'': CM_AGENT_LIST_TO_TEXT,
|
'': CM_AGENT_LIST_TO_TEXT,
|
||||||
};
|
},
|
||||||
|
|
||||||
function makeCMSideNote(side) {
|
|
||||||
return {
|
|
||||||
type: 'keyword',
|
|
||||||
suggest: [side + ' of ', side + ': '],
|
|
||||||
then: CM_NOTE_SIDE_THEN,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
'': 0,
|
'': 0,
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const CM_COMMANDS = {type: 'error', then: {
|
const CM_COMMANDS = {type: 'error line-error', then: {
|
||||||
'title': {type: 'keyword', suggest: true, then: {
|
'title': {type: 'keyword', suggest: true, then: {
|
||||||
'': CM_TEXT_TO_END,
|
'': CM_TEXT_TO_END,
|
||||||
}},
|
}},
|
||||||
|
@ -231,6 +233,10 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
updateSuggestion(state, suggestions, '', {});
|
updateSuggestion(state, suggestions, '', {});
|
||||||
}
|
}
|
||||||
state.nextCompletions = cmMakeCompletions(state, path);
|
state.nextCompletions = cmMakeCompletions(state, path);
|
||||||
|
state.valid = (
|
||||||
|
Boolean(current.then['\n']) ||
|
||||||
|
Object.keys(current.then).length === 0
|
||||||
|
);
|
||||||
return current.type;
|
return current.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +264,7 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
beginCompletions: cmMakeCompletions({}, [CM_COMMANDS]),
|
beginCompletions: cmMakeCompletions({}, [CM_COMMANDS]),
|
||||||
completions: [],
|
completions: [],
|
||||||
nextCompletions: [],
|
nextCompletions: [],
|
||||||
|
valid: true,
|
||||||
line: [],
|
line: [],
|
||||||
indent: 0,
|
indent: 0,
|
||||||
};
|
};
|
||||||
|
@ -336,10 +343,14 @@ define(['core/ArrayUtilities'], (array) => {
|
||||||
if(stream.sol() && state.currentType === -1) {
|
if(stream.sol() && state.currentType === -1) {
|
||||||
state.line.length = 0;
|
state.line.length = 0;
|
||||||
}
|
}
|
||||||
|
let type = '';
|
||||||
if(state.currentType !== -1 || this._tokenBegin(stream, state)) {
|
if(state.currentType !== -1 || this._tokenBegin(stream, state)) {
|
||||||
return this._tokenEnd(stream, state);
|
type = this._tokenEnd(stream, state);
|
||||||
|
}
|
||||||
|
if(state.currentType === -1 && stream.eol() && !state.valid) {
|
||||||
|
return 'line-error ' + type;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,10 @@ html, body {
|
||||||
background: #EEEEEE;
|
background: #EEEEEE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.CodeMirror-line.error {
|
||||||
|
background: rgba(255, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
.cm-s-default .cm-keyword {color: #0055CC;}
|
.cm-s-default .cm-keyword {color: #0055CC;}
|
||||||
.cm-s-default .cm-variable {color: #AA5500;}
|
.cm-s-default .cm-variable {color: #AA5500;}
|
||||||
.cm-s-default .cm-operator {color: #0055CC;}
|
.cm-s-default .cm-operator {color: #0055CC;}
|
||||||
|
@ -25,7 +29,7 @@ html, body {
|
||||||
.cm-s-default .cm-error {color: #FF0000;}
|
.cm-s-default .cm-error {color: #FF0000;}
|
||||||
|
|
||||||
.cm-s-default .cm-trailingspace {
|
.cm-s-default .cm-trailingspace {
|
||||||
background: rgba(255, 0, 0, 0.5);
|
background: rgba(255, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pick-virtual {
|
.pick-virtual {
|
||||||
|
|
Loading…
Reference in New Issue