-
Notifications
You must be signed in to change notification settings - Fork 6
Add a mechanism for renaming anonymous structs #204
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -636,7 +636,12 @@ class Render(manager: Manager, packageName: String = "langoustine.lsp"): | |
| case other => | ||
| val newType = other.traverse { | ||
| case stl: Type.StructureLiteralType => | ||
| val newTypeName = "S" + inlineAnonymousStructures | ||
| val newTypeName = summon[Config].anonNameOverrides | ||
| .get(structure.name.value) | ||
| .fold("S" + inlineAnonymousStructures)( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. technically these
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I think it's worth being strict here – better to fix the names once during update, than to expose
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not completely unreasonable |
||
| _(inlineAnonymousStructures) | ||
| ) | ||
|
|
||
| val newType: Type.ReferenceType = Type.ReferenceType( | ||
| TypeName( | ||
| structure.name.value + "." + newTypeName | ||
|
|
@@ -981,7 +986,11 @@ class Render(manager: Manager, packageName: String = "langoustine.lsp"): | |
| var inlineAnonymousStructures = 0 | ||
| val newType = alias.`type`.traverse { | ||
| case stl: Type.StructureLiteralType => | ||
| val newTypeName = "S" + inlineAnonymousStructures | ||
| val newTypeName = summon[Config].anonNameOverrides | ||
| .get(alias.name.value) | ||
| .fold("S" + inlineAnonymousStructures)( | ||
| _(inlineAnonymousStructures) | ||
| ) | ||
| val newType: Type.ReferenceType = Type.ReferenceType( | ||
| TypeName( | ||
| alias.name.value + "." + newTypeName | ||
|
|
@@ -1202,7 +1211,11 @@ object Render: | |
| def appender: Config ?=> Appender = to(lb) | ||
| end LineBuilder | ||
|
|
||
| case class Config(indents: Indentation, indentSize: IndentationSize) | ||
| case class Config( | ||
| indents: Indentation, | ||
| indentSize: IndentationSize, | ||
| anonNameOverrides: Map[String, List[String]] | ||
| ) | ||
|
|
||
| opaque type IndentationSize = Int | ||
| object IndentationSize extends OpaqueNum[IndentationSize] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't spend enough time with the codebase to have a clue if a struct's renderer knows its FQN, so I went with this for now. It works by a miraculous stroke (of luck) as
ByCells/ByDocumentAndCellsboth have the same structure.