Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
rk4718
wacc_26_web_client
Commits
a20f30b4
Commit
a20f30b4
authored
Mar 13, 2020
by
Matej Genci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Function to generate markers to highlight node
parent
264f6513
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/Comm.js
src/Comm.js
+13
-9
No files found.
src/Comm.js
View file @
a20f30b4
...
...
@@ -9,19 +9,27 @@ export function astMetaToGraphData(astMeta) {
return
graphData
}
function
generateMarkerObject
(
start
,
end
,
off
=
0
)
{
function
generateMarkerObject
(
start
,
end
,
off
=
0
,
style
=
"
ast-node-highlight
"
)
{
return
{
startRow
:
start
.
lineNum
-
1
,
startCol
:
start
.
charNum
+
off
,
endRow
:
end
.
lineNum
-
1
,
endCol
:
end
.
charNum
,
className
:
"
ast-node-highlight
"
,
className
:
style
,
type
:
"
text
"
}
}
function
generateArmMarkers
(
lineNums
)
{
return
lineNums
.
map
(
ln
=>
({
startRow
:
ln
-
1
,
className
:
"
ast-node-highlight
"
,
type
:
"
background
"
}))
function
generateArmMarkers
(
lineNums
,
style
=
"
ast-node-highlight
"
)
{
return
lineNums
.
map
(
ln
=>
({
startRow
:
ln
-
1
,
className
:
style
,
type
:
"
background
"
}))
}
function
highlightNode
(
node
,
style
=
"
ast-node-highlight
"
)
{
return
{
wacc
:
[
generateMarkerObject
(
node
.
waccStart
,
node
.
waccEnd
,
style
)],
js
:
typeof
node
.
jsStart
===
"
undefined
"
?
[{}]
:
[
generateMarkerObject
(
node
.
jsStart
,
node
.
jsEnd
,
-
1
,
style
)],
arm
:
generateArmMarkers
(
node
.
armLineNums
,
style
)
}
}
function
createGraphNode
(
node
,
astMeta
){
...
...
@@ -41,11 +49,7 @@ function createGraphNode(node, astMeta){
return
{
name
:
name
,
attributes
:
{
value
:
value
},
highlighting
:
{
wacc
:
[
generateMarkerObject
(
node
.
waccStart
,
node
.
waccEnd
)],
js
:
typeof
node
.
jsStart
===
"
undefined
"
?
[{}]
:
[
generateMarkerObject
(
node
.
jsStart
,
node
.
jsEnd
,
-
1
)],
arm
:
generateArmMarkers
(
node
.
armLineNums
)
},
highlighting
:
highlightNode
(
node
),
children
:
children
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment