Removed RedeclarationDiagnosticFactory.

This commit is contained in:
Evgeny Gerashchenko
2013-02-20 15:39:18 +04:00
parent a0f2e2d878
commit 27a8e16f97
3 changed files with 22 additions and 54 deletions
@@ -67,7 +67,7 @@ public interface Errors {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RedeclarationDiagnosticFactory REDECLARATION = new RedeclarationDiagnosticFactory(ERROR);
DiagnosticFactory1<PsiElement, String> REDECLARATION = DiagnosticFactory1.create(ERROR, FOR_REDECLARATION);
UnresolvedReferenceDiagnosticFactory UNRESOLVED_REFERENCE = UnresolvedReferenceDiagnosticFactory.create();
@@ -299,7 +299,7 @@ public interface Errors {
// General
RedeclarationDiagnosticFactory NAME_SHADOWING = new RedeclarationDiagnosticFactory(WARNING);
DiagnosticFactory1<PsiElement, String> NAME_SHADOWING = DiagnosticFactory1.create(WARNING, PositioningStrategies.FOR_REDECLARATION);
SimpleDiagnosticFactory<JetExpression> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = SimpleDiagnosticFactory.create(ERROR);
@@ -169,6 +169,26 @@ public class PositioningStrategies {
public static final PositioningStrategy<JetModifierListOwner> VARIANCE_MODIFIER = modifierSetPosition(JetTokens.IN_KEYWORD,
JetTokens.OUT_KEYWORD);
public static final PositioningStrategy<PsiElement> FOR_REDECLARATION = new PositioningStrategy<PsiElement>() {
@NotNull
@Override
public List<TextRange> mark(@NotNull PsiElement element) {
if (element instanceof JetNamedDeclaration) {
PsiElement nameIdentifier = ((JetNamedDeclaration) element).getNameIdentifier();
if (nameIdentifier != null) {
return markElement(nameIdentifier);
}
}
else if (element instanceof JetFile) {
JetFile file = (JetFile) element;
PsiElement nameIdentifier = file.getNamespaceHeader().getNameIdentifier();
if (nameIdentifier != null) {
return markElement(nameIdentifier);
}
}
return markElement(element);
}
};
public static PositioningStrategy<JetModifierListOwner> modifierSetPosition(final JetKeywordToken... tokens) {
return new PositioningStrategy<JetModifierListOwner>() {
@@ -1,52 +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 com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
import java.util.List;
public class RedeclarationDiagnosticFactory extends DiagnosticFactory1<PsiElement, String> {
private static final PositioningStrategy<PsiElement> POSITION_REDECLARATION = new PositioningStrategy<PsiElement>() {
@NotNull
@Override
public List<TextRange> mark(@NotNull PsiElement element) {
if (element instanceof JetNamedDeclaration) {
PsiElement nameIdentifier = ((JetNamedDeclaration) element).getNameIdentifier();
if (nameIdentifier != null) {
return markElement(nameIdentifier);
}
}
else if (element instanceof JetFile) {
JetFile file = (JetFile) element;
PsiElement nameIdentifier = file.getNamespaceHeader().getNameIdentifier();
if (nameIdentifier != null) {
return markElement(nameIdentifier);
}
}
return markElement(element);
}
};
public RedeclarationDiagnosticFactory(Severity severity) {
super(severity, POSITION_REDECLARATION);
}
}