Repository navigation
fix: resolve a model reference in a model target by model ID - #231
Open
sergej-koscejev wants to merge 1 commit into
Open
sergej-koscejev wants to merge 1 commit into
sergej-koscejev wants to merge 1 commit into
Conversation
A model target that parses as a model reference with a type designator now resolves by model ID, so a reference with an out-of-date name still finds its model and a reference to a missing model never falls back to a name lookup. Other targets are model names, as before. The navigation resolver used by search scopes shares the same parser.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A Model Target that is a serialized Model Reference now resolves by model ID. Before, mops compared the exact printed reference text, so a reference with an out-of-date name in parentheses (for example after a model rename) failed with "model not found", while the same reference worked as a search scope.
Text without a type designator is a model name and never reaches MPS's
createModelReference, which would read it as a name-based model ID. mops does not support name-based model IDs.The check lives in one helper,
parseModelReferenceOrNull(modelReferenceSpelling.kt).NavigationTargetResolver.resolveModelReference(search scopes,list, Ant test selection) now uses it too, in place of its own "the resolved ID must equal the parsed ID" guard, which existed only to reject name-based IDs.Sibling paths
All go through
ModelNodeResolver.findNode/findModelUnique, so all are changed:get node,render node,find usages(MODEL_TARGET NODE_ID forms)check model(help text now says a reference resolves by model ID;docs/reference/check.mdregenerated){"model": …, "nodeId": …}targets (EditBatchExecutor)mops.lookup.model/requireModel(MopsLookupExtensions)Left for later: the inline-reference
{"target": {"model": …, "node": …}}form inEditBatchExecutor.resolveReferenceTargetOrFailjoins the model text and node ID into a Node Reference string and passes it to MPS, so a model name there is still parsed as a name-based model ID. It does not go through MODEL_TARGET resolution.Evidence
New tests, all on the
jsonfixture unless noted:GetNodeSemanticsTestresolves a model reference with an out-of-date name by its model ID—r:fd752404-…(com.specificlanguages.json.oldname)findscom.specificlanguages.json.structurefails on a model reference to a missing model without falling back to its name— unknown ID, existing name in parentheses →MODEL_NOT_FOUNDfails instead of guessing when model target is ambiguous— extended: with two same-named models the bare name still failsAMBIGUOUS_TARGET, and a reference picks one of them by IDexports node jsonand others)ModelCheckSemanticsTest:a model reference with an out-of-date name checks the model it identifies(sandbox fixture)CodeModeLookupTest:mops.lookup.modelresolves a stale reference and returns null for a missing oneBefore: with the old text-comparing
matchingModels,GetNodeSemanticsTest→21 tests completed, 1 failed:resolves a model reference with an out-of-date name by its model ID()throwsMpsRequestException(model not found).After:
GetNodeSemanticsTest(21),ModelCheckSemanticsTest(10),CodeModeLookupTest(1),ScopeResolutionTest(13),MpsListSemanticsTest(34),FindNodeByIdSemanticsTest(7),RenderNodeSemanticsTest(5),RootEditSemanticsTest(7),ModelEditSemanticsTest(9): all pass. Full./gradlew buildpasses;detektMainis clean.Merge Danger
Blast Radius: small
A target that matched before only because its exact text equaled the printed reference still matches. Two behaviors change: a reference with a stale name now resolves, and a model whose name contains a type-designator colon can no longer be addressed by name (MPS model names do not contain colons).