From 27a8e16f976858004bb28ba978ae3ec052a19cbe Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Wed, 20 Feb 2013 15:39:18 +0400 Subject: [PATCH] Removed RedeclarationDiagnosticFactory. --- .../jet/lang/diagnostics/Errors.java | 4 +- .../diagnostics/PositioningStrategies.java | 20 +++++++ .../RedeclarationDiagnosticFactory.java | 52 ------------------- 3 files changed, 22 insertions(+), 54 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index 3a3acaca57d..0741589d7ff 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -67,7 +67,7 @@ public interface Errors { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - RedeclarationDiagnosticFactory REDECLARATION = new RedeclarationDiagnosticFactory(ERROR); + DiagnosticFactory1 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 NAME_SHADOWING = DiagnosticFactory1.create(WARNING, PositioningStrategies.FOR_REDECLARATION); SimpleDiagnosticFactory TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = SimpleDiagnosticFactory.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.java index 65d483ea5c3..5096e3de618 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategies.java @@ -169,6 +169,26 @@ public class PositioningStrategies { public static final PositioningStrategy VARIANCE_MODIFIER = modifierSetPosition(JetTokens.IN_KEYWORD, JetTokens.OUT_KEYWORD); + public static final PositioningStrategy FOR_REDECLARATION = new PositioningStrategy() { + @NotNull + @Override + public List 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 modifierSetPosition(final JetKeywordToken... tokens) { return new PositioningStrategy() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.java deleted file mode 100644 index a4e2426ebcb..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/RedeclarationDiagnosticFactory.java +++ /dev/null @@ -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 { - private static final PositioningStrategy POSITION_REDECLARATION = new PositioningStrategy() { - @NotNull - @Override - public List 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); - } -}