Add getSignificantElement method in JetCodeFragment
This commit is contained in:
@@ -27,5 +27,6 @@ public class JetBlockCodeFragment(
|
||||
context: PsiElement?
|
||||
) : JetCodeFragment(project, name, text, JetNodeTypes.BLOCK_CODE_FRAGMENT, context) {
|
||||
|
||||
fun getBlock() = findChildByClass(javaClass<JetBlockExpression>()) ?: throw IllegalStateException("Block expression should be parsed for BlockCodeFragment")
|
||||
override fun getSignificantElement() = findChildByClass(javaClass<JetBlockExpression>())
|
||||
?: throw IllegalStateException("Block expression should be parsed for BlockCodeFragment")
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public abstract class JetCodeFragment(
|
||||
private var _superType: PsiType? = null
|
||||
private var _exceptionHandler: JavaCodeFragment.ExceptionHandler? = null
|
||||
|
||||
public abstract fun getSignificantElement(): JetElement?
|
||||
|
||||
override fun forceResolveScope(scope: GlobalSearchScope?) {
|
||||
_resolveScope = scope
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ public class JetExpressionCodeFragment(
|
||||
context: PsiElement?
|
||||
) : JetCodeFragment(project, name, text, JetNodeTypes.EXPRESSION_CODE_FRAGMENT, context) {
|
||||
|
||||
fun getExpression() = findChildByClass(javaClass<JetExpression>())
|
||||
override fun getSignificantElement() = findChildByClass(javaClass<JetExpression>())
|
||||
}
|
||||
|
||||
@@ -30,11 +30,17 @@ public class JetTypeCodeFragment extends JetCodeFragment {
|
||||
|
||||
@Nullable
|
||||
public JetType getType() {
|
||||
JetTypeReference typeReference = findChildByClass(JetTypeReference.class);
|
||||
if (typeReference != null) {
|
||||
JetElement typeReference = getSignificantElement();
|
||||
if (typeReference instanceof JetTypeReference) {
|
||||
//TODO return the actual type
|
||||
return KotlinBuiltIns.getInstance().getAnyType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetElement getSignificantElement() {
|
||||
return findChildByClass(JetTypeReference.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user