Removed UnresolvedReferenceDiagnosticFactory.

This commit is contained in:
Evgeny Gerashchenko
2013-02-20 15:48:59 +04:00
parent 27a8e16f97
commit 3190cf1526
10 changed files with 27 additions and 62 deletions
@@ -69,7 +69,7 @@ public interface Errors {
DiagnosticFactory1<PsiElement, String> REDECLARATION = DiagnosticFactory1.create(ERROR, FOR_REDECLARATION);
UnresolvedReferenceDiagnosticFactory UNRESOLVED_REFERENCE = UnresolvedReferenceDiagnosticFactory.create();
DiagnosticFactory1<JetReferenceExpression, String> UNRESOLVED_REFERENCE = DiagnosticFactory1.create(ERROR, FOR_UNRESOLVED_REFERENCE);
//Elements with "INVISIBLE_REFERENCE" error are marked as unresolved, unlike elements with "INVISIBLE_MEMBER" error
//"INVISIBLE_REFERENCE" is used for invisible classes references and references in import
@@ -307,7 +307,8 @@ public interface Errors {
SimpleDiagnosticFactory<PsiElement> MIXING_NAMED_AND_POSITIONED_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR);
SimpleDiagnosticFactory<JetReferenceExpression> ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR);
UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create();
DiagnosticFactory1<JetReferenceExpression, String> NAMED_PARAMETER_NOT_FOUND =
DiagnosticFactory1.create(ERROR, FOR_UNRESOLVED_REFERENCE);
SimpleDiagnosticFactory<JetExpression> VARARG_OUTSIDE_PARENTHESES = SimpleDiagnosticFactory.create(ERROR);
SimpleDiagnosticFactory<LeafPsiElement> NON_VARARG_SPREAD = SimpleDiagnosticFactory.create(ERROR);
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lexer.JetKeywordToken;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class PositioningStrategies {
@@ -189,6 +190,20 @@ public class PositioningStrategies {
return markElement(element);
}
};
public static final PositioningStrategy<JetReferenceExpression> FOR_UNRESOLVED_REFERENCE =
new PositioningStrategy<JetReferenceExpression>() {
@NotNull
@Override
public List<TextRange> mark(@NotNull JetReferenceExpression element) {
if (element instanceof JetArrayAccessExpression) {
List<TextRange> ranges = ((JetArrayAccessExpression) element).getBracketRanges();
if (!ranges.isEmpty()) {
return ranges;
}
}
return Collections.singletonList(element.getTextRange());
}
};
public static PositioningStrategy<JetModifierListOwner> modifierSetPosition(final JetKeywordToken... tokens) {
return new PositioningStrategy<JetModifierListOwner>() {
@@ -1,51 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.diagnostics;
import com.intellij.openapi.util.TextRange;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetArrayAccessExpression;
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import java.util.Collections;
import java.util.List;
public class UnresolvedReferenceDiagnosticFactory extends DiagnosticFactory1<JetReferenceExpression, String> {
public UnresolvedReferenceDiagnosticFactory() {
super(Severity.ERROR, new PositioningStrategy<JetReferenceExpression>() {
@NotNull
@Override
public List<TextRange> mark(@NotNull JetReferenceExpression element) {
if (element instanceof JetArrayAccessExpression) {
List<TextRange> ranges = ((JetArrayAccessExpression) element).getBracketRanges();
if (!ranges.isEmpty()) {
return ranges;
}
}
return Collections.singletonList(element.getTextRange());
}
});
}
public DiagnosticWithParameters1<JetReferenceExpression, String> on(@NotNull JetReferenceExpression reference) {
return new DiagnosticWithParameters1<JetReferenceExpression, String>(reference, reference.getText(), this, severity);
}
public static UnresolvedReferenceDiagnosticFactory create() {
return new UnresolvedReferenceDiagnosticFactory();
}
}
@@ -616,7 +616,7 @@ public class DescriptorResolver {
trace.record(BindingContext.REFERENCE_TARGET, subjectTypeParameterName, classifier);
}
else {
trace.report(UNRESOLVED_REFERENCE.on(subjectTypeParameterName));
trace.report(UNRESOLVED_REFERENCE.on(subjectTypeParameterName, subjectTypeParameterName.getText()));
}
}
else {
@@ -359,7 +359,7 @@ public class QualifiedExpressionResolver {
// Simple case of no descriptors
if (descriptors.isEmpty()) {
trace.record(BindingContext.RESOLUTION_SCOPE, referenceExpression, resolutionScope);
trace.report(UNRESOLVED_REFERENCE.on(referenceExpression));
trace.report(UNRESOLVED_REFERENCE.on(referenceExpression, referenceExpression.getText()));
return;
}
@@ -430,7 +430,7 @@ public class CallResolver {
resolveFunctionArguments(context, resultsForFirstNonemptyCandidateSet);
}
else {
context.trace.report(UNRESOLVED_REFERENCE.on(reference));
context.trace.report(UNRESOLVED_REFERENCE.on(reference, reference.getText()));
argumentTypeResolver.checkTypesWithNoCallee(context, RESOLVE_FUNCTION_ARGUMENTS);
}
return resultsForFirstNonemptyCandidateSet != null ? resultsForFirstNonemptyCandidateSet : OverloadResolutionResultsImpl.<F>nameNotFound();
@@ -153,7 +153,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
JetSimpleNameExpression nameReference = argument.getArgumentName().getReferenceExpression();
ValueParameterDescriptor valueParameterDescriptor = parameterByName.get(nameReference.getReferencedNameAsName());
if (valueParameterDescriptor == null) {
report(NAMED_PARAMETER_NOT_FOUND.on(nameReference));
report(NAMED_PARAMETER_NOT_FOUND.on(nameReference, nameReference.getText()));
unmappedArguments.add(argument);
setStatus(WEAK_ERROR);
}
@@ -87,7 +87,7 @@ public class TracingStrategyImpl implements TracingStrategy {
@Override
public void unresolvedReference(@NotNull BindingTrace trace) {
trace.report(UNRESOLVED_REFERENCE.on(reference));
trace.report(UNRESOLVED_REFERENCE.on(reference, reference.getText()));
}
@Override
@@ -217,7 +217,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
if (leftType == null) {
dataFlowInfo = facade.getTypeInfo(right, context.replaceDataFlowInfo(dataFlowInfo)).getDataFlowInfo();
context.trace.report(UNRESOLVED_REFERENCE.on(operationSign));
context.trace.report(UNRESOLVED_REFERENCE.on(operationSign, operationSign.getText()));
temporaryBindingTrace.commit();
return JetTypeInfo.create(null, dataFlowInfo);
}
@@ -111,7 +111,7 @@ public class LabelResolver {
Stack<JetElement> stack = labeledElements.get(labelName);
if (stack == null || stack.isEmpty()) {
if (reportUnresolved) {
context.trace.report(UNRESOLVED_REFERENCE.on(labelExpression));
context.trace.report(UNRESOLVED_REFERENCE.on(labelExpression, labelExpression.getText()));
}
return null;
}
@@ -174,11 +174,11 @@ public class LabelResolver {
return LabeledReceiverResolutionResult.labelResolutionSuccess(thisReceiver);
}
else {
context.trace.report(UNRESOLVED_REFERENCE.on(targetLabel));
context.trace.report(UNRESOLVED_REFERENCE.on(targetLabel, targetLabel.getText()));
}
}
else {
context.trace.report(UNRESOLVED_REFERENCE.on(targetLabel));
context.trace.report(UNRESOLVED_REFERENCE.on(targetLabel, targetLabel.getText()));
}
}
else {