Skip to content

Commit

Permalink
Update a few stragglers for the query property renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
savetheclocktower committed Aug 9, 2024
1 parent 11e2f75 commit 6846b9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions packages/symbol-provider-tree-sitter/lib/tree-sitter-provider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const CaptureOrganizer = require('./capture-organizer');
const { Emitter } = require('atom');

function layerHasTagsQuery(layer) {
return layer.queries?.tagsQuery ?? layer.tagsQuery;
}

class TreeSitterProvider {
constructor() {
this.packageName = 'symbol-provider-tree-sitter';
Expand Down Expand Up @@ -37,7 +41,7 @@ class TreeSitterProvider {
}

// This provider needs at least one layer to have a tags query.
let layers = languageMode.getAllLanguageLayers(l => !!l.tagsQuery);
let layers = languageMode.getAllLanguageLayers(layerHasTagsQuery);
if (layers.length === 0) {
return false;
}
Expand All @@ -64,13 +68,14 @@ class TreeSitterProvider {
// The symbols-view package might've cancelled us in the interim.
if (signal.aborted) return null;

let layers = languageMode.getAllLanguageLayers(l => !!l.tagsQuery);
let layers = languageMode.getAllLanguageLayers(layerHasTagsQuery);
if (layers.length === 0) return null;

for (let layer of layers) {
let extent = layer.getExtent();

let captures = layer.tagsQuery.captures(
let tagsQuery = layer.queries?.tagsQuery ?? layer.tagsQuery;
let captures = tagsQuery.captures(
layer.tree.rootNode,
extent.start,
extent.end
Expand Down
10 changes: 5 additions & 5 deletions src/wasm-tree-sitter-language-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3290,7 +3290,7 @@ class LanguageLayer {
// propagate errors.
//
// TODO: Warning?
grammar.highlightsQuery = grammar.setQueryForTest(
grammar.setQueryForTest(
'highlightsQuery',
`; (placeholder)`
);
Expand Down Expand Up @@ -3753,8 +3753,8 @@ class LanguageLayer {
}

getLocalReferencesAtPoint(point) {
if (!this.localsQuery) { return []; }
let captures = this.localsQuery.captures(
if (!this.queries.localsQuery) { return []; }
let captures = this.queries.localsQuery.captures(
this.tree.rootNode,
point,
point + 1
Expand All @@ -3777,15 +3777,15 @@ class LanguageLayer {
// EXPERIMENTAL: Given a local reference node, tries to find the node that
// defines it.
findDefinitionForLocalReference(node, captures = null) {
if (!this.localsQuery) { return []; }
if (!this.queries.localsQuery) { return []; }
let name = node.text;
if (!name) { return []; }
let localRange = rangeForNode(node);
let globalScope = this.tree.rootNode;

if (!captures) {
captures = this.groupLocalsCaptures(
this.localsQuery.captures(
this.queries.localsQuery.captures(
globalScope,
globalScope.startPosition,
globalScope.endPosition
Expand Down

0 comments on commit 6846b9c

Please sign in to comment.