Skip to content

Commit

Permalink
Support nested repository's
Browse files Browse the repository at this point in the history
  • Loading branch information
RedCMD committed Dec 3, 2023
1 parent 33aba65 commit 0470483
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions out/DefinitionProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const DefinitionProvider = {

const { getNodeAtLocation } = await _extension.parseTreeExtension.activate()
const location = new vscode.Location(document.uri, position)
let node = getNodeAtLocation(location)
let locations = []
const node = await getNodeAtLocation(location)
const locations = []
// vscode.window.showInformationMessage(node.text)

if (node.parent.type == 'value')
Expand Down Expand Up @@ -70,10 +70,10 @@ const DefinitionProvider = {
locations.push(locationLink)
}


if (node.type == 'value' && node.parent.type == 'include') {
const { getTree } = await _extension.parseTreeExtension.activate()
const tree = getTree(document)
const tree = await getTree(document)

switch (node.text) {
case '$self':
Expand Down Expand Up @@ -105,8 +105,8 @@ const DefinitionProvider = {

if (targetSelectionRange.contains(originSelectionRange))
targetSelectionRange = targetRange


const locationLink = {
originSelectionRange: originSelectionRange,
targetUri: document.uri,
Expand Down Expand Up @@ -188,7 +188,7 @@ const DefinitionProvider = {
targetSelectionRange = targetRange

targetRange = targetSelectionRange

if (targetRange == null)
return

Expand Down Expand Up @@ -237,7 +237,7 @@ const DefinitionProvider = {
}
})
}
else
else {
tree.rootNode.namedChildren.forEach(node => {
if (node.type != 'repository')
return
Expand All @@ -260,6 +260,34 @@ const DefinitionProvider = {
})
})

let parentNode = node.parent
while (parentNode != null) {
if (parentNode.type == 'repo')
parentNode.namedChildren.forEach(repoNode => {
if (repoNode.type != 'repository')
return

repoNode.namedChildren.forEach(repoNode => {
if (repoNode.type != 'repo')
return

if (repoNode.firstNamedChild.text != includeText)
return

const locationLink = {
originSelectionRange: originSelectionRange,
targetUri: document.uri,
targetRange: _extension.nodeToVscodeRange(repoNode),
targetSelectionRange: _extension.nodeToVscodeRange(repoNode.firstNamedChild)
}
// vscode.window.showInformationMessage(JSON.stringify(locationLink))
locations.push(locationLink)
})
})
parentNode = parentNode.parent
}
}

break
}
}
Expand Down

0 comments on commit 0470483

Please sign in to comment.