Commit 523483a6 authored by Matej Genci's avatar Matej Genci

Highlighting and more action buttons

parent f36b61f0
...@@ -68,32 +68,15 @@ class App extends React.Component { ...@@ -68,32 +68,15 @@ class App extends React.Component {
let hl = nodeData.highlighting; let hl = nodeData.highlighting;
this.setState((state, props) => { this.setState((state, props) => {
let armMarkers = state.arm.markers;
hl.arm.array.forEach(element => armMarkers.append(element))
return { return {
wacc: {markers: state.wacc.markers.append(hl.wacc)}, wacc: {code: state.wacc.code, markers: hl.wacc},
js: {markers: state.js.markers.append(hl.js)}, js: {code: state.js.code, markers: hl.js},
arm: {markers: armMarkers} arm: {code: state.arm.code, markers: hl.arm}
} }
}) })
} }
onNodeOut = (nodeData, evt) => { onNodeOut = (nodeData, evt) => {
let hl = nodeData.highlighting;
this.setState((state, props) => {
let waccMarkerIdx = state.wacc.markers.indexOf(hl.wacc);
let jsMarkerIdx = state.js.markers.indexOf(hl.js)
let armMarkers = [];
return {
wacc: {markers: state.wacc.markers.splice(waccMarkerIdx, 1)},
js: {markers: state.js.markers.splice(jsMarkerIdx, 1)},
arm: {markers: armMarkers}
}
})
} }
readInputCallBack = (codeToEval) => { readInputCallBack = (codeToEval) => {
......
...@@ -22,10 +22,10 @@ export function astMetaToGraphData(astMeta) { ...@@ -22,10 +22,10 @@ export function astMetaToGraphData(astMeta) {
function generateMarkerObject(start, end) { function generateMarkerObject(start, end) {
return { return {
startRow: start.lineNum, startRow: start.lineNum - 1,
startCol: start.charNum, startCol: start.charNum,
endRow: end.lineNum, endRow: end.lineNum - 1,
endCol: end.charNum, endCol: end.charNum - 1,
className: "ast-node-highlight", className: "ast-node-highlight",
type: "text" type: "text"
} }
...@@ -49,8 +49,8 @@ function createGraphNode(node, astMeta){ ...@@ -49,8 +49,8 @@ function createGraphNode(node, astMeta){
name: name, name: name,
attributes: {value: value}, attributes: {value: value},
highlighting: { highlighting: {
wacc: generateMarkerObject(node.waccStart, node.waccEnd), wacc: [generateMarkerObject(node.waccStart, node.waccEnd)],
js: typeof node.jsStart === "undefined" ? {} : generateMarkerObject(node.jsStart, node.jsEnd), js: typeof node.jsStart === "undefined" ? [{}] : [generateMarkerObject(node.jsStart, node.jsEnd)],
arm: [] arm: []
}, },
children: children children: children
......
...@@ -9,8 +9,9 @@ class ButtonStrip extends React.Component { ...@@ -9,8 +9,9 @@ class ButtonStrip extends React.Component {
render() { render() {
return ( return (
<div> <div>
<Button onClick={this.props.onCompileClick}></Button> <Button onClick={this.props.onCompileClick}>COMPILE</Button>
<Button onClick={this.props.onStepJsClick}>STEP JS LINE</Button> <Button onClick={this.props.onExecuteClick}>EXECUTE</Button>
<Button onClick={this.props.onStepWaccClick}>STEP WACC LINE</Button>
</div> </div>
) )
} }
......
...@@ -20,6 +20,9 @@ class CodeEditor extends React.Component { ...@@ -20,6 +20,9 @@ class CodeEditor extends React.Component {
return ( return (
<div className="ace-editor"> <div className="ace-editor">
{this.heading()} {this.heading()}
<p>
Highlighting {JSON.stringify(this.props.markers)}
</p>
<AceEditor <AceEditor
mode="java" mode="java"
theme="github" theme="github"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment