Replaced Diagnostic.getMessage() with DiagnosticRenderer.render() calls.

Made Diagnostic.getMessage() deprecated, introduced DiagnosticRender interface and default implementation for it.
This commit is contained in:
Evgeny Gerashchenko
2012-04-12 13:56:53 +04:00
parent 409d6b2da1
commit 6a13510741
8 changed files with 107 additions and 35 deletions
@@ -35,10 +35,7 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassOrNamespaceDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.SimpleDiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
import org.jetbrains.jet.lang.diagnostics.Severity;
import org.jetbrains.jet.lang.diagnostics.*;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
@@ -150,7 +147,7 @@ public class CompileSession {
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.getLineAndColumn(diagnostic);
VirtualFile virtualFile = diagnostic.getPsiFile().getVirtualFile();
String path = virtualFile == null ? null : virtualFile.getPath();
collector.report(diagnostic.getSeverity(), diagnostic.getMessage(), path, lineAndColumn.getLine(), lineAndColumn.getColumn());
collector.report(diagnostic.getSeverity(), DefaultDiagnosticRenderer.INSTANCE.render(diagnostic), path, lineAndColumn.getLine(), lineAndColumn.getColumn());
}
@NotNull
@@ -0,0 +1,39 @@
/*
* Copyright 2010-2012 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.compiler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.DiagnosticRenderer;
/**
* @author Evgeny Gerashchenko
* @since 4/12/12
*/
public class DefaultDiagnosticRenderer implements DiagnosticRenderer {
public static final DefaultDiagnosticRenderer INSTANCE = new DefaultDiagnosticRenderer();
private DefaultDiagnosticRenderer() {
}
@NotNull
@Override
public String render(@Nullable Diagnostic diagnostic) {
return diagnostic.getMessage();
}
}