Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a clone of the parsed document available in compilation #3338

Closed

Conversation

keyboardDrummer
Copy link
Member

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@@ -938,8 +938,8 @@ public class ModuleDefinition : INode, IDeclarationOrUsage, INamedRegion, IAttri
public override IEnumerable<INode> Children => (Attributes != null ? new List<INode> { Attributes } : Enumerable.Empty<INode>()).Concat(TopLevelDecls);
}

public class DefaultModuleDecl : ModuleDefinition {
public DefaultModuleDecl()
public class DefaultModuleDef : ModuleDefinition {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhhhh I was wondering why I was always confused by module declarations and module definitions.... you nailed it !

var symbolTable = symbolTableFactory.CreateFrom(program, compilationUnit, cancellationToken);
var textDocument = documentAfterParsing.TextDocumentItem;
var parsedProgram = documentAfterParsing.Program;
var clonedProgram = new Program(parsedProgram.Name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops the cloning removes all the ranges and owned tokens, that means that the parsed document will be useless for formatting... I don't think we can get around solving #3290 now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not just clone those as well? Not cloning them seems like a bug

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but since they are not part of the constructor, we might forget about them, either in current cloners, in future cloners, or in future language constructs. Anyway, we can add the range manually for now.

@keyboardDrummer keyboardDrummer deleted the parsedDocument branch December 1, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants