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

Spoon CompilationUnit improvements #2254

Closed
8 tasks done
pvojtechovsky opened this issue Jul 21, 2018 · 2 comments
Closed
8 tasks done

Spoon CompilationUnit improvements #2254

pvojtechovsky opened this issue Jul 21, 2018 · 2 comments

Comments

@pvojtechovsky
Copy link
Collaborator

pvojtechovsky commented Jul 21, 2018

This issue is related to #1785

Sniper mode printer needs to handle package reference , import x.y.z; and list of types of compilation unit.
It brings several requirements on compilation unit.

  • The compilation unit should implement SourcePositionHolder so it may act as root of the tree of source fragments (see review: feat: CompilationUnit extends SourcePositionHolder #2255)
  • The compilation unit should have new property CtPackageDeclaration packageDeclaration
  • packageDeclaration should hold SourcePosition of the line package x.y.z;. (see fix: CtPackageDeclaration position doesn't include top file comment #2811)
  • CtCompilationUnitImpl#declaredTypeRefs should be declared as @MetamodelPropertyField(DECLARED_TYPE_REF) ... including @PropertyGetter and @PropertySetter on interface and appropriate RoleHandler
  • CtCompilationUnitImpl#imports should be declared as @MetamodelPropertyField(DECLARED_IMPORT) ... including @PropertyGetter and @PropertySetter on interface and appropriate RoleHandler
  • CtCompilationUnitImpl#packageDeclaration should be declared as @MetamodelPropertyField(PACKAGE_DECLARATION) ... including @PropertyGetter and @PropertySetter on interface and appropriate RoleHandler
  • CtCompilationUnit should implement CtElement (which extends CtVisitable) and CtScanner should visit package reference, imports and all declared type references.
  • CtImport.getParent() should return instance of CompilationUnit (therefore it must extend CtElement)

Concept related to Spoon AST model
CtCompilationUnit is not accessible from CtModel. It is not part of it's parent/child tree.
Each CtCompilationUnit is a root of own model, which has no parent, and has these children:

  • package reference
  • module reference
  • imports
  • references to included types.

WDYT? Do you see any problem? Drop here a note if you would have time to implement some part of that.

surli pushed a commit that referenced this issue Jul 22, 2018
`CompilationUnit` extends `SourcePositionHolder` now, so it can act as root of source fragments - as needed for sniper mode pretty printer as discussed in #2254.
@tdurieux
Copy link
Collaborator

tdurieux commented Jul 22, 2018

CompilationUnit should implement CtElement is a big change, and kind of broke the tree representation of the AST. Honestly, I don't fully understand the impact that this change can have on existing clients.

But I think it is important.

It also solves an issue that we have with comments, such as license, that should be associated with the compilation unit and not really with a class.

For the moment, I don't see problem.

@pvojtechovsky
Copy link
Collaborator Author

Last changes suggested here were merged in last days. So I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants