Add getSignificantElement method in JetCodeFragment

This commit is contained in:
Natalia Ukhorskaya
2014-05-15 13:29:16 +04:00
parent 8c0f99001b
commit fd8d292c02
6 changed files with 17 additions and 18 deletions
@@ -254,11 +254,7 @@ fun addDebugExpressionBeforeContextElement(codeFragment: JetCodeFragment, contex
parent.addBefore(JetPsiFactory.createNewLine(contextElement.getProject()), contextElement)
val debugExpression = when(codeFragment) {
is JetExpressionCodeFragment -> codeFragment.getExpression()
is JetBlockCodeFragment -> codeFragment.getBlock()
else -> null
}
val debugExpression = codeFragment.getSignificantElement()
if (debugExpression == null) return null
val newDebugExpression = parent.addBefore(debugExpression, contextElement)
@@ -218,14 +218,8 @@ public class ResolveElementCache {
JetCodeFragment codeFragment,
BindingTrace trace
) {
JetExpression codeFragmentExpression = null;
if (codeFragment instanceof JetExpressionCodeFragment) {
codeFragmentExpression = ((JetExpressionCodeFragment) codeFragment).getExpression();
}
else if (codeFragment instanceof JetBlockCodeFragment) {
codeFragmentExpression = ((JetBlockCodeFragment) codeFragment).getBlock();
}
if (codeFragmentExpression == null) return;
JetElement codeFragmentExpression = codeFragment.getSignificantElement();
if (!(codeFragmentExpression instanceof JetExpression)) return;
PsiElement contextElement = codeFragment.getContext();
if (!(contextElement instanceof JetExpression)) return;
@@ -245,7 +239,7 @@ public class ResolveElementCache {
DataFlowInfo dataFlowInfoForContextElement = contextForElement.get(BindingContext.EXPRESSION_DATA_FLOW_INFO, contextExpression);
AnalyzerPackage.computeTypeInContext(
codeFragmentExpression,
(JetExpression) codeFragmentExpression,
chainedScope,
trace,
dataFlowInfoForContextElement == null ? DataFlowInfo.EMPTY : dataFlowInfoForContextElement,