Improve header-impl mismatch diagnostic rendering in IDE
Use HTML instead of text to render line breaks and lists correctly
This commit is contained in:
@@ -28,8 +28,7 @@ import org.jetbrains.kotlin.js.resolve.diagnostics.JsCallDataHtmlRenderer;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.rendering.Renderers.RENDER_CLASS_OR_OBJECT;
|
||||
import static org.jetbrains.kotlin.diagnostics.rendering.Renderers.STRING;
|
||||
import static org.jetbrains.kotlin.diagnostics.rendering.Renderers.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.TextElementType;
|
||||
import static org.jetbrains.kotlin.idea.highlighter.HtmlTabledDescriptorRenderer.tableForTypes;
|
||||
import static org.jetbrains.kotlin.idea.highlighter.IdeRenderers.*;
|
||||
@@ -176,6 +175,14 @@ public class IdeErrorMessages {
|
||||
MAP.put(EXPERIMENTAL_FEATURE_WARNING, "<html>{0}</html>", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.WARNING, true));
|
||||
MAP.put(EXPERIMENTAL_FEATURE_ERROR, "<html>{0}</html>", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.ERROR, true));
|
||||
|
||||
MAP.put(HEADER_WITHOUT_IMPLEMENTATION, "<html>''header'' {0} has no implementation in module{1}{2}</html>", DECLARATION_NAME_WITH_KIND,
|
||||
PLATFORM, new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
||||
MAP.put(IMPLEMENTATION_WITHOUT_HEADER, "<html>''impl'' {0} has no corresponding ''header'' declaration{1}</html>", DECLARATION_NAME_WITH_KIND,
|
||||
new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
||||
|
||||
MAP.put(HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED, "<html>''impl'' class ''{0}'' has no implementation of ''header'' class members:{1}</html>",
|
||||
NAME, new IncompatibleHeaderImplClassScopesRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE));
|
||||
|
||||
MAP.setImmutable();
|
||||
}
|
||||
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2017 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.kotlin.idea.highlighter
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.MultiplatformDiagnosticRenderingMode
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RenderingContext
|
||||
|
||||
object IdeMultiplatformDiagnosticRenderingMode : MultiplatformDiagnosticRenderingMode() {
|
||||
override fun newLine(sb: StringBuilder) {
|
||||
sb.append("<br/>")
|
||||
}
|
||||
|
||||
override fun renderList(sb: StringBuilder, elements: List<() -> Unit>) {
|
||||
sb.append("<ul>")
|
||||
for (element in elements) {
|
||||
sb.append("<li>")
|
||||
element()
|
||||
sb.append("</li>")
|
||||
}
|
||||
sb.append("</ul>")
|
||||
}
|
||||
|
||||
override fun renderDescriptor(sb: StringBuilder, descriptor: DeclarationDescriptor, context: RenderingContext, indent: String) {
|
||||
sb.append(IdeRenderers.HTML.render(descriptor, context))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user