Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
9103923d
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,发现更多精彩内容 >>
提交
9103923d
编写于
5月 16, 2011
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Navigation problems in the IDE fixed
上级
0f63489f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
204 addition
and
83 deletion
+204
-83
idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java
idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java
+0
-68
idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java
...c/org/jetbrains/jet/lang/resolve/BindingTraceContext.java
+4
-4
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
+4
-4
idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java
idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java
+3
-0
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
+1
-0
idea/tests/org/jetbrains/jet/JetTestUtils.java
idea/tests/org/jetbrains/jet/JetTestUtils.java
+184
-0
idea/tests/org/jetbrains/jet/types/JetOverridingTest.java
idea/tests/org/jetbrains/jet/types/JetOverridingTest.java
+2
-2
idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java
idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java
+6
-5
未找到文件。
idea/src/org/jetbrains/jet/lang/resolve/BindingTrace.java
浏览文件 @
9103923d
...
...
@@ -12,74 +12,6 @@ import org.jetbrains.jet.lang.types.JetType;
* @author abreslav
*/
public
interface
BindingTrace
{
public
static
final
BindingTrace
DUMMY
=
new
BindingTrace
()
{
@Override
public
void
recordExpressionType
(
@NotNull
JetExpression
expression
,
@NotNull
JetType
type
)
{
}
@Override
public
void
recordReferenceResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
DeclarationDescriptor
descriptor
)
{
}
@Override
public
void
recordLabelResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
PsiElement
element
)
{
}
@Override
public
void
recordDeclarationResolution
(
@NotNull
PsiElement
declaration
,
@NotNull
DeclarationDescriptor
descriptor
)
{
}
@Override
public
void
recordValueParameterAsPropertyResolution
(
@NotNull
JetParameter
declaration
,
@NotNull
PropertyDescriptor
descriptor
)
{
}
@Override
public
void
recordTypeResolution
(
@NotNull
JetTypeReference
typeReference
,
@NotNull
JetType
type
)
{
}
@Override
public
void
recordBlock
(
JetFunctionLiteralExpression
expression
)
{
}
@Override
public
void
recordStatement
(
@NotNull
JetElement
statement
)
{
}
@Override
public
void
removeStatementRecord
(
@NotNull
JetElement
statement
)
{
}
@Override
public
void
removeReferenceResolution
(
@NotNull
JetReferenceExpression
referenceExpression
)
{
}
@Override
public
void
requireBackingField
(
@NotNull
PropertyDescriptor
propertyDescriptor
)
{
}
@NotNull
@Override
public
ErrorHandler
getErrorHandler
()
{
return
ErrorHandler
.
DO_NOTHING
;
}
@Override
public
boolean
isProcessed
(
@NotNull
JetExpression
expression
)
{
return
false
;
}
@Override
public
void
markAsProcessed
(
@NotNull
JetExpression
expression
)
{
}
@Override
public
BindingContext
getBindingContext
()
{
throw
new
UnsupportedOperationException
();
}
};
void
recordExpressionType
(
@NotNull
JetExpression
expression
,
@NotNull
JetType
type
);
...
...
idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java
浏览文件 @
9103923d
...
...
@@ -71,7 +71,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
@Override
public
void
recordExpressionType
(
@NotNull
JetExpression
expression
,
@NotNull
JetType
type
)
{
expressionTypes
.
put
(
expression
,
type
);
safePut
(
expressionTypes
,
expression
,
type
);
}
@Override
...
...
@@ -81,7 +81,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
@Override
public
void
recordLabelResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
PsiElement
element
)
{
labelResolutionResults
.
put
(
expression
,
element
);
safePut
(
labelResolutionResults
,
expression
,
element
);
}
@Override
...
...
@@ -91,7 +91,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
@Override
public
void
recordTypeResolution
(
@NotNull
JetTypeReference
typeReference
,
@NotNull
JetType
type
)
{
types
.
put
(
typeReference
,
type
);
safePut
(
types
,
typeReference
,
type
);
}
@Override
...
...
@@ -106,7 +106,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
@Override
public
Void
visitNamespaceDescriptor
(
NamespaceDescriptor
descriptor
,
PsiElement
declaration
)
{
namespaceDeclarationsToDescriptors
.
put
(
declaration
,
descriptor
);
safePut
(
namespaceDeclarationsToDescriptors
,
declaration
,
descriptor
);
return
null
;
}
...
...
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
浏览文件 @
9103923d
...
...
@@ -573,15 +573,15 @@ public class TopDownAnalyzer {
public
void
visitDelegationToSuperCallSpecifier
(
JetDelegatorToSuperCall
call
)
{
JetTypeReference
typeReference
=
call
.
getTypeReference
();
if
(
typeReference
!=
null
)
{
if
(!
jetClass
.
hasPrimaryConstructor
())
{
if
(
jetClass
.
hasPrimaryConstructor
())
{
typeInferrer
.
checkConstructorCall
(
scopeForConstructor
,
typeReference
,
call
);
}
else
{
JetArgumentList
valueArgumentList
=
call
.
getValueArgumentList
();
assert
valueArgumentList
!=
null
;
trace
.
getErrorHandler
().
genericError
(
valueArgumentList
.
getNode
(),
"Class "
+
JetPsiUtil
.
safeName
(
jetClass
.
getName
())
+
" must have a constructor in order to be able to initialize supertypes"
);
}
else
{
typeInferrer
.
checkConstructorCall
(
scopeForConstructor
,
typeReference
,
call
);
}
}
}
...
...
idea/src/org/jetbrains/jet/lang/resolve/TypeResolver.java
浏览文件 @
9103923d
...
...
@@ -28,6 +28,9 @@ public class TypeResolver {
@NotNull
public
JetType
resolveType
(
@NotNull
final
JetScope
scope
,
@NotNull
final
JetTypeReference
typeReference
)
{
JetType
cachedType
=
trace
.
getBindingContext
().
resolveTypeReference
(
typeReference
);
if
(
cachedType
!=
null
)
return
cachedType
;
final
List
<
Annotation
>
annotations
=
AnnotationResolver
.
INSTANCE
.
resolveAnnotations
(
typeReference
.
getAttributes
());
JetTypeElement
typeElement
=
typeReference
.
getTypeElement
();
...
...
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
浏览文件 @
9103923d
...
...
@@ -494,6 +494,7 @@ public class JetTypeInferrer {
else
{
trace
.
getErrorHandler
().
genericError
(((
JetElement
)
call
).
getNode
(),
"Calling a constructor is only supported for ordinary classes"
);
// TODO : review the message
}
return
null
;
}
else
{
if
(
typeElement
!=
null
)
{
...
...
idea/tests/org/jetbrains/jet/JetTestUtils.java
0 → 100644
浏览文件 @
9103923d
package
org.jetbrains.jet
;
import
com.intellij.psi.PsiElement
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.codegen.ClassCodegen
;
import
org.jetbrains.jet.lang.ErrorHandler
;
import
org.jetbrains.jet.lang.JetDiagnostic
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.resolve.BindingContext
;
import
org.jetbrains.jet.lang.resolve.BindingTrace
;
import
org.jetbrains.jet.lang.types.JetType
;
import
java.util.Collection
;
/**
* @author abreslav
*/
public
class
JetTestUtils
{
public
static
final
BindingTrace
DUMMY
=
new
BindingTrace
()
{
@Override
public
void
recordExpressionType
(
@NotNull
JetExpression
expression
,
@NotNull
JetType
type
)
{
}
@Override
public
void
recordReferenceResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
DeclarationDescriptor
descriptor
)
{
}
@Override
public
void
recordLabelResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
PsiElement
element
)
{
}
@Override
public
void
recordDeclarationResolution
(
@NotNull
PsiElement
declaration
,
@NotNull
DeclarationDescriptor
descriptor
)
{
}
@Override
public
void
recordValueParameterAsPropertyResolution
(
@NotNull
JetParameter
declaration
,
@NotNull
PropertyDescriptor
descriptor
)
{
}
@Override
public
void
recordTypeResolution
(
@NotNull
JetTypeReference
typeReference
,
@NotNull
JetType
type
)
{
}
@Override
public
void
recordBlock
(
JetFunctionLiteralExpression
expression
)
{
}
@Override
public
void
recordStatement
(
@NotNull
JetElement
statement
)
{
}
@Override
public
void
removeStatementRecord
(
@NotNull
JetElement
statement
)
{
}
@Override
public
void
removeReferenceResolution
(
@NotNull
JetReferenceExpression
referenceExpression
)
{
}
@Override
public
void
requireBackingField
(
@NotNull
PropertyDescriptor
propertyDescriptor
)
{
}
@NotNull
@Override
public
ErrorHandler
getErrorHandler
()
{
return
ErrorHandler
.
DO_NOTHING
;
}
@Override
public
boolean
isProcessed
(
@NotNull
JetExpression
expression
)
{
return
false
;
}
@Override
public
void
markAsProcessed
(
@NotNull
JetExpression
expression
)
{
}
@Override
public
BindingContext
getBindingContext
()
{
return
new
BindingContext
()
{
@Override
public
DeclarationDescriptor
getDeclarationDescriptor
(
PsiElement
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
NamespaceDescriptor
getNamespaceDescriptor
(
JetNamespace
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
ClassDescriptor
getClassDescriptor
(
JetClass
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
TypeParameterDescriptor
getTypeParameterDescriptor
(
JetTypeParameter
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
FunctionDescriptor
getFunctionDescriptor
(
JetFunction
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
ConstructorDescriptor
getConstructorDescriptor
(
JetElement
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
VariableDescriptor
getVariableDescriptor
(
JetProperty
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
VariableDescriptor
getVariableDescriptor
(
JetParameter
declaration
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
PropertyDescriptor
getPropertyDescriptor
(
JetParameter
primaryConstructorParameter
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
JetType
getExpressionType
(
JetExpression
expression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
DeclarationDescriptor
resolveReferenceExpression
(
JetReferenceExpression
referenceExpression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
JetType
resolveTypeReference
(
JetTypeReference
typeReference
)
{
return
null
;
}
@Override
public
PsiElement
resolveToDeclarationPsiElement
(
JetReferenceExpression
referenceExpression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
PsiElement
getDeclarationPsiElement
(
DeclarationDescriptor
descriptor
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
boolean
isBlock
(
JetFunctionLiteralExpression
expression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
boolean
isStatement
(
JetExpression
expression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
boolean
hasBackingField
(
PropertyDescriptor
propertyDescriptor
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
ConstructorDescriptor
resolveSuperConstructor
(
JetDelegatorToSuperCall
superCall
,
ClassCodegen
classCodegen
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
Collection
<
JetDiagnostic
>
getDiagnostics
()
{
throw
new
UnsupportedOperationException
();
// TODO
}
};
}
};
}
idea/tests/org/jetbrains/jet/types/JetOverridingTest.java
浏览文件 @
9103923d
...
...
@@ -2,13 +2,13 @@ package org.jetbrains.jet.types;
import
com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase
;
import
com.intellij.openapi.application.PathManager
;
import
org.jetbrains.jet.JetTestUtils
;
import
org.jetbrains.jet.lang.JetSemanticServices
;
import
org.jetbrains.jet.lang.descriptors.FunctionDescriptor
;
import
org.jetbrains.jet.lang.descriptors.FunctionDescriptorUtil
;
import
org.jetbrains.jet.lang.descriptors.ModuleDescriptor
;
import
org.jetbrains.jet.lang.psi.JetChangeUtil
;
import
org.jetbrains.jet.lang.psi.JetFunction
;
import
org.jetbrains.jet.lang.resolve.BindingTrace
;
import
org.jetbrains.jet.lang.resolve.ClassDescriptorResolver
;
import
org.jetbrains.jet.lang.types.*
;
import
org.jetbrains.jet.parsing.JetParsingTest
;
...
...
@@ -30,7 +30,7 @@ public class JetOverridingTest extends LightDaemonAnalyzerTestCase {
super
.
setUp
();
library
=
JetStandardLibrary
.
getJetStandardLibrary
(
getProject
());
semanticServices
=
JetSemanticServices
.
createSemanticServices
(
library
);
classDescriptorResolver
=
semanticServices
.
getClassDescriptorResolver
(
BindingTrace
.
DUMMY
);
classDescriptorResolver
=
semanticServices
.
getClassDescriptorResolver
(
JetTestUtils
.
DUMMY
);
}
@Override
...
...
idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java
浏览文件 @
9103923d
...
...
@@ -5,6 +5,7 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import
com.intellij.openapi.application.PathManager
;
import
com.intellij.openapi.project.Project
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.JetTestUtils
;
import
org.jetbrains.jet.lang.JetSemanticServices
;
import
org.jetbrains.jet.lang.cfg.JetFlowInformationProvider
;
import
org.jetbrains.jet.lang.descriptors.*
;
...
...
@@ -34,7 +35,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
library
=
JetStandardLibrary
.
getJetStandardLibrary
(
getProject
());
semanticServices
=
JetSemanticServices
.
createSemanticServices
(
library
);
classDefinitions
=
new
ClassDefinitions
();
classDescriptorResolver
=
semanticServices
.
getClassDescriptorResolver
(
BindingTrace
.
DUMMY
);
classDescriptorResolver
=
semanticServices
.
getClassDescriptorResolver
(
JetTestUtils
.
DUMMY
);
}
@Override
...
...
@@ -487,14 +488,14 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
private
void
assertType
(
String
expression
,
JetType
expectedType
)
{
Project
project
=
getProject
();
JetExpression
jetExpression
=
JetChangeUtil
.
createExpression
(
project
,
expression
);
JetType
type
=
semanticServices
.
getTypeInferrer
(
BindingTrace
.
DUMMY
,
JetFlowInformationProvider
.
NONE
).
getType
(
classDefinitions
.
BASIC_SCOPE
,
jetExpression
,
false
);
JetType
type
=
semanticServices
.
getTypeInferrer
(
JetTestUtils
.
DUMMY
,
JetFlowInformationProvider
.
NONE
).
getType
(
classDefinitions
.
BASIC_SCOPE
,
jetExpression
,
false
);
assertTrue
(
type
+
" != "
+
expectedType
,
type
.
equals
(
expectedType
));
}
private
void
assertErrorType
(
String
expression
)
{
Project
project
=
getProject
();
JetExpression
jetExpression
=
JetChangeUtil
.
createExpression
(
project
,
expression
);
JetType
type
=
semanticServices
.
getTypeInferrer
(
BindingTrace
.
DUMMY
,
JetFlowInformationProvider
.
NONE
).
safeGetType
(
classDefinitions
.
BASIC_SCOPE
,
jetExpression
,
false
);
JetType
type
=
semanticServices
.
getTypeInferrer
(
JetTestUtils
.
DUMMY
,
JetFlowInformationProvider
.
NONE
).
safeGetType
(
classDefinitions
.
BASIC_SCOPE
,
jetExpression
,
false
);
assertTrue
(
"Error type expected but "
+
type
+
" returned"
,
ErrorUtils
.
isErrorType
(
type
));
}
...
...
@@ -517,7 +518,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
private
void
assertType
(
JetScope
scope
,
String
expression
,
String
expectedTypeStr
)
{
Project
project
=
getProject
();
JetExpression
jetExpression
=
JetChangeUtil
.
createExpression
(
project
,
expression
);
JetType
type
=
semanticServices
.
getTypeInferrer
(
BindingTrace
.
DUMMY
,
JetFlowInformationProvider
.
NONE
).
getType
(
scope
,
jetExpression
,
false
);
JetType
type
=
semanticServices
.
getTypeInferrer
(
JetTestUtils
.
DUMMY
,
JetFlowInformationProvider
.
NONE
).
getType
(
scope
,
jetExpression
,
false
);
JetType
expectedType
=
expectedTypeStr
==
null
?
null
:
makeType
(
expectedTypeStr
);
assertEquals
(
expectedType
,
type
);
}
...
...
@@ -527,7 +528,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
}
private
JetType
makeType
(
JetScope
scope
,
String
typeStr
)
{
return
new
TypeResolver
(
semanticServices
,
BindingTrace
.
DUMMY
,
true
).
resolveType
(
scope
,
JetChangeUtil
.
createType
(
getProject
(),
typeStr
));
return
new
TypeResolver
(
semanticServices
,
JetTestUtils
.
DUMMY
,
true
).
resolveType
(
scope
,
JetChangeUtil
.
createType
(
getProject
(),
typeStr
));
}
private
class
ClassDefinitions
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录