Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
cd33620f
Commit
cd33620f
authored
Sep 25, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- rename API
- hightlight every expression that has a referenced declaration
parent
2f8900f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
26 deletions
+36
-26
app.js
src/app.js
+2
-2
contextualListener.js
src/app/editor/contextualListener.js
+34
-24
No files found.
src/app.js
View file @
cd33620f
...
@@ -394,11 +394,11 @@ function run () {
...
@@ -394,11 +394,11 @@ function run () {
getCompilationResult
:
()
=>
{
getCompilationResult
:
()
=>
{
return
compiler
.
lastCompilationResult
return
compiler
.
lastCompilationResult
},
},
warn
FoundCall
:
(
position
)
=>
{
warn
Expression
:
(
position
)
=>
{
position
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
position
=
offsetToLineColumnConverter
.
offsetToLineColumn
(
position
,
position
.
file
,
compiler
.
lastCompilationResult
)
return
editor
.
addMarker
(
position
,
config
.
get
(
'currentFile'
),
'highlightcall'
)
return
editor
.
addMarker
(
position
,
config
.
get
(
'currentFile'
),
'highlightcall'
)
},
},
stop
FoundCall
:
(
event
)
=>
{
stop
WarningExpression
:
(
event
)
=>
{
editor
.
removeMarker
(
event
.
eventId
,
event
.
fileTarget
)
editor
.
removeMarker
(
event
.
eventId
,
event
.
fileTarget
)
}
}
},
{
},
{
...
...
src/app/editor/contextualListener.js
View file @
cd33620f
...
@@ -6,9 +6,8 @@ class ContextualListener {
...
@@ -6,9 +6,8 @@ class ContextualListener {
constructor
(
api
,
events
)
{
constructor
(
api
,
events
)
{
this
.
_api
=
api
this
.
_api
=
api
this
.
_index
=
{
this
.
_index
=
{
FunctionDefinition
:
{},
ReferencedDeclarations
:
{},
FunctionCalls
:
{},
Expressions
:
[]
FunctionCall
:
{}
}
}
this
.
_events
=
[]
this
.
_events
=
[]
...
@@ -18,27 +17,26 @@ class ContextualListener {
...
@@ -18,27 +17,26 @@ class ContextualListener {
this
.
_buildIndex
(
data
,
source
)
this
.
_buildIndex
(
data
,
source
)
}
else
{
}
else
{
this
.
_index
=
{
this
.
_index
=
{
FunctionDefinition
:
{},
ReferencedDeclarations
:
{},
FunctionCalls
:
{},
Expressions
:
[]
FunctionCall
:
{}
}
}
}
}
})
})
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
sourceMappingDecoder
=
new
SourceMappingDecoder
()
this
.
astWalker
=
new
AstWalker
()
this
.
astWalker
=
new
AstWalker
()
setInterval
(()
=>
{
setInterval
(()
=>
{
this
.
_
context
(
api
.
getCursorPosition
(),
api
.
getCompilationResult
())
this
.
_
warnExpressions
(
api
.
getCursorPosition
(),
api
.
getCompilationResult
())
},
1000
)
},
1000
)
}
}
_
context
(
cursorPosition
,
compilationResult
)
{
_
warnExpressions
(
cursorPosition
,
compilationResult
)
{
if
(
this
.
currentPosition
===
cursorPosition
)
return
if
(
this
.
currentPosition
===
cursorPosition
)
return
this
.
_stopWarning
()
this
.
_stopWarning
()
this
.
currentPosition
=
cursorPosition
this
.
currentPosition
=
cursorPosition
if
(
compilationResult
&&
compilationResult
.
data
&&
compilationResult
.
source
)
{
if
(
compilationResult
&&
compilationResult
.
data
&&
compilationResult
.
source
)
{
var
nodes
=
this
.
sourceMappingDecoder
.
nodesAtPosition
(
null
,
cursorPosition
,
compilationResult
.
data
.
sources
[
compilationResult
.
source
.
target
])
var
nodes
=
this
.
sourceMappingDecoder
.
nodesAtPosition
(
null
,
cursorPosition
,
compilationResult
.
data
.
sources
[
compilationResult
.
source
.
target
])
if
(
nodes
&&
nodes
[
'FunctionCall'
])
{
if
(
nodes
&&
nodes
.
length
&&
nodes
[
nodes
.
length
-
1
])
{
this
.
_
highlightFunctionCall
(
nodes
[
'FunctionCall'
],
compilationResult
)
this
.
_
warnExpression
(
nodes
[
nodes
.
length
-
1
],
compilationResult
)
}
}
}
}
}
}
...
@@ -48,13 +46,12 @@ class ContextualListener {
...
@@ -48,13 +46,12 @@ class ContextualListener {
var
self
=
this
var
self
=
this
var
callback
=
{}
var
callback
=
{}
callback
[
'*'
]
=
function
(
node
)
{
callback
[
'*'
]
=
function
(
node
)
{
if
(
node
&&
node
.
name
&&
self
.
_index
[
node
.
name
])
{
if
(
node
&&
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
self
.
_index
[
node
.
name
][
node
.
id
]
=
node
if
(
!
self
.
_index
[
'ReferencedDeclarations'
][
node
.
attributes
.
referencedDeclaration
])
{
if
(
node
.
name
===
'FunctionCall'
&&
node
.
children
[
0
]
&&
node
.
children
[
0
].
attributes
)
{
self
.
_index
[
'ReferencedDeclarations'
][
node
.
attributes
.
referencedDeclaration
]
=
[]
var
declaration
=
node
.
children
[
0
].
attributes
.
referencedDeclaration
if
(
!
self
.
_index
[
'FunctionCalls'
][
declaration
])
self
.
_index
[
'FunctionCalls'
][
declaration
]
=
[]
self
.
_index
[
'FunctionCalls'
][
declaration
].
push
(
node
.
id
)
}
}
self
.
_index
[
'ReferencedDeclarations'
][
node
.
attributes
.
referencedDeclaration
].
push
(
node
)
self
.
_index
[
'Expressions'
].
push
(
node
)
}
}
return
true
return
true
}
}
...
@@ -62,20 +59,33 @@ class ContextualListener {
...
@@ -62,20 +59,33 @@ class ContextualListener {
}
}
}
}
_highlightFunctionCall
(
node
,
compilationResult
)
{
_warnExpression
(
node
,
compilationResult
)
{
if
(
node
.
name
===
'FunctionCall'
&&
node
.
children
[
0
]
&&
node
.
children
[
0
].
attributes
)
{
var
self
=
this
var
calls
=
this
.
_index
[
'FunctionCalls'
][
node
.
children
[
0
].
attributes
.
referencedDeclaration
]
function
highlight
(
id
)
{
for
(
var
call
in
calls
)
{
if
(
self
.
_index
[
'ReferencedDeclarations'
]
&&
self
.
_index
[
'ReferencedDeclarations'
][
id
])
{
var
position
=
this
.
sourceMappingDecoder
.
decode
(
this
.
_index
[
'FunctionCall'
][
calls
[
call
]].
src
)
var
calls
=
self
.
_index
[
'ReferencedDeclarations'
][
id
]
var
eventId
=
this
.
_api
.
warnFoundCall
(
position
)
for
(
var
call
in
calls
)
{
this
.
_events
.
push
({
eventId
,
position
,
fileTarget
:
compilationResult
.
source
.
target
})
self
.
_warn
(
calls
[
call
].
src
,
compilationResult
)
}
}
}
}
}
if
(
node
.
attributes
&&
node
.
attributes
.
referencedDeclaration
)
{
highlight
(
node
.
attributes
.
referencedDeclaration
)
}
else
{
highlight
(
node
.
id
)
}
}
_warn
(
src
,
compilationResult
)
{
var
position
=
this
.
sourceMappingDecoder
.
decode
(
src
)
var
eventId
=
this
.
_api
.
warnExpression
(
position
)
this
.
_events
.
push
({
eventId
,
position
,
fileTarget
:
compilationResult
.
source
.
target
})
}
}
_stopWarning
()
{
_stopWarning
()
{
for
(
var
event
in
this
.
_events
)
{
for
(
var
event
in
this
.
_events
)
{
this
.
_api
.
stop
FoundCall
(
this
.
_events
[
event
])
this
.
_api
.
stop
WarningExpression
(
this
.
_events
[
event
])
}
}
this
.
_events
=
[]
this
.
_events
=
[]
}
}
...
...
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