idea: significant enhancements to ide experience

This commit is contained in:
2023-09-22 22:38:06 -07:00
parent 83c24843a3
commit c340cfb86d
46 changed files with 450 additions and 131 deletions

View File

@ -70,13 +70,15 @@ class AstPorkIdeaCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
),
inherits = mutableListOf("${baseType}(node)"),
imports = mutableListOf(
"com.intellij.lang.ASTNode"
"com.intellij.lang.ASTNode",
"gay.pizza.pork.idea.psi.PorkElementHelpers",
"javax.swing.Icon",
"com.intellij.navigation.ItemPresentation"
)
)
if (baseType == "PorkNamedElement") {
kotlinClass.imports.add(0, "com.intellij.psi.PsiElement")
kotlinClass.imports.add("gay.pizza.pork.idea.psi.PorkElementHelpers")
val getNameFunction = KotlinFunction(
"getName",
overridden = true,
@ -111,7 +113,6 @@ class AstPorkIdeaCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
if (type.referencedElementValue != null && type.referencedElementType != null) {
kotlinClass.imports.add(0, "com.intellij.psi.PsiReference")
kotlinClass.imports.add("gay.pizza.pork.ast.NodeType")
kotlinClass.imports.add("gay.pizza.pork.idea.psi.PorkElementHelpers")
val getReferenceFunction = KotlinFunction(
"getReference",
@ -123,6 +124,27 @@ class AstPorkIdeaCodegen(pkg: String, outputDirectory: Path, world: AstWorld) :
kotlinClass.functions.add(getReferenceFunction)
}
val getIconFunction = KotlinFunction(
"getIcon",
overridden = true,
returnType = "Icon?",
parameters = mutableListOf(
KotlinParameter("flags", "Int")
),
isImmediateExpression = true
)
getIconFunction.body.add("PorkElementHelpers.iconOf(this)")
kotlinClass.functions.add(getIconFunction)
val getPresentationFunction = KotlinFunction(
"getPresentation",
overridden = true,
returnType = "ItemPresentation?",
isImmediateExpression = true
)
getPresentationFunction.body.add("PorkElementHelpers.presentationOf(this)")
kotlinClass.functions.add(getPresentationFunction)
write("${type.name}Element.kt", KotlinWriter(kotlinClass))
}

View File

@ -195,7 +195,7 @@ class KotlinWriter() {
appendLine("package $pkg")
appendLine()
for (import in imports) {
for (import in imports.toSortedSet()) {
appendLine("import $import")
}