Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
c9d9001a
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c9d9001a
编写于
6月 15, 2011
作者:
D
Dmitry Jemerov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
structure view is in general working
上级
f16a4bb7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
128 addition
and
57 deletion
+128
-57
idea/src/META-INF/plugin.xml
idea/src/META-INF/plugin.xml
+2
-0
idea/src/org/jetbrains/jet/lang/annotations/JetLineMarkerProvider.java
...jetbrains/jet/lang/annotations/JetLineMarkerProvider.java
+25
-53
idea/src/org/jetbrains/jet/plugin/JetIconProvider.java
idea/src/org/jetbrains/jet/plugin/JetIconProvider.java
+55
-0
idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewElement.java
...ins/jet/plugin/structureView/JetStructureViewElement.java
+44
-3
idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewModel.java
...rains/jet/plugin/structureView/JetStructureViewModel.java
+2
-1
未找到文件。
idea/src/META-INF/plugin.xml
浏览文件 @
c9d9001a
...
@@ -22,11 +22,13 @@
...
@@ -22,11 +22,13 @@
<lang.braceMatcher
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.JetPairMatcher"
/>
<lang.braceMatcher
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.JetPairMatcher"
/>
<lang.parserDefinition
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.parsing.JetParserDefinition"
/>
<lang.parserDefinition
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.parsing.JetParserDefinition"
/>
<lang.commenter
language=
"jet"
implementationClass=
"org.jetbrains.jet.plugin.JetCommenter"
/>
<lang.commenter
language=
"jet"
implementationClass=
"org.jetbrains.jet.plugin.JetCommenter"
/>
<lang.psiStructureViewFactory
language=
"jet"
implementationClass=
"org.jetbrains.jet.plugin.structureView.JetStructureViewFactory"
/>
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.SoftKeywordsAnnotator"
/>
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.SoftKeywordsAnnotator"
/>
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.LabelsAnnotator"
/>
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.LabelsAnnotator"
/>
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.JetPsiChecker"
/>
<annotator
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.JetPsiChecker"
/>
<documentationProvider
implementation=
"org.jetbrains.jet.plugin.JetQuickDocumentationProvider"
/>
<documentationProvider
implementation=
"org.jetbrains.jet.plugin.JetQuickDocumentationProvider"
/>
<configurationType
implementation=
"org.jetbrains.jet.run.JetRunConfigurationType"
/>
<configurationType
implementation=
"org.jetbrains.jet.run.JetRunConfigurationType"
/>
<codeInsight.lineMarkerProvider
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.JetLineMarkerProvider"
/>
<codeInsight.lineMarkerProvider
language=
"jet"
implementationClass=
"org.jetbrains.jet.lang.annotations.JetLineMarkerProvider"
/>
<iconProvider
implementation=
"org.jetbrains.jet.plugin.JetIconProvider"
/>
</extensions>
</extensions>
</idea-plugin>
</idea-plugin>
idea/src/org/jetbrains/jet/lang/annotations/JetLineMarkerProvider.java
浏览文件 @
c9d9001a
...
@@ -11,19 +11,20 @@ import com.intellij.ide.util.DefaultPsiElementCellRenderer;
...
@@ -11,19 +11,20 @@ import com.intellij.ide.util.DefaultPsiElementCellRenderer;
import
com.intellij.openapi.ui.popup.JBPopup
;
import
com.intellij.openapi.ui.popup.JBPopup
;
import
com.intellij.openapi.ui.popup.JBPopupFactory
;
import
com.intellij.openapi.ui.popup.JBPopupFactory
;
import
com.intellij.openapi.util.IconLoader
;
import
com.intellij.openapi.util.IconLoader
;
import
com.intellij.openapi.util.Iconable
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
com.intellij.psi.util.PsiUtilBase
;
import
com.intellij.psi.util.PsiUtilBase
;
import
com.intellij.ui.awt.RelativePoint
;
import
com.intellij.ui.awt.RelativePoint
;
import
com.intellij.util.Function
;
import
com.intellij.util.Function
;
import
com.intellij.util.Icons
;
import
com.intellij.util.Icons
;
import
com.intellij.util.PsiIconUtil
;
import
com.intellij.util.PsiNavigateUtil
;
import
com.intellij.util.PsiNavigateUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.resolve.AnalyzingUtils
;
import
org.jetbrains.jet.lang.resolve.AnalyzingUtils
;
import
org.jetbrains.jet.lang.resolve.BindingContext
;
import
org.jetbrains.jet.lang.resolve.BindingContext
;
import
org.jetbrains.jet.lexer.JetTokens
;
import
org.jetbrains.jet.resolve.DescriptorRenderer
;
import
org.jetbrains.jet.resolve.DescriptorRenderer
;
import
javax.swing.*
;
import
javax.swing.*
;
...
@@ -38,7 +39,6 @@ import java.util.Set;
...
@@ -38,7 +39,6 @@ import java.util.Set;
public
class
JetLineMarkerProvider
implements
LineMarkerProvider
{
public
class
JetLineMarkerProvider
implements
LineMarkerProvider
{
public
static
final
Icon
OVERRIDING_FUNCTION
=
IconLoader
.
getIcon
(
"/general/overridingMethod.png"
);
public
static
final
Icon
OVERRIDING_FUNCTION
=
IconLoader
.
getIcon
(
"/general/overridingMethod.png"
);
public
static
final
Icon
ICON_FOR_OBJECT
=
Icons
.
ANONYMOUS_CLASS_ICON
;
@Override
@Override
public
LineMarkerInfo
getLineMarkerInfo
(
PsiElement
element
)
{
public
LineMarkerInfo
getLineMarkerInfo
(
PsiElement
element
)
{
...
@@ -49,47 +49,16 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
...
@@ -49,47 +49,16 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
if
(
element
instanceof
JetClass
)
{
if
(
element
instanceof
JetClass
)
{
JetClass
jetClass
=
(
JetClass
)
element
;
JetClass
jetClass
=
(
JetClass
)
element
;
Icon
icon
=
jetClass
.
hasModifier
(
JetTokens
.
ENUM_KEYWORD
)
?
Icons
.
ENUM_ICON
:
Icons
.
CLASS_ICON
;
ClassDescriptor
classDescriptor
=
bindingContext
.
getClassDescriptor
(
jetClass
);
if
(
jetClass
instanceof
JetEnumEntry
)
{
String
text
=
classDescriptor
==
null
?
"<i>Unresolved</i>"
:
DescriptorRenderer
.
HTML
.
render
(
classDescriptor
);
JetEnumEntry
enumEntry
=
(
JetEnumEntry
)
jetClass
;
return
createLineMarkerInfo
(
jetClass
,
text
);
if
(
enumEntry
.
getPrimaryConstructorParameterList
()
==
null
)
{
icon
=
ICON_FOR_OBJECT
;
}
}
return
new
LineMarkerInfo
<
JetClass
>(
jetClass
,
jetClass
.
getTextOffset
(),
icon
,
Pass
.
UPDATE_ALL
,
new
Function
<
JetClass
,
String
>()
{
@Override
public
String
fun
(
JetClass
jetClass
)
{
ClassDescriptor
classDescriptor
=
bindingContext
.
getClassDescriptor
(
jetClass
);
if
(
classDescriptor
==
null
)
{
return
"<it>Unresolved</it>"
;
}
return
DescriptorRenderer
.
HTML
.
render
(
classDescriptor
);
}
},
new
GutterIconNavigationHandler
<
JetClass
>()
{
@Override
public
void
navigate
(
MouseEvent
e
,
JetClass
elt
)
{
}
});
}
}
if
(
element
instanceof
JetProperty
)
{
if
(
element
instanceof
JetProperty
)
{
JetProperty
jetProperty
=
(
JetProperty
)
element
;
JetProperty
jetProperty
=
(
JetProperty
)
element
;
final
VariableDescriptor
variableDescriptor
=
bindingContext
.
getVariableDescriptor
(
jetProperty
);
final
VariableDescriptor
variableDescriptor
=
bindingContext
.
getVariableDescriptor
(
jetProperty
);
if
(
variableDescriptor
instanceof
PropertyDescriptor
)
{
if
(
variableDescriptor
instanceof
PropertyDescriptor
)
{
return
new
LineMarkerInfo
<
JetProperty
>(
jetProperty
,
jetProperty
.
getTextOffset
(),
Icons
.
PROPERTY_ICON
,
Pass
.
UPDATE_ALL
,
return
createLineMarkerInfo
(
element
,
DescriptorRenderer
.
HTML
.
render
(
variableDescriptor
));
new
Function
<
JetProperty
,
String
>()
{
@Override
public
String
fun
(
JetProperty
property
)
{
return
DescriptorRenderer
.
HTML
.
render
(
variableDescriptor
);
}
},
new
GutterIconNavigationHandler
<
JetProperty
>()
{
@Override
public
void
navigate
(
MouseEvent
e
,
JetProperty
elt
)
{
}
});
}
}
}
}
...
@@ -164,22 +133,8 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
...
@@ -164,22 +133,8 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
}
}
if
(
element
instanceof
JetNamespace
)
{
if
(
element
instanceof
JetNamespace
)
{
JetNamespace
jetNamespace
=
(
JetNamespace
)
element
;
return
createLineMarkerInfo
((
JetNamespace
)
element
,
return
new
LineMarkerInfo
<
JetNamespace
>(
DescriptorRenderer
.
HTML
.
render
(
bindingContext
.
getNamespaceDescriptor
((
JetNamespace
)
element
)));
jetNamespace
,
jetNamespace
.
getTextOffset
(),
Icons
.
PACKAGE_ICON
,
Pass
.
UPDATE_ALL
,
new
Function
<
JetNamespace
,
String
>()
{
@Override
public
String
fun
(
JetNamespace
jetNamespace
)
{
NamespaceDescriptor
namespaceDescriptor
=
bindingContext
.
getNamespaceDescriptor
(
jetNamespace
);
return
DescriptorRenderer
.
HTML
.
render
(
namespaceDescriptor
);
}
},
new
GutterIconNavigationHandler
<
JetNamespace
>()
{
@Override
public
void
navigate
(
MouseEvent
e
,
JetNamespace
elt
)
{
}
}
);
}
}
if
(
element
instanceof
JetObjectDeclaration
&&
!(
element
.
getParent
()
instanceof
JetExpression
))
{
if
(
element
instanceof
JetObjectDeclaration
&&
!(
element
.
getParent
()
instanceof
JetExpression
))
{
...
@@ -208,6 +163,23 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
...
@@ -208,6 +163,23 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
return
null
;
return
null
;
}
}
private
<
T
extends
PsiElement
>
LineMarkerInfo
<
T
>
createLineMarkerInfo
(
T
element
,
final
String
text
)
{
return
new
LineMarkerInfo
<
T
>(
element
,
element
.
getTextOffset
(),
PsiIconUtil
.
getProvidersIcon
(
element
,
Iconable
.
ICON_FLAG_CLOSED
),
Pass
.
UPDATE_ALL
,
new
Function
<
T
,
String
>()
{
@Override
public
String
fun
(
T
jetNamespace
)
{
return
text
;
}
},
new
GutterIconNavigationHandler
<
T
>()
{
@Override
public
void
navigate
(
MouseEvent
e
,
T
elt
)
{
}
}
);
}
private
boolean
isMember
(
@NotNull
FunctionDescriptor
functionDescriptor
)
{
private
boolean
isMember
(
@NotNull
FunctionDescriptor
functionDescriptor
)
{
return
functionDescriptor
.
getContainingDeclaration
().
getOriginal
()
instanceof
ClassifierDescriptor
;
return
functionDescriptor
.
getContainingDeclaration
().
getOriginal
()
instanceof
ClassifierDescriptor
;
}
}
...
...
idea/src/org/jetbrains/jet/plugin/JetIconProvider.java
0 → 100644
浏览文件 @
c9d9001a
package
org.jetbrains.jet.plugin
;
import
com.intellij.ide.IconProvider
;
import
com.intellij.openapi.util.Iconable
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.util.PsiTreeUtil
;
import
com.intellij.util.Icons
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lexer.JetTokens
;
import
javax.swing.*
;
/**
* @author yole
*/
public
class
JetIconProvider
extends
IconProvider
{
public
static
final
Icon
ICON_FOR_OBJECT
=
Icons
.
ANONYMOUS_CLASS_ICON
;
@Override
public
Icon
getIcon
(
@NotNull
PsiElement
psiElement
,
int
flags
)
{
if
(
psiElement
instanceof
JetNamespace
)
{
return
(
flags
&
Iconable
.
ICON_FLAG_OPEN
)
!=
0
?
Icons
.
PACKAGE_OPEN_ICON
:
Icons
.
PACKAGE_ICON
;
}
if
(
psiElement
instanceof
JetFunction
)
{
return
PsiTreeUtil
.
getParentOfType
(
psiElement
,
JetNamedDeclaration
.
class
)
instanceof
JetClass
?
Icons
.
METHOD_ICON
:
Icons
.
FUNCTION_ICON
;
}
if
(
psiElement
instanceof
JetClass
)
{
JetClass
jetClass
=
(
JetClass
)
psiElement
;
Icon
icon
=
jetClass
.
hasModifier
(
JetTokens
.
ENUM_KEYWORD
)
?
Icons
.
ENUM_ICON
:
Icons
.
CLASS_ICON
;
if
(
jetClass
instanceof
JetEnumEntry
)
{
JetEnumEntry
enumEntry
=
(
JetEnumEntry
)
jetClass
;
if
(
enumEntry
.
getPrimaryConstructorParameterList
()
==
null
)
{
icon
=
ICON_FOR_OBJECT
;
}
}
return
icon
;
}
if
(
psiElement
instanceof
JetParameter
)
{
if
(((
JetParameter
)
psiElement
).
getValOrVarNode
()
!=
null
)
{
JetParameterList
parameterList
=
PsiTreeUtil
.
getParentOfType
(
psiElement
,
JetParameterList
.
class
);
if
(
parameterList
!=
null
&&
parameterList
.
getParent
()
instanceof
JetClass
)
{
return
Icons
.
PROPERTY_ICON
;
}
}
return
Icons
.
PARAMETER_ICON
;
}
if
(
psiElement
instanceof
JetProperty
)
{
return
Icons
.
PROPERTY_ICON
;
}
return
null
;
}
}
idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewElement.java
浏览文件 @
c9d9001a
...
@@ -5,9 +5,14 @@ import com.intellij.ide.util.treeView.smartTree.TreeElement;
...
@@ -5,9 +5,14 @@ import com.intellij.ide.util.treeView.smartTree.TreeElement;
import
com.intellij.navigation.ItemPresentation
;
import
com.intellij.navigation.ItemPresentation
;
import
com.intellij.openapi.editor.colors.TextAttributesKey
;
import
com.intellij.openapi.editor.colors.TextAttributesKey
;
import
com.intellij.openapi.util.Iconable
;
import
com.intellij.openapi.util.Iconable
;
import
com.intellij.openapi.util.text.StringUtil
;
import
com.intellij.psi.NavigatablePsiElement
;
import
com.intellij.psi.NavigatablePsiElement
;
import
com.intellij.util.PsiIconUtil
;
import
org.jetbrains.jet.lang.psi.*
;
import
javax.swing.*
;
import
javax.swing.*
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* @author yole
* @author yole
...
@@ -44,7 +49,13 @@ public class JetStructureViewElement implements StructureViewTreeElement {
...
@@ -44,7 +49,13 @@ public class JetStructureViewElement implements StructureViewTreeElement {
return
new
ItemPresentation
()
{
return
new
ItemPresentation
()
{
@Override
@Override
public
String
getPresentableText
()
{
public
String
getPresentableText
()
{
return
""
;
String
name
=
myElement
.
getName
();
if
(
StringUtil
.
isEmpty
(
name
))
{
if
(
myElement
instanceof
JetClassInitializer
)
{
return
"<class initializer>"
;
}
}
return
name
;
}
}
@Override
@Override
...
@@ -54,7 +65,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
...
@@ -54,7 +65,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
@Override
@Override
public
Icon
getIcon
(
boolean
open
)
{
public
Icon
getIcon
(
boolean
open
)
{
return
myElement
.
getIcon
(
open
?
Iconable
.
ICON_FLAG_OPEN
:
Iconable
.
ICON_FLAG_CLOSED
);
return
PsiIconUtil
.
getProvidersIcon
(
myElement
,
open
?
Iconable
.
ICON_FLAG_OPEN
:
Iconable
.
ICON_FLAG_CLOSED
);
}
}
@Override
@Override
...
@@ -66,6 +77,36 @@ public class JetStructureViewElement implements StructureViewTreeElement {
...
@@ -66,6 +77,36 @@ public class JetStructureViewElement implements StructureViewTreeElement {
@Override
@Override
public
TreeElement
[]
getChildren
()
{
public
TreeElement
[]
getChildren
()
{
return
new
TreeElement
[
0
];
//To change body of implemented methods use File | Settings | File Templates.
if
(
myElement
instanceof
JetFile
)
{
JetNamespace
rootNamespace
=
((
JetFile
)
myElement
).
getRootNamespace
();
return
new
TreeElement
[]
{
new
JetStructureViewElement
((
rootNamespace
))
};
}
else
if
(
myElement
instanceof
JetNamespace
)
{
return
wrapDeclarations
(((
JetNamespace
)
myElement
).
getDeclarations
());
}
else
if
(
myElement
instanceof
JetClass
)
{
JetClass
jetClass
=
(
JetClass
)
myElement
;
List
<
JetDeclaration
>
declarations
=
new
ArrayList
<
JetDeclaration
>();
for
(
JetParameter
parameter
:
jetClass
.
getPrimaryConstructorParameters
())
{
if
(
parameter
.
getValOrVarNode
()
!=
null
)
{
declarations
.
add
(
parameter
);
}
}
declarations
.
addAll
(
jetClass
.
getDeclarations
());
return
wrapDeclarations
(
declarations
);
}
else
if
(
myElement
instanceof
JetClassOrObject
)
{
return
wrapDeclarations
(((
JetClassOrObject
)
myElement
).
getDeclarations
());
}
return
new
TreeElement
[
0
];
}
private
static
TreeElement
[]
wrapDeclarations
(
List
<
JetDeclaration
>
declarations
)
{
TreeElement
[]
result
=
new
TreeElement
[
declarations
.
size
()];
for
(
int
i
=
0
;
i
<
declarations
.
size
();
i
++)
{
result
[
i
]
=
new
JetStructureViewElement
(
declarations
.
get
(
i
));
}
return
result
;
}
}
}
}
idea/src/org/jetbrains/jet/plugin/structureView/JetStructureViewModel.java
浏览文件 @
c9d9001a
package
org.jetbrains.jet.plugin.structureView
;
package
org.jetbrains.jet.plugin.structureView
;
import
com.intellij.ide.structureView.StructureViewModelBase
;
import
com.intellij.ide.structureView.StructureViewModelBase
;
import
com.intellij.ide.structureView.StructureViewTreeElement
;
import
com.intellij.psi.PsiFile
;
import
com.intellij.psi.PsiFile
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.JetDeclaration
;
/**
/**
* @author yole
* @author yole
...
@@ -11,5 +11,6 @@ import org.jetbrains.annotations.NotNull;
...
@@ -11,5 +11,6 @@ import org.jetbrains.annotations.NotNull;
public
class
JetStructureViewModel
extends
StructureViewModelBase
{
public
class
JetStructureViewModel
extends
StructureViewModelBase
{
public
JetStructureViewModel
(
@NotNull
PsiFile
psiFile
)
{
public
JetStructureViewModel
(
@NotNull
PsiFile
psiFile
)
{
super
(
psiFile
,
new
JetStructureViewElement
(
psiFile
));
super
(
psiFile
,
new
JetStructureViewElement
(
psiFile
));
withSuitableClasses
(
JetDeclaration
.
class
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录