Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
5d926963
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,发现更多精彩内容 >>
提交
5d926963
编写于
4月 04, 2012
作者:
E
Evgeny Gerashchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disabled names highlighting in tests.
上级
c989b2e5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
35 deletion
+37
-35
idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
.../jet/plugin/highlighter/FunctionsHighlightingVisitor.java
+6
-10
idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java
...c/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java
+13
-0
idea/src/org/jetbrains/jet/plugin/highlighter/LabelsHighlightingVisitor.java
...ins/jet/plugin/highlighter/LabelsHighlightingVisitor.java
+2
-6
idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
...jet/plugin/highlighter/PropertiesHighlightingVisitor.java
+4
-7
idea/src/org/jetbrains/jet/plugin/highlighter/TypeKindHighlightingVisitor.java
...s/jet/plugin/highlighter/TypeKindHighlightingVisitor.java
+9
-9
idea/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
.../jet/plugin/highlighter/VariablesHighlightingVisitor.java
+3
-3
未找到文件。
idea/src/org/jetbrains/jet/plugin/highlighter/FunctionsHighlightingVisitor.java
浏览文件 @
5d926963
...
...
@@ -41,8 +41,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
public
void
visitNamedFunction
(
JetNamedFunction
function
)
{
PsiElement
nameIdentifier
=
function
.
getNameIdentifier
();
if
(
nameIdentifier
!=
null
)
{
holder
.
createInfoAnnotation
(
nameIdentifier
,
null
).
setTextAttributes
(
JetHighlightingColors
.
FUNCTION_DECLARATION
);
JetPsiChecker
.
highlightName
(
holder
,
nameIdentifier
,
JetHighlightingColors
.
FUNCTION_DECLARATION
);
}
super
.
visitNamedFunction
(
function
);
...
...
@@ -57,8 +56,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
if
(
typeElement
instanceof
JetUserType
)
{
JetSimpleNameExpression
nameExpression
=
((
JetUserType
)
typeElement
).
getReferenceExpression
();
if
(
nameExpression
!=
null
)
{
holder
.
createInfoAnnotation
(
nameExpression
,
null
).
setTextAttributes
(
JetHighlightingColors
.
CONSTRUCTOR_CALL
);
JetPsiChecker
.
highlightName
(
holder
,
nameExpression
,
JetHighlightingColors
.
CONSTRUCTOR_CALL
);
}
}
}
...
...
@@ -72,20 +70,18 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
DeclarationDescriptor
calleeDescriptor
=
bindingContext
.
get
(
BindingContext
.
REFERENCE_TARGET
,
(
JetReferenceExpression
)
callee
);
if
(
calleeDescriptor
!=
null
)
{
if
(
calleeDescriptor
instanceof
ConstructorDescriptor
)
{
holder
.
createInfoAnnotation
(
callee
,
null
).
setTextAttributes
(
JetHighlightingColors
.
CONSTRUCTOR_CALL
);
JetPsiChecker
.
highlightName
(
holder
,
callee
,
JetHighlightingColors
.
CONSTRUCTOR_CALL
);
}
else
if
(
calleeDescriptor
instanceof
FunctionDescriptor
&&
!(
calleeDescriptor
instanceof
VariableAsFunctionDescriptor
))
{
FunctionDescriptor
fun
=
(
FunctionDescriptor
)
calleeDescriptor
;
if
(
fun
.
getReceiverParameter
()
!=
ReceiverDescriptor
.
NO_RECEIVER
)
{
holder
.
createInfoAnnotation
(
callee
,
null
).
setTextAttributes
(
JetHighlightingColors
.
EXTENSION_FUNCTION_CALL
);
JetPsiChecker
.
highlightName
(
holder
,
callee
,
JetHighlightingColors
.
EXTENSION_FUNCTION_CALL
);
}
else
if
(
fun
.
getContainingDeclaration
()
instanceof
NamespaceDescriptor
)
{
holder
.
createInfoAnnotation
(
callee
,
null
).
setTextAttributes
(
JetHighlightingColors
.
NAMESPACE_FUNCTION_CALL
);
JetPsiChecker
.
highlightName
(
holder
,
callee
,
JetHighlightingColors
.
NAMESPACE_FUNCTION_CALL
);
}
else
{
holder
.
createInfoAnnotation
(
callee
,
null
).
setTextAttributes
(
JetHighlightingColors
.
FUNCTION_CALL
);
JetPsiChecker
.
highlightName
(
holder
,
callee
,
JetHighlightingColors
.
FUNCTION_CALL
);
}
}
}
...
...
idea/src/org/jetbrains/jet/plugin/highlighter/JetPsiChecker.java
浏览文件 @
5d926963
...
...
@@ -23,6 +23,7 @@ import com.intellij.lang.annotation.Annotation;
import
com.intellij.lang.annotation.AnnotationHolder
;
import
com.intellij.lang.annotation.Annotator
;
import
com.intellij.openapi.application.ApplicationManager
;
import
com.intellij.openapi.editor.colors.TextAttributesKey
;
import
com.intellij.openapi.progress.ProcessCanceledException
;
import
com.intellij.openapi.util.TextRange
;
import
com.intellij.psi.MultiRangeReference
;
...
...
@@ -55,6 +56,18 @@ public class JetPsiChecker implements Annotator {
return
errorReportingEnabled
;
}
static
boolean
isNamesHighlightingEnabled
()
{
return
!
ApplicationManager
.
getApplication
().
isUnitTestMode
();
}
static
void
highlightName
(
@NotNull
AnnotationHolder
holder
,
@NotNull
PsiElement
psiElement
,
@NotNull
TextAttributesKey
attributesKey
)
{
if
(
isNamesHighlightingEnabled
())
{
holder
.
createInfoAnnotation
(
psiElement
,
null
).
setTextAttributes
(
attributesKey
);
}
}
private
static
HighlightingVisitor
[]
getBeforeAnalysisVisitors
(
AnnotationHolder
holder
)
{
return
new
HighlightingVisitor
[]{
new
SoftKeywordsHighlightingVisitor
(
holder
),
...
...
idea/src/org/jetbrains/jet/plugin/highlighter/LabelsHighlightingVisitor.java
浏览文件 @
5d926963
...
...
@@ -20,13 +20,9 @@
package
org.jetbrains.jet.plugin.highlighter
;
import
com.intellij.lang.annotation.AnnotationHolder
;
import
com.intellij.lang.annotation.Annotator
;
import
com.intellij.psi.PsiElement
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.JetLabelQualifiedExpression
;
import
org.jetbrains.jet.lang.psi.JetPrefixExpression
;
import
org.jetbrains.jet.lang.psi.JetSimpleNameExpression
;
import
org.jetbrains.jet.lang.psi.JetVisitorVoid
;
import
org.jetbrains.jet.lexer.JetTokens
;
class
LabelsHighlightingVisitor
extends
HighlightingVisitor
{
...
...
@@ -38,7 +34,7 @@ class LabelsHighlightingVisitor extends HighlightingVisitor {
public
void
visitPrefixExpression
(
JetPrefixExpression
expression
)
{
JetSimpleNameExpression
operationSign
=
expression
.
getOperationReference
();
if
(
JetTokens
.
LABELS
.
contains
(
operationSign
.
getReferencedNameElementType
()))
{
holder
.
createInfoAnnotation
(
operationSign
,
null
).
setTextAttributes
(
JetHighlightingColors
.
LABEL
);
JetPsiChecker
.
highlightName
(
holder
,
operationSign
,
JetHighlightingColors
.
LABEL
);
}
}
...
...
@@ -46,7 +42,7 @@ class LabelsHighlightingVisitor extends HighlightingVisitor {
public
void
visitLabelQualifiedExpression
(
JetLabelQualifiedExpression
expression
)
{
JetSimpleNameExpression
targetLabel
=
expression
.
getTargetLabel
();
if
(
targetLabel
!=
null
)
{
holder
.
createInfoAnnotation
(
targetLabel
,
null
).
setTextAttributes
(
JetHighlightingColors
.
LABEL
);
JetPsiChecker
.
highlightName
(
holder
,
targetLabel
,
JetHighlightingColors
.
LABEL
);
}
}
}
idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java
浏览文件 @
5d926963
...
...
@@ -41,14 +41,13 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
}
if
(((
PropertyDescriptor
)
target
).
getReceiverParameter
()
!=
ReceiverDescriptor
.
NO_RECEIVER
)
{
holder
.
createInfoAnnotation
(
expression
,
null
).
setTextAttributes
(
JetHighlightingColors
.
EXTENSION_PROPERTY
);
JetPsiChecker
.
highlightName
(
holder
,
expression
,
JetHighlightingColors
.
EXTENSION_PROPERTY
);
}
boolean
namespace
=
target
.
getContainingDeclaration
()
instanceof
NamespaceDescriptor
;
putPropertyAnnotation
(
expression
,
namespace
,
false
);
if
(
expression
.
getReferencedNameElementType
()
==
JetTokens
.
FIELD_IDENTIFIER
)
{
holder
.
createInfoAnnotation
(
expression
,
null
).
setTextAttributes
(
JetHighlightingColors
.
BACKING_FIELD_ACCESS
);
JetPsiChecker
.
highlightName
(
holder
,
expression
,
JetHighlightingColors
.
BACKING_FIELD_ACCESS
);
}
}
...
...
@@ -83,10 +82,8 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
}
private
void
putPropertyAnnotation
(
@NotNull
PsiElement
elementToHighlight
,
boolean
namespace
,
boolean
withBackingField
)
{
holder
.
createInfoAnnotation
(
elementToHighlight
,
null
).
setTextAttributes
(
namespace
?
JetHighlightingColors
.
NAMESPACE_PROPERTY
:
JetHighlightingColors
.
INSTANCE_PROPERTY
JetPsiChecker
.
highlightName
(
holder
,
elementToHighlight
,
namespace
?
JetHighlightingColors
.
NAMESPACE_PROPERTY
:
JetHighlightingColors
.
INSTANCE_PROPERTY
);
if
(
withBackingField
)
{
holder
.
createInfoAnnotation
(
...
...
idea/src/org/jetbrains/jet/plugin/highlighter/TypeKindHighlightingVisitor.java
浏览文件 @
5d926963
...
...
@@ -16,7 +16,6 @@
package
org.jetbrains.jet.plugin.highlighter
;
import
com.intellij.lang.annotation.Annotation
;
import
com.intellij.lang.annotation.AnnotationHolder
;
import
com.intellij.openapi.editor.colors.TextAttributesKey
;
import
com.intellij.psi.PsiElement
;
...
...
@@ -51,11 +50,13 @@ class TypeKindHighlightingVisitor extends HighlightingVisitor {
private
void
visitNameExpression
(
JetExpression
expression
)
{
PsiReference
ref
=
expression
.
getReference
();
if
(
ref
==
null
)
return
;
PsiElement
target
=
ref
.
resolve
();
if
(
target
instanceof
JetClass
)
{
highlightClassByKind
((
JetClass
)
target
,
expression
);
}
else
if
(
target
instanceof
JetTypeParameter
)
{
holder
.
createInfoAnnotation
(
expression
,
null
).
setTextAttributes
(
JetHighlightingColors
.
TYPE_PARAMETER
);
if
(
JetPsiChecker
.
isNamesHighlightingEnabled
())
{
PsiElement
target
=
ref
.
resolve
();
if
(
target
instanceof
JetClass
)
{
highlightClassByKind
((
JetClass
)
target
,
expression
);
}
else
if
(
target
instanceof
JetTypeParameter
)
{
JetPsiChecker
.
highlightName
(
holder
,
expression
,
JetHighlightingColors
.
TYPE_PARAMETER
);
}
}
}
...
...
@@ -73,7 +74,7 @@ class TypeKindHighlightingVisitor extends HighlightingVisitor {
public
void
visitTypeParameter
(
JetTypeParameter
parameter
)
{
PsiElement
identifier
=
parameter
.
getNameIdentifier
();
if
(
identifier
!=
null
)
{
holder
.
createInfoAnnotation
(
identifier
,
null
).
setTextAttributes
(
JetHighlightingColors
.
TYPE_PARAMETER
);
JetPsiChecker
.
highlightName
(
holder
,
identifier
,
JetHighlightingColors
.
TYPE_PARAMETER
);
}
}
...
...
@@ -99,7 +100,6 @@ class TypeKindHighlightingVisitor extends HighlightingVisitor {
}
}
}
Annotation
annotation
=
holder
.
createInfoAnnotation
(
whatToHighlight
,
null
);
annotation
.
setTextAttributes
(
textAttributes
);
JetPsiChecker
.
highlightName
(
holder
,
whatToHighlight
,
textAttributes
);
}
}
idea/src/org/jetbrains/jet/plugin/highlighter/VariablesHighlightingVisitor.java
浏览文件 @
5d926963
...
...
@@ -94,7 +94,7 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
if
(
descriptor
instanceof
VariableDescriptor
)
{
VariableDescriptor
variableDescriptor
=
(
VariableDescriptor
)
descriptor
;
if
(
variableDescriptor
.
isVar
())
{
holder
.
createInfoAnnotation
(
elementToHighlight
,
null
).
setTextAttributes
(
JetHighlightingColors
.
MUTABLE_VARIABLE
);
JetPsiChecker
.
highlightName
(
holder
,
elementToHighlight
,
JetHighlightingColors
.
MUTABLE_VARIABLE
);
}
if
(
Boolean
.
TRUE
.
equals
(
bindingContext
.
get
(
MUST_BE_WRAPPED_IN_A_REF
,
variableDescriptor
)))
{
...
...
@@ -103,11 +103,11 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
}
if
(
descriptor
instanceof
LocalVariableDescriptor
)
{
holder
.
createInfoAnnotation
(
elementToHighlight
,
null
).
setTextAttributes
(
JetHighlightingColors
.
LOCAL_VARIABLE
);
JetPsiChecker
.
highlightName
(
holder
,
elementToHighlight
,
JetHighlightingColors
.
LOCAL_VARIABLE
);
}
if
(
descriptor
instanceof
ValueParameterDescriptor
)
{
holder
.
createInfoAnnotation
(
elementToHighlight
,
null
).
setTextAttributes
(
JetHighlightingColors
.
PARAMETER
);
JetPsiChecker
.
highlightName
(
holder
,
elementToHighlight
,
JetHighlightingColors
.
PARAMETER
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录