Redeclaration diagnostics work properly

This commit is contained in:
Andrey Breslav
2011-09-16 13:30:59 +04:00
parent 0dd2889c55
commit 20427a6e4d
71 changed files with 436 additions and 2553 deletions
@@ -2,15 +2,15 @@ package org.jetbrains.jet.lang.diagnostics;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
import org.jetbrains.jet.lang.resolve.BindingContext;
/**
* @author abreslav
*/
public class RedeclarationDiagnosticFactory implements DiagnosticFactory {
public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory {
public static final RedeclarationDiagnosticFactory INSTANCE = new RedeclarationDiagnosticFactory();
@@ -27,13 +27,14 @@ public class RedeclarationDiagnosticFactory implements DiagnosticFactory {
@NotNull
@Override
public TextRange getTextRange(@NotNull Diagnostic diagnostic) {
throw new UnsupportedOperationException(); // TODO
}
@NotNull
@Override
public PsiFile getPsiFile(@NotNull Diagnostic diagnostic) {
throw new UnsupportedOperationException(); // TODO
PsiElement redeclaration = ((RedeclarationDiagnostic) diagnostic).getPsiElement();
if (redeclaration instanceof JetNamedDeclaration) {
PsiElement nameIdentifier = ((JetNamedDeclaration) redeclaration).getNameIdentifier();
if (nameIdentifier != null) {
return nameIdentifier.getTextRange();
}
}
return redeclaration.getTextRange();
}
@NotNull
@@ -974,7 +974,11 @@ public class JetTypeInferrer {
@Override
public JetType visitParenthesizedExpression(JetParenthesizedExpression expression, TypeInferenceContext context) {
return context.services.checkType(getType(expression.getExpression(), context.replaceScope(context.scope)), expression, context);
JetExpression innerExpression = expression.getExpression();
if (innerExpression == null) {
return null;
}
return context.services.checkType(getType(innerExpression, context.replaceScope(context.scope)), expression, context);
}
@Override