Skip to content

Commit

Permalink
Support text based an syntax tree item
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Nov 9, 2024
1 parent a672947 commit 88e708b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
4 changes: 2 additions & 2 deletions data/fixtures/recorded/languages/typescript/takeItem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ finalState:
const value = { a: 1, b: 2, c: 3 };
selections:
- anchor: {line: 1, character: 0}
active: {line: 1, character: 35}
- anchor: {line: 1, character: 6}
active: {line: 1, character: 34}

This file was deleted.

1 change: 0 additions & 1 deletion packages/common/src/scopeSupportFacets/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = {
"value.field": supported,

"collectionItem.unenclosed": supported,
"collectionItem.unenclosed.iteration": supported,
};

export const javascriptJsxScopeSupport: LanguageScopeSupportFacetMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,39 @@ export class ContainingScopeStage implements ModifierStage {
.run(target);
}

const containingScope = getContainingScopeTarget(
const containingScopes = getContainingScopeTarget(
target,
scopeHandler,
ancestorIndex,
);

if (containingScope == null) {
if (scopeType.type === "collectionItem") {
// For `collectionItem`, fall back to generic implementation
return this.modifierStageFactory
if (scopeType.type === "collectionItem") {
// For `collectionItem`, combine with generic implementation
try {
const legacyScopes = this.modifierStageFactory
.getLegacyScopeStage(this.modifier)
.run(target);
if (containingScopes == null) {
return legacyScopes;
}
if (containingScopes.length === 1 && legacyScopes.length === 1) {
const containingRange = containingScopes[0].contentRange;
const legacyRange = legacyScopes[0].contentRange;
if (
containingRange.contains(legacyRange) &&
!containingRange.isRangeEqual(legacyRange)
) {
return legacyScopes;
}
}
} catch (_ex) {
// Do nothing
}
}

if (containingScopes == null) {
throw new NoContainingScopeError(this.modifier.scopeType.type);
}

return containingScope;
return containingScopes;
}
}
9 changes: 0 additions & 9 deletions queries/javascript.core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,6 @@
(#insertion-delimiter! @collectionItem ", ")
)

;;!! let foo, bar;
;;! ^^^^^^^^
;;! -------------
(lexical_declaration
.
(_) @collectionItem.iteration.start.startOf
";"? @collectionItem.iteration.end.startOf
) @collectionItem.iteration.domain

(expression_statement
[
;; name:
Expand Down

0 comments on commit 88e708b

Please sign in to comment.