-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scoping of direct references to declarations in same file (#580)
Closes partially #540 ### Summary of Changes Resolve the target of references if * it is in the same file as the declaration * the reference is not the member of a member access. --------- Co-authored-by: megalinter-bot <[email protected]>
- Loading branch information
1 parent
2e6be9f
commit 491d7b0
Showing
37 changed files
with
1,897 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { AstNode, hasContainerOfType } from 'langium'; | ||
|
||
/** | ||
* Returns whether the inner node is contained in the outer node. If the nodes are equal, this function returns `true`. | ||
*/ | ||
export const isContainedIn = (inner: AstNode | undefined, outer: AstNode | undefined): boolean => { | ||
return hasContainerOfType(inner, (it) => it === outer); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { isSdsAnnotation, isSdsPipeline, isSdsSchema, SdsReference } from '../../../generated/ast.js'; | ||
import { ValidationAcceptor } from 'langium'; | ||
|
||
export const CODE_REFERENCE_TARGET = 'reference/target'; | ||
|
||
export const referenceTargetMustNotBeAnnotationPipelineOrSchema = ( | ||
node: SdsReference, | ||
accept: ValidationAcceptor, | ||
): void => { | ||
const target = node.target?.ref; | ||
|
||
if (isSdsAnnotation(target)) { | ||
accept('error', 'An annotation must not be the target of a reference.', { | ||
node, | ||
code: CODE_REFERENCE_TARGET, | ||
}); | ||
} else if (isSdsPipeline(target)) { | ||
accept('error', 'A pipeline must not be the target of a reference.', { | ||
node, | ||
code: CODE_REFERENCE_TARGET, | ||
}); | ||
} else if (isSdsSchema(target)) { | ||
accept('error', 'A schema must not be the target of a reference.', { | ||
node, | ||
code: CODE_REFERENCE_TARGET, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...literal (with interpolation)/main.sdstest → ...ursive cases/template string/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.