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
8351bdf6
Commit
8351bdf6
authored
Sep 25, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nodesAtCursorPosition
parent
d46b09ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
sourceMappingDecoder.js
src/util/sourceMappingDecoder.js
+32
-0
No files found.
src/util/sourceMappingDecoder.js
View file @
8351bdf6
...
@@ -10,6 +10,15 @@ function SourceMappingDecoder () {
...
@@ -10,6 +10,15 @@ function SourceMappingDecoder () {
}
}
/**
/**
* get a list of nodes that are at the given @arg position
*
* @param {String} astNodeType - type of node to return
* @param {Int} position - cursor position
* @return {Object} ast object given by the compiler
*/
SourceMappingDecoder
.
prototype
.
nodesAtPosition
=
nodesAtPosition
/**
* Decode the source mapping for the given @arg index
* Decode the source mapping for the given @arg index
*
*
* @param {Integer} index - source mapping index to decode
* @param {Integer} index - source mapping index to decode
...
@@ -156,6 +165,29 @@ function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) {
...
@@ -156,6 +165,29 @@ function findNodeAtSourceLocation (astNodeType, sourceLocation, ast) {
return
found
return
found
}
}
function
nodesAtPosition
(
astNodeType
,
position
,
ast
)
{
var
astWalker
=
new
AstWalker
()
var
callback
=
{}
var
found
=
{}
callback
[
'*'
]
=
function
(
node
)
{
var
nodeLocation
=
sourceLocationFromAstNode
(
node
)
if
(
!
nodeLocation
)
{
return
}
if
(
nodeLocation
.
start
<=
position
&&
nodeLocation
.
start
+
nodeLocation
.
length
>=
position
)
{
if
(
!
astNodeType
||
astNodeType
===
node
.
name
)
{
found
[
node
.
name
]
=
node
if
(
astNodeType
)
return
false
}
return
true
}
else
{
return
false
}
}
astWalker
.
walk
(
ast
.
AST
,
callback
)
return
found
}
function
atIndex
(
index
,
mapping
)
{
function
atIndex
(
index
,
mapping
)
{
var
ret
=
{}
var
ret
=
{}
var
map
=
mapping
.
split
(
';'
)
var
map
=
mapping
.
split
(
';'
)
...
...
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