Permalink
Browse files

Do not show classes in file node by default in project view

  • Loading branch information...
1 parent c44ee27 commit e06e5198edc4de84fb0d04d19991a0d779c2005e @goodwinnk goodwinnk committed Jun 29, 2012
@@ -44,7 +44,7 @@ public Icon getIcon(@NotNull PsiElement psiElement, int flags) {
if (psiElement instanceof JetFile) {
JetFile file = (JetFile) psiElement;
JetClassOrObject mainClass = getMainClass(file);
- return mainClass != null ? getIcon(mainClass, flags) : JetIcons.FILE;
+ return mainClass != null && file.getDeclarations().size() == 1 ? getIcon(mainClass, flags) : JetIcons.FILE;
}
if (psiElement instanceof JetNamespaceHeader) {
return (flags & Iconable.ICON_FLAG_OPEN) != 0 ? PlatformIcons.PACKAGE_OPEN_ICON : PlatformIcons.PACKAGE_ICON;
@@ -45,14 +45,16 @@ public JetFileTreeNode(Project project, JetFile value, ViewSettings viewSettings
if (file == null) return Collections.emptyList();
ArrayList<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
- List<JetDeclaration> declarations = file.getDeclarations();
-
- for (JetDeclaration declaration : declarations) {
- if (declaration instanceof JetClassOrObject) {
- result.add(new JetClassOrObjectTreeNode(file.getProject(), (JetClassOrObject) declaration, getSettings()));
- }
- else if (getSettings().isShowMembers()) {
- result.add(new JetDeclarationTreeNode(getProject(), declaration, getSettings()));
+ if (getSettings().isShowMembers()) {
+ List<JetDeclaration> declarations = file.getDeclarations();
+
+ for (JetDeclaration declaration : declarations) {
+ if (declaration instanceof JetClassOrObject) {
+ result.add(new JetClassOrObjectTreeNode(file.getProject(), (JetClassOrObject) declaration, getSettings()));
+ }
+ else if (getSettings().isShowMembers()) {
+ result.add(new JetDeclarationTreeNode(getProject(), declaration, getSettings()));
+ }
}
}
@@ -59,7 +59,7 @@ public JetProjectViewProvider(Project project) {
List<JetDeclaration> declarations = file.getDeclarations();
JetClassOrObject mainClass = JetIconProvider.getMainClass(file);
- if (mainClass != null && (!settings.isShowMembers() || declarations.size() == 1)) {
+ if (mainClass != null && declarations.size() == 1) {
result.add(new JetClassOrObjectTreeNode(file.getProject(), mainClass, settings));
}
else {
@@ -106,7 +106,7 @@ public PsiElement getTopLevelElement(PsiElement element) {
return current != null ? current : file;
}
- private boolean isSelectable(PsiElement element) {
+ private static boolean isSelectable(PsiElement element) {
if (element instanceof JetFile) return true;
if (element instanceof JetDeclaration) {
PsiElement parent = element.getParent();

0 comments on commit e06e519

Please sign in to comment.