Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
2c5c92c7
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,发现更多精彩内容 >>
提交
2c5c92c7
编写于
6月 17, 2011
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JET-114 Do not allow an anonymous initializer on the same line after 'get' of a property
+ 'Toggle Error Reporting' Action
上级
35ee989a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
122 addition
and
40 deletion
+122
-40
idea/src/META-INF/plugin.xml
idea/src/META-INF/plugin.xml
+5
-0
idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java
idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java
+32
-10
idea/src/org/jetbrains/jet/plugin/actions/ToggleErrorReportingAction.java
...brains/jet/plugin/actions/ToggleErrorReportingAction.java
+15
-0
idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java
...c/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java
+13
-1
idea/testData/psi/PropertiesFollowedByInitializers.jet
idea/testData/psi/PropertiesFollowedByInitializers.jet
+26
-0
idea/testData/psi/Properties_ERR.txt
idea/testData/psi/Properties_ERR.txt
+31
-29
未找到文件。
idea/src/META-INF/plugin.xml
浏览文件 @
2c5c92c7
...
...
@@ -19,6 +19,11 @@
<keyboard-shortcut
keymap=
"$default"
first-keystroke=
"control shift Q"
/>
<add-to-group
group-id=
"CodeMenu"
anchor=
"last"
/>
</action>
<action
id=
"ToggleJetErrorReporting"
class=
"org.jetbrains.jet.plugin.actions.ToggleErrorReportingAction"
text=
"Toggle Error Reporting"
>
<keyboard-shortcut
keymap=
"$default"
first-keystroke=
"control alt shift E"
/>
<add-to-group
group-id=
"CodeMenu"
anchor=
"last"
/>
</action>
</actions>
<extensions
defaultExtensionNs=
"com.intellij"
>
...
...
idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java
浏览文件 @
2c5c92c7
...
...
@@ -818,20 +818,35 @@ public class JetParsing extends AbstractJetParsing {
parseTypeRef
();
}
if
(
at
(
EQ
))
{
advance
();
// EQ
myExpressionParsing
.
parseExpression
();
if
(!
local
)
{
consumeIf
(
SEMICOLON
);
}
else
{
if
(
local
)
{
if
(
at
(
EQ
))
{
advance
();
// EQ
myExpressionParsing
.
parseExpression
();
// "val a = 1; b" must not be an infix call of b on "val ...;"
}
}
if
(!
local
)
{
else
{
if
(
at
(
EQ
))
{
advance
();
// EQ
myExpressionParsing
.
parseExpression
();
consumeIf
(
SEMICOLON
);
}
if
(
parsePropertyGetterOrSetter
())
{
parsePropertyGetterOrSetter
();
}
consumeIf
(
SEMICOLON
);
if
(!
atSet
(
EOL_OR_SEMICOLON
,
RBRACE
))
{
int
i
=
-
1
;
while
(-
i
<
myBuilder
.
getCurrentOffset
()
&&
WHITE_SPACE_OR_COMMENT_BIT_SET
.
contains
(
myBuilder
.
rawLookup
(
i
)))
{
i
--;
}
if
(
myBuilder
.
rawLookup
(
i
)
!=
SEMICOLON
)
{
errorUntil
(
"Property getter or setter expected"
,
TokenSet
.
create
(
EOL_OR_SEMICOLON
));
}
}
else
{
consumeIf
(
SEMICOLON
);
}
}
...
...
@@ -862,8 +877,15 @@ public class JetParsing extends AbstractJetParsing {
advance
();
// GET_KEYWORD or SET_KEYWORD
if
(!
at
(
LPAR
))
{
getterOrSetter
.
done
(
PROPERTY_ACCESSOR
);
return
true
;
// Account for Jet-114 (val a : int get {...})
TokenSet
ACCESSOR_FIRST_OR_PROPERTY_END
=
TokenSet
.
orSet
(
MODIFIER_KEYWORDS
,
TokenSet
.
create
(
LBRACKET
,
GET_KEYWORD
,
SET_KEYWORD
,
EOL_OR_SEMICOLON
,
RBRACE
));
if
(!
atSet
(
ACCESSOR_FIRST_OR_PROPERTY_END
))
{
errorUntil
(
"Accessor body expected"
,
TokenSet
.
orSet
(
ACCESSOR_FIRST_OR_PROPERTY_END
,
TokenSet
.
create
(
LBRACE
,
LPAR
,
EQ
)));
}
else
{
getterOrSetter
.
done
(
PROPERTY_ACCESSOR
);
return
true
;
}
}
myBuilder
.
disableNewlines
();
...
...
idea/src/org/jetbrains/jet/plugin/actions/ToggleErrorReportingAction.java
0 → 100644
浏览文件 @
2c5c92c7
package
org.jetbrains.jet.plugin.actions
;
import
com.intellij.openapi.actionSystem.AnAction
;
import
com.intellij.openapi.actionSystem.AnActionEvent
;
import
org.jetbrains.jet.plugin.annotations.JetPsiChecker
;
/**
* @author yole
*/
public
class
ToggleErrorReportingAction
extends
AnAction
{
@Override
public
void
actionPerformed
(
AnActionEvent
e
)
{
JetPsiChecker
.
setErrorReportingEnabled
(!
JetPsiChecker
.
isErrorReportingEnabled
());
}
}
idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java
浏览文件 @
2c5c92c7
...
...
@@ -28,6 +28,16 @@ import java.util.Set;
*/
public
class
JetPsiChecker
implements
Annotator
{
private
static
volatile
boolean
errorReportingEnabled
=
true
;
public
static
void
setErrorReportingEnabled
(
boolean
value
)
{
errorReportingEnabled
=
value
;
}
public
static
boolean
isErrorReportingEnabled
()
{
return
errorReportingEnabled
;
}
@Override
public
void
annotate
(
@NotNull
PsiElement
element
,
@NotNull
final
AnnotationHolder
holder
)
{
if
(
element
instanceof
JetFile
)
{
...
...
@@ -85,7 +95,9 @@ public class JetPsiChecker implements Annotator {
}
};
AnalyzingUtils
.
applyHandler
(
errorHandler
,
bindingContext
);
if
(
errorReportingEnabled
)
{
AnalyzingUtils
.
applyHandler
(
errorHandler
,
bindingContext
);
}
highlightBackingFields
(
holder
,
file
,
bindingContext
);
...
...
idea/testData/psi/PropertiesFollowedByInitializers.jet
0 → 100644
浏览文件 @
2c5c92c7
class Foo() {
val a : Int get = 1
var b : Int get() = 1; set
var b1 : Int get() = 1; set {1}
val b2 : Int get
{
}
val b3 : Int get {
return 1
}
val b4 : Int get; {
}
var b5 : Int get abstract set
var b6 : Int get [a] abstract set
var b7 : Int get [a] abstract {}
}
class PublicVar() { public var foo = 0; }
class PublicVar() { public var foo = 0; var x : Int }
class PublicVar() { public var foo = 0 }
class PublicVar() { public var foo get set }
class PublicVar() { public var foo get set }
val now: Long get() = System.currentTimeMillis(); fun foo() = now
idea/testData/psi/Properties_ERR.txt
浏览文件 @
2c5c92c7
...
...
@@ -5,21 +5,19 @@ JetFile: Properties_ERR.jet
PsiWhiteSpace(' ')
PsiErrorElement:Expecting property name or receiver type
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace(' ')
PsiErrorElement:Property getter or setter expected
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(var)('var')
...
...
@@ -70,8 +68,8 @@ JetFile: Properties_ERR.jet
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(DOT)('.')
PsiErrorElement:Property getter or setter expected
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
...
...
@@ -167,13 +165,20 @@ JetFile: Properties_ERR.jet
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(set)('set')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiErrorElement:Accessor body expected
PsiElement(RPAR)(')')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
VALUE_PARAMETER
PsiErrorElement:Expecting parameter name
<empty list>
PsiErrorElement:Expecting ')'
<empty list>
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('dfget')
...
...
@@ -266,16 +271,13 @@ JetFile: Properties_ERR.jet
PsiElement(IDENTIFIER)('f')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('d')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(DOT)('.')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('f')
PsiErrorElement:Property getter or setter expected
PsiElement(DOT)('.')
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace('\n\n')
PROPERTY
PsiElement(val)('val')
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录