Merge branch 'zrispo-feature-runtime-error-highlight'
This commit is contained in:
commit
5de876e202
6 changed files with 82 additions and 16 deletions
|
@ -126,4 +126,7 @@ export const CLEAR_PERSISTED_STATE = 'CLEAR_PERSISTED_STATE';
|
||||||
|
|
||||||
export const SHOW_HELP_MODAL = 'SHOW_HELP_MODAL';
|
export const SHOW_HELP_MODAL = 'SHOW_HELP_MODAL';
|
||||||
export const HIDE_HELP_MODAL = 'HIDE_HELP_MODAL';
|
export const HIDE_HELP_MODAL = 'HIDE_HELP_MODAL';
|
||||||
|
|
||||||
|
export const HIDE_RUNTIME_ERROR_WARNING = 'HIDE_RUNTIME_ERROR_WARNING';
|
||||||
|
export const SHOW_RUNTIME_ERROR_WARNING = 'SHOW_RUNTIME_ERROR_WARNING';
|
||||||
export const SET_ASSETS = 'SET_ASSETS';
|
export const SET_ASSETS = 'SET_ASSETS';
|
||||||
|
|
|
@ -235,6 +235,18 @@ export function hideHelpModal() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hideRuntimeErrorWarning() {
|
||||||
|
return {
|
||||||
|
type: ActionTypes.HIDE_RUNTIME_ERROR_WARNING
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function showRuntimeErrorWarning() {
|
||||||
|
return {
|
||||||
|
type: ActionTypes.SHOW_RUNTIME_ERROR_WARNING
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function startSketch() {
|
export function startSketch() {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(clearConsole());
|
dispatch(clearConsole());
|
||||||
|
@ -256,4 +268,3 @@ export function stopSketch() {
|
||||||
dispatch(stopVisualSketch());
|
dispatch(stopVisualSketch());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,23 @@ class Editor extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.tidyCode = this.tidyCode.bind(this);
|
this.tidyCode = this.tidyCode.bind(this);
|
||||||
|
|
||||||
|
this.updateLintingMessageAccessibility = debounce((annotations) => {
|
||||||
|
this.props.clearLintMessage();
|
||||||
|
annotations.forEach((x) => {
|
||||||
|
if (x.from.line > -1) {
|
||||||
|
this.props.updateLintMessage(x.severity, (x.from.line + 1), x.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (this.props.lintMessages.length > 0 && this.props.lintWarning) {
|
||||||
|
this.beep.play();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
this.showFind = this.showFind.bind(this);
|
this.showFind = this.showFind.bind(this);
|
||||||
this.findNext = this.findNext.bind(this);
|
this.findNext = this.findNext.bind(this);
|
||||||
this.findPrev = this.findPrev.bind(this);
|
this.findPrev = this.findPrev.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.beep = new Audio(beepUrl);
|
this.beep = new Audio(beepUrl);
|
||||||
this.widgets = [];
|
this.widgets = [];
|
||||||
|
@ -73,17 +86,10 @@ class Editor extends React.Component {
|
||||||
keyMap: 'sublime',
|
keyMap: 'sublime',
|
||||||
highlightSelectionMatches: true, // highlight current search match
|
highlightSelectionMatches: true, // highlight current search match
|
||||||
lint: {
|
lint: {
|
||||||
onUpdateLinting: debounce((annotations) => {
|
onUpdateLinting: ((annotations) => {
|
||||||
this.props.clearLintMessage();
|
this.props.hideRuntimeErrorWarning();
|
||||||
annotations.forEach((x) => {
|
this.updateLintingMessageAccessibility(annotations);
|
||||||
if (x.from.line > -1) {
|
}),
|
||||||
this.props.updateLintMessage(x.severity, (x.from.line + 1), x.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (this.props.lintMessages.length > 0 && this.props.lintWarning) {
|
|
||||||
this.beep.play();
|
|
||||||
}
|
|
||||||
}, 2000),
|
|
||||||
options: {
|
options: {
|
||||||
'asi': true,
|
'asi': true,
|
||||||
'eqeqeq': false,
|
'eqeqeq': false,
|
||||||
|
@ -93,7 +99,6 @@ class Editor extends React.Component {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this._cm.setOption('extraKeys', {
|
this._cm.setOption('extraKeys', {
|
||||||
[`${metaKey}-Enter`]: () => null,
|
[`${metaKey}-Enter`]: () => null,
|
||||||
[`Shift-${metaKey}-Enter`]: () => null,
|
[`Shift-${metaKey}-Enter`]: () => null,
|
||||||
|
@ -171,6 +176,22 @@ class Editor extends React.Component {
|
||||||
if (this.props.theme !== prevProps.theme) {
|
if (this.props.theme !== prevProps.theme) {
|
||||||
this._cm.setOption('theme', `p5-${this.props.theme}`);
|
this._cm.setOption('theme', `p5-${this.props.theme}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prevProps.consoleEvents !== this.props.consoleEvents) {
|
||||||
|
this.props.showRuntimeErrorWarning();
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 1000; i += 1) {
|
||||||
|
this._cm.removeLineClass(i, 'background', 'line-runtime-error');
|
||||||
|
}
|
||||||
|
if (this.props.runtimeErrorWarningVisible) {
|
||||||
|
this.props.consoleEvents.forEach((consoleEvent) => {
|
||||||
|
if (consoleEvent.method === 'error') {
|
||||||
|
const n = consoleEvent.arguments.replace(')', '').split(' ');
|
||||||
|
const lineNumber = parseInt(n[n.length - 1], 10) - 1;
|
||||||
|
this._cm.addLineClass(lineNumber, 'background', 'line-runtime-error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -301,6 +322,10 @@ Editor.propTypes = {
|
||||||
message: PropTypes.string.isRequired,
|
message: PropTypes.string.isRequired,
|
||||||
id: PropTypes.number.isRequired
|
id: PropTypes.number.isRequired
|
||||||
})).isRequired,
|
})).isRequired,
|
||||||
|
consoleEvents: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
method: PropTypes.string.isRequired,
|
||||||
|
args: PropTypes.arrayOf(PropTypes.string)
|
||||||
|
})),
|
||||||
updateLintMessage: PropTypes.func.isRequired,
|
updateLintMessage: PropTypes.func.isRequired,
|
||||||
clearLintMessage: PropTypes.func.isRequired,
|
clearLintMessage: PropTypes.func.isRequired,
|
||||||
indentationAmount: PropTypes.number.isRequired,
|
indentationAmount: PropTypes.number.isRequired,
|
||||||
|
@ -332,11 +357,15 @@ Editor.propTypes = {
|
||||||
expandSidebar: PropTypes.func.isRequired,
|
expandSidebar: PropTypes.func.isRequired,
|
||||||
isUserOwner: PropTypes.bool,
|
isUserOwner: PropTypes.bool,
|
||||||
clearConsole: PropTypes.func.isRequired,
|
clearConsole: PropTypes.func.isRequired,
|
||||||
|
showRuntimeErrorWarning: PropTypes.func.isRequired,
|
||||||
|
hideRuntimeErrorWarning: PropTypes.func.isRequired,
|
||||||
|
runtimeErrorWarningVisible: PropTypes.bool.isRequired,
|
||||||
provideController: PropTypes.func.isRequired
|
provideController: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
Editor.defaultProps = {
|
Editor.defaultProps = {
|
||||||
isUserOwner: false
|
isUserOwner: false,
|
||||||
|
consoleEvents: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Editor;
|
export default Editor;
|
||||||
|
|
|
@ -340,6 +340,10 @@ class IDEView extends React.Component {
|
||||||
collapseSidebar={this.props.collapseSidebar}
|
collapseSidebar={this.props.collapseSidebar}
|
||||||
isUserOwner={this.isUserOwner()}
|
isUserOwner={this.isUserOwner()}
|
||||||
clearConsole={this.props.clearConsole}
|
clearConsole={this.props.clearConsole}
|
||||||
|
consoleEvents={this.props.console}
|
||||||
|
showRuntimeErrorWarning={this.props.showRuntimeErrorWarning}
|
||||||
|
hideRuntimeErrorWarning={this.props.hideRuntimeErrorWarning}
|
||||||
|
runtimeErrorWarningVisible={this.props.ide.runtimeErrorWarningVisible}
|
||||||
provideController={(ctl) => { this.cmController = ctl; }}
|
provideController={(ctl) => { this.cmController = ctl; }}
|
||||||
/>
|
/>
|
||||||
<Console
|
<Console
|
||||||
|
@ -568,7 +572,8 @@ IDEView.propTypes = {
|
||||||
previousPath: PropTypes.string.isRequired,
|
previousPath: PropTypes.string.isRequired,
|
||||||
justOpenedProject: PropTypes.bool.isRequired,
|
justOpenedProject: PropTypes.bool.isRequired,
|
||||||
errorType: PropTypes.string,
|
errorType: PropTypes.string,
|
||||||
helpType: PropTypes.string
|
helpType: PropTypes.string,
|
||||||
|
runtimeErrorWarningVisible: PropTypes.bool.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
stopSketch: PropTypes.func.isRequired,
|
stopSketch: PropTypes.func.isRequired,
|
||||||
project: PropTypes.shape({
|
project: PropTypes.shape({
|
||||||
|
@ -685,6 +690,8 @@ IDEView.propTypes = {
|
||||||
persistState: PropTypes.func.isRequired,
|
persistState: PropTypes.func.isRequired,
|
||||||
showHelpModal: PropTypes.func.isRequired,
|
showHelpModal: PropTypes.func.isRequired,
|
||||||
hideHelpModal: PropTypes.func.isRequired,
|
hideHelpModal: PropTypes.func.isRequired,
|
||||||
|
showRuntimeErrorWarning: PropTypes.func.isRequired,
|
||||||
|
hideRuntimeErrorWarning: PropTypes.func.isRequired,
|
||||||
startSketch: PropTypes.func.isRequired,
|
startSketch: PropTypes.func.isRequired,
|
||||||
startAccessibleSketch: PropTypes.func.isRequired
|
startAccessibleSketch: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,8 @@ const initialState = {
|
||||||
infiniteLoopMessage: '',
|
infiniteLoopMessage: '',
|
||||||
justOpenedProject: false,
|
justOpenedProject: false,
|
||||||
previousPath: '/',
|
previousPath: '/',
|
||||||
errorType: undefined
|
errorType: undefined,
|
||||||
|
runtimeErrorWarningVisible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ide = (state = initialState, action) => {
|
const ide = (state = initialState, action) => {
|
||||||
|
@ -95,6 +96,10 @@ const ide = (state = initialState, action) => {
|
||||||
return Object.assign({}, state, { helpType: action.helpType });
|
return Object.assign({}, state, { helpType: action.helpType });
|
||||||
case ActionTypes.HIDE_HELP_MODAL:
|
case ActionTypes.HIDE_HELP_MODAL:
|
||||||
return Object.assign({}, state, { helpType: undefined });
|
return Object.assign({}, state, { helpType: undefined });
|
||||||
|
case ActionTypes.HIDE_RUNTIME_ERROR_WARNING:
|
||||||
|
return Object.assign({}, state, { runtimeErrorWarningVisible: false });
|
||||||
|
case ActionTypes.SHOW_RUNTIME_ERROR_WARNING:
|
||||||
|
return Object.assign({}, state, { runtimeErrorWarningVisible: true });
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,6 +278,17 @@ pre.CodeMirror-line {
|
||||||
font-family: serif;
|
font-family: serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.line-runtime-error + .CodeMirror-activeline-gutter {
|
||||||
|
background-color: rgb(255, 95, 82);
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.line-runtime-error {
|
||||||
|
background-color: rgb(255, 95, 82) !important;
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
.editor-holder {
|
.editor-holder {
|
||||||
height: calc(100% - #{29 / $base-font-size}rem);
|
height: calc(100% - #{29 / $base-font-size}rem);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
Loading…
Reference in a new issue