Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
jetbrains-plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
jetbrains-plugin
Commits
e598ce02
Commit
e598ce02
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
add inter-type declarations and attributes to structure view
parent
adde402f
No related branches found
No related tags found
1 merge request
!5
Resolve "Structure View Support"
Pipeline
#12041
passed
3 years ago
Stage: test
Stage: jar
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/jastadd/tooling/aspect/AspectStructureViewElement.java
+152
-8
152 additions, 8 deletions
...rg/jastadd/tooling/aspect/AspectStructureViewElement.java
with
152 additions
and
8 deletions
src/main/java/org/jastadd/tooling/aspect/AspectStructureViewElement.java
+
152
−
8
View file @
e598ce02
package
org.jastadd.tooling.aspect
;
package
org.jastadd.tooling.aspect
;
import
com.intellij.icons.AllIcons
;
import
com.intellij.ide.projectView.PresentationData
;
import
com.intellij.ide.projectView.PresentationData
;
import
com.intellij.ide.structureView.StructureViewTreeElement
;
import
com.intellij.ide.structureView.StructureViewTreeElement
;
import
com.intellij.ide.util.treeView.smartTree.SortableTreeElement
;
import
com.intellij.ide.util.treeView.smartTree.SortableTreeElement
;
import
com.intellij.ide.util.treeView.smartTree.TreeElement
;
import
com.intellij.ide.util.treeView.smartTree.TreeElement
;
import
com.intellij.navigation.ItemPresentation
;
import
com.intellij.navigation.ItemPresentation
;
import
com.intellij.openapi.util.NlsSafe
;
import
com.intellij.psi.NavigatablePsiElement
;
import
com.intellij.psi.NavigatablePsiElement
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
org.jastadd.tooling.aspect.psi.AspectFile
;
import
org.jastadd.tooling.aspect.psi.*
;
import
org.jastadd.tooling.aspect.psi.JastAddAspectAspectBodyDeclaration
;
import
org.jastadd.tooling.aspect.psi.impl.*
;
import
org.jastadd.tooling.aspect.psi.JastAddAspectAspectDeclaration
;
import
org.jastadd.tooling.util.JastAddIcons
;
import
org.jastadd.tooling.aspect.psi.JastAddAspectTypeDeclaration
;
import
org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectDeclarationImpl
;
import
org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectInhAttributeDeclarationImpl
;
import
org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectSynAttributeDeclarationImpl
;
import
org.jastadd.tooling.aspect.psi.impl.JastAddAspectCollectionAttributeImpl
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
javax.swing.*
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
public
class
AspectStructureViewElement
implements
StructureViewTreeElement
,
SortableTreeElement
{
public
class
AspectStructureViewElement
implements
StructureViewTreeElement
,
SortableTreeElement
{
...
@@ -58,9 +59,133 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
...
@@ -58,9 +59,133 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
@Override
@Override
public
ItemPresentation
getPresentation
()
{
public
ItemPresentation
getPresentation
()
{
ItemPresentation
presentation
=
myElement
.
getPresentation
();
ItemPresentation
presentation
=
myElement
.
getPresentation
();
if
(
presentation
==
null
)
{
if
(
myElement
instanceof
JastAddAspectAspectMethodDeclaration
)
{
presentation
=
new
ItemPresentation
()
{
@Override
public
String
getPresentableText
()
{
return
AspectStructureViewElement
.
getPresentableText
((
JastAddAspectAspectMethodDeclaration
)
myElement
);
}
@Override
public
Icon
getIcon
(
boolean
unused
)
{
return
AllIcons
.
Nodes
.
Method
;
}
};
}
else
if
(
myElement
instanceof
JastAddAspectAspectClassDeclaration
)
{
presentation
=
new
ItemPresentation
()
{
@Override
public
String
getPresentableText
()
{
return
AspectStructureViewElement
.
getPresentableText
((
JastAddAspectAspectClassDeclaration
)
myElement
);
}
@Override
public
Icon
getIcon
(
boolean
unused
)
{
return
AllIcons
.
Nodes
.
Class
;
}
};
}
else
if
(
myElement
instanceof
JastAddAspectAspectEnumDeclaration
)
{
presentation
=
new
ItemPresentation
()
{
@Override
public
String
getPresentableText
()
{
return
AspectStructureViewElement
.
getPresentableText
((
JastAddAspectAspectEnumDeclaration
)
myElement
);
}
@Override
public
Icon
getIcon
(
boolean
unused
)
{
return
AllIcons
.
Nodes
.
Enum
;
}
};
}
else
if
(
myElement
instanceof
JastAddAspectAspectInterfaceDeclaration
)
{
presentation
=
new
ItemPresentation
()
{
@Override
public
String
getPresentableText
()
{
return
AspectStructureViewElement
.
getPresentableText
((
JastAddAspectAspectInterfaceDeclaration
)
myElement
);
}
@Override
public
Icon
getIcon
(
boolean
unused
)
{
return
AllIcons
.
Nodes
.
Interface
;
}
};
}
else
if
(
myElement
instanceof
JastAddAspectAspectFieldDeclaration
)
{
presentation
=
new
ItemPresentation
()
{
@Override
public
String
getPresentableText
()
{
return
AspectStructureViewElement
.
getPresentableText
((
JastAddAspectAspectFieldDeclaration
)
myElement
);
}
@Override
public
Icon
getIcon
(
boolean
unused
)
{
return
AllIcons
.
Nodes
.
Field
;
}
};
}
else
if
(
myElement
instanceof
JastAddAspectAspectConstructorDeclaration
)
{
presentation
=
new
ItemPresentation
()
{
@Override
public
String
getPresentableText
()
{
return
AspectStructureViewElement
.
getPresentableText
((
JastAddAspectAspectConstructorDeclaration
)
myElement
);
}
@Override
public
Icon
getIcon
(
boolean
unused
)
{
return
AllIcons
.
Nodes
.
Method
;
}
};
}
}
return
presentation
!=
null
?
presentation
:
new
PresentationData
();
return
presentation
!=
null
?
presentation
:
new
PresentationData
();
}
}
private
static
String
getPresentableText
(
JastAddAspectAspectClassDeclaration
decl
)
{
return
decl
.
getModifiers
().
getText
()
+
" class "
+
decl
.
getClassDeclaration
().
getSimpleTypeName
().
getText
();
}
private
static
String
getPresentableText
(
JastAddAspectAspectEnumDeclaration
decl
)
{
return
decl
.
getModifiers
().
getText
()
+
" class "
+
decl
.
getSimpleTypeName
().
getText
();
}
private
static
String
getPresentableText
(
JastAddAspectAspectInterfaceDeclaration
decl
)
{
return
decl
.
getModifiers
().
getText
()
+
" class "
+
decl
.
getSimpleTypeName
().
getText
();
}
private
static
String
getPresentableText
(
JastAddAspectAspectFieldDeclaration
decl
)
{
return
decl
.
getModifiers
().
getText
()
+
" "
+
decl
.
getAstTypeName
().
getText
()
+
" : "
+
decl
.
getAspectType
().
getText
();
}
private
static
String
getPresentableText
(
JastAddAspectAspectConstructorDeclaration
decl
)
{
return
decl
.
getModifiers
().
getText
()
+
" "
+
decl
.
getAstTypeNameList
().
get
(
0
).
getText
()
+
"."
+
decl
.
getAstTypeNameList
().
get
(
1
).
getText
()
+
decl
.
getFormalParameters
().
getFormalParameterList
().
stream
()
.
map
(
JastAddAspectFormalParameter:
:
getType
)
.
map
(
PsiElement:
:
getText
).
collect
(
Collectors
.
joining
(
", "
,
"("
,
")"
));
}
private
static
String
getPresentableText
(
JastAddAspectAspectMethodDeclaration
decl
)
{
return
decl
.
getModifiers
().
getText
()
+
" "
+
decl
.
getAstTypeName
().
getText
()
+
"."
+
AspectStructureViewElement
.
getPresentableText
(
decl
.
getMethodDeclarator
())
+
" : "
+
decl
.
getAspectResultType
().
getText
();
}
private
static
String
getPresentableText
(
JastAddAspectMethodDeclarator
declarator
)
{
return
declarator
.
getJavaIdentifier
().
getText
()
+
declarator
.
getFormalParameters
().
getFormalParameterList
().
stream
()
.
map
(
JastAddAspectFormalParameter:
:
getType
)
.
map
(
PsiElement:
:
getText
).
collect
(
Collectors
.
joining
(
", "
,
"("
,
")"
));
}
@Override
@Override
public
TreeElement
@NotNull
[]
getChildren
()
{
public
TreeElement
@NotNull
[]
getChildren
()
{
if
(
myElement
instanceof
AspectFile
)
{
if
(
myElement
instanceof
AspectFile
)
{
...
@@ -80,6 +205,18 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
...
@@ -80,6 +205,18 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
return
new
AspectStructureViewElement
((
JastAddAspectAspectInhAttributeDeclarationImpl
)
decl
.
getAspectInhAttributeDeclaration
());
return
new
AspectStructureViewElement
((
JastAddAspectAspectInhAttributeDeclarationImpl
)
decl
.
getAspectInhAttributeDeclaration
());
}
else
if
(
decl
.
getCollectionAttribute
()
!=
null
)
{
}
else
if
(
decl
.
getCollectionAttribute
()
!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectCollectionAttributeImpl
)
decl
.
getCollectionAttribute
());
return
new
AspectStructureViewElement
((
JastAddAspectCollectionAttributeImpl
)
decl
.
getCollectionAttribute
());
}
else
if
(
decl
.
getAspectMethodDeclaration
()
!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectAspectMethodDeclarationImpl
)
decl
.
getAspectMethodDeclaration
());
}
else
if
(
decl
.
getAspectClassDeclaration
()
!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectAspectClassDeclarationImpl
)
decl
.
getAspectClassDeclaration
());
}
else
if
(
decl
.
getAspectEnumDeclaration
()
!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectAspectEnumDeclarationImpl
)
decl
.
getAspectEnumDeclaration
());
}
else
if
(
decl
.
getAspectInterfaceDeclaration
()
!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectAspectInterfaceDeclarationImpl
)
decl
.
getAspectInterfaceDeclaration
());
}
else
if
(
decl
.
getAspectFieldDeclaration
()
!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectAspectFieldDeclarationImpl
)
decl
.
getAspectFieldDeclaration
());
}
else
if
(
decl
.
getAspectConstructorDeclaration
()!=
null
)
{
return
new
AspectStructureViewElement
((
JastAddAspectAspectConstructorDeclarationImpl
)
decl
.
getAspectConstructorDeclaration
());
}
}
return
null
;
return
null
;
})
})
...
@@ -87,6 +224,13 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
...
@@ -87,6 +224,13 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
.
toArray
(
TreeElement
[]::
new
);
.
toArray
(
TreeElement
[]::
new
);
}
}
// aspect_refine_method_declaration
// aspect_refine_constructor_declaration
// aspect_rewrite
// aspect_add_interface
// aspect_extend_interface
return
EMPTY_ARRAY
;
return
EMPTY_ARRAY
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment