Little corrections

This commit is contained in:
Andrey Breslav
2011-09-02 17:33:37 +04:00
parent 30304ed1b1
commit 324922506c
8 changed files with 31 additions and 17 deletions
@@ -37,6 +37,16 @@ public class ErrorHandler {
throw new IllegalStateException("Redeclaration: " + existingDescriptor.getName()); throw new IllegalStateException("Redeclaration: " + existingDescriptor.getName());
} }
}; };
public static String atLocation(PsiElement element) {
Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(element.getContainingFile());
int offset = element.getTextRange().getStartOffset();
int lineNumber = document.getLineNumber(offset);
int lineStartOffset = document.getLineStartOffset(lineNumber);
int column = offset - lineStartOffset;
return "' at line " + (lineNumber+1) + ":" + column;
}
public void unresolvedReference(@NotNull JetReferenceExpression referenceExpression) { public void unresolvedReference(@NotNull JetReferenceExpression referenceExpression) {
} }
@@ -52,14 +62,5 @@ public class ErrorHandler {
public void genericWarning(@NotNull ASTNode node, @NotNull String message) { public void genericWarning(@NotNull ASTNode node, @NotNull String message) {
} }
public static String atLocation(PsiElement element) {
Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(element.getContainingFile());
int offset = element.getTextRange().getStartOffset();
int lineNumber = document.getLineNumber(offset);
int lineStartOffset = document.getLineStartOffset(lineNumber);
int column = offset - lineStartOffset;
return "' at line " + (lineNumber+1) + ":" + column;
}
} }
@@ -1,10 +1,8 @@
package org.jetbrains.jet.lang.resolve; package org.jetbrains.jet.lang.resolve;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiErrorElement; import com.intellij.psi.PsiErrorElement;
@@ -24,7 +24,7 @@ public interface BindingContext {
WritableSlice<JetReferenceExpression, Collection<? extends DeclarationDescriptor>> AMBIGUOUS_REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, Collection<? extends DeclarationDescriptor>>("AMBIGUOUS_REFERENCE_TARGET", RewritePolicy.DO_NOTHING); WritableSlice<JetReferenceExpression, Collection<? extends DeclarationDescriptor>> AMBIGUOUS_REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, Collection<? extends DeclarationDescriptor>>("AMBIGUOUS_REFERENCE_TARGET", RewritePolicy.DO_NOTHING);
WritableSlice<JetExpression, FunctionDescriptor> LOOP_RANGE_ITERATOR = Slices.createSimpleSlice("LOOP_RANGE_ITERATOR"); WritableSlice<JetExpression, FunctionDescriptor> LOOP_RANGE_ITERATOR = Slices.createSimpleSlice("LOOP_RANGE_ITERATOR");
WritableSlice<JetExpression, DeclarationDescriptor> LOOP_RANGE_HAS_NEXT = Slices.createSimpleSlice("LOOP_RANGE_HAS_NEXT"); WritableSlice<JetExpression, CallableDescriptor> LOOP_RANGE_HAS_NEXT = Slices.createSimpleSlice("LOOP_RANGE_HAS_NEXT");
WritableSlice<JetExpression, FunctionDescriptor> LOOP_RANGE_NEXT = Slices.createSimpleSlice("LOOP_RANGE_NEXT"); WritableSlice<JetExpression, FunctionDescriptor> LOOP_RANGE_NEXT = Slices.createSimpleSlice("LOOP_RANGE_NEXT");
WritableSlice<JetExpression, JetType> AUTOCAST = Slices.createSimpleSlice("AUTOCAST"); WritableSlice<JetExpression, JetType> AUTOCAST = Slices.createSimpleSlice("AUTOCAST");
@@ -1060,18 +1060,18 @@ public class JetTypeInferrer {
TemporaryBindingTrace temporaryTraceWithExpectedType = TemporaryBindingTrace.create(context.trace); TemporaryBindingTrace temporaryTraceWithExpectedType = TemporaryBindingTrace.create(context.trace);
boolean success = checkBinaryWithTypeRHS(expression, context, targetType, targetType, temporaryTraceWithExpectedType); boolean success = checkBinaryWithTypeRHS(expression, context, targetType, targetType, temporaryTraceWithExpectedType);
if (success) { if (success) {
temporaryTraceWithExpectedType.addAllMyDataTo(context.trace); temporaryTraceWithExpectedType.commit();
} }
else { else {
TemporaryBindingTrace temporaryTraceWithoutExpectedType = TemporaryBindingTrace.create(context.trace); TemporaryBindingTrace temporaryTraceWithoutExpectedType = TemporaryBindingTrace.create(context.trace);
checkBinaryWithTypeRHS(expression, context, targetType, NO_EXPECTED_TYPE, temporaryTraceWithoutExpectedType); checkBinaryWithTypeRHS(expression, context, targetType, NO_EXPECTED_TYPE, temporaryTraceWithoutExpectedType);
temporaryTraceWithoutExpectedType.addAllMyDataTo(context.trace); temporaryTraceWithoutExpectedType.commit();
} }
} }
else { else {
TemporaryBindingTrace temporaryTraceWithoutExpectedType = TemporaryBindingTrace.create(context.trace); TemporaryBindingTrace temporaryTraceWithoutExpectedType = TemporaryBindingTrace.create(context.trace);
checkBinaryWithTypeRHS(expression, context, targetType, NO_EXPECTED_TYPE, temporaryTraceWithoutExpectedType); checkBinaryWithTypeRHS(expression, context, targetType, NO_EXPECTED_TYPE, temporaryTraceWithoutExpectedType);
temporaryTraceWithoutExpectedType.addAllMyDataTo(context.trace); temporaryTraceWithoutExpectedType.commit();
} }
IElementType operationType = expression.getOperationSign().getReferencedNameElementType(); IElementType operationType = expression.getOperationSign().getReferencedNameElementType();
@@ -106,6 +106,15 @@ public class JetHighlighter extends SyntaxHighlighterBase {
JET_DEBUG_INFO = TextAttributesKey.createTextAttributesKey("JET.DEBUG.INFO", textAttributes); JET_DEBUG_INFO = TextAttributesKey.createTextAttributesKey("JET.DEBUG.INFO", textAttributes);
} }
public static final TextAttributesKey JET_RESOLVED_TO_ERROR;
static {
TextAttributes textAttributes = new TextAttributes();
textAttributes.setEffectType(EffectType.ROUNDED_BOX);
textAttributes.setEffectColor(Color.RED);
JET_RESOLVED_TO_ERROR = TextAttributesKey.createTextAttributesKey("JET.RESOLVED.TO.ERROR", textAttributes);
}
@NotNull @NotNull
public Lexer getHighlightingLexer() { public Lexer getHighlightingLexer() {
return new JetLexer(); return new JetLexer();
+1 -1
View File
@@ -4,5 +4,5 @@ fun test() {
<error>1</error> : Double <error>1</error> : Double
1 <warning>as</warning> Byte 1 <warning>as</warning> Byte
1 <warning>as</warning> Int 1 <warning>as</warning> Int
1 <warning>as</warning> Double <error>1</error> <warning>as</warning> Double
} }
+3
View File
@@ -0,0 +1,3 @@
class C(x : `std::Int`Int) : NotFound {
val xx : `std::Int`Int
}
@@ -264,7 +264,10 @@ public class ExpectedResolveData {
statement = (JetExpression) parent; statement = (JetExpression) parent;
} }
JetDeclaration declaration = PsiTreeUtil.getParentOfType(referenceExpression, JetDeclaration.class); JetDeclaration declaration = PsiTreeUtil.getParentOfType(referenceExpression, JetDeclaration.class);
return referenceExpression.getText() +
return referenceExpression.getText() + " at " + ErrorHandler.atLocation(referenceExpression) +
" in " + statement.getText() + (declaration == null ? "" : " in " + declaration.getText()); " in " + statement.getText() + (declaration == null ? "" : " in " + declaration.getText());
} }