Redeclaration diagnostics work properly
This commit is contained in:
+10
-9
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user