JvmDeclarationOrigin moved to frontend.java

This commit is contained in:
Andrey Breslav
2014-05-28 18:28:26 +04:00
parent 592328aa27
commit 41d66281ee
26 changed files with 81 additions and 44 deletions
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2014 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.resolve.java.diagnostics
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin
public class ConflictingJvmDeclarationsData(
public val classInternalName: String?,
public val classOrigin: JvmDeclarationOrigin,
public val signature: RawSignature,
public val signatureOrigins: Collection<JvmDeclarationOrigin>
)
@@ -19,17 +19,24 @@ package org.jetbrains.jet.lang.resolve.java.diagnostics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.diagnostics.rendering.DefaultErrorMessages;
import org.jetbrains.jet.lang.diagnostics.rendering.DiagnosticFactoryToRendererMap;
import static org.jetbrains.jet.lang.diagnostics.rendering.Renderers.STRING;
import org.jetbrains.jet.renderer.Renderer;
public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
public static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap();
private static final Renderer<ConflictingJvmDeclarationsData> CONFLICTING_JVM_DECLARATIONS_DATA = new Renderer<ConflictingJvmDeclarationsData>() {
@NotNull
@Override
public String render(@NotNull ConflictingJvmDeclarationsData element) {
return element.getSignature().getName() + element.getSignature().getDesc();
}
};
public static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap();
static {
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: ''{0}''", STRING);
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: ''{0}''", CONFLICTING_JVM_DECLARATIONS_DATA);
}
@NotNull
@Override
public DiagnosticFactoryToRendererMap getMap() {
@@ -24,7 +24,7 @@ import static org.jetbrains.jet.lang.diagnostics.PositioningStrategies.DECLARATI
import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
public interface ErrorsJvm {
DiagnosticFactory1<PsiElement, String> CONFLICTING_JVM_DECLARATIONS = DiagnosticFactory1.create(ERROR, DECLARATION_OR_DEFAULT);
DiagnosticFactory1<PsiElement, ConflictingJvmDeclarationsData> CONFLICTING_JVM_DECLARATIONS = DiagnosticFactory1.create(ERROR, DECLARATION_OR_DEFAULT);
@SuppressWarnings("UnusedDeclaration")
Object _initializer = new Object() {
@@ -0,0 +1,65 @@
/*
* Copyright 2010-2014 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.resolve.java.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
import org.jetbrains.jet.lang.psi.JetClassOrObject
import org.jetbrains.jet.lang.psi.JetDeclaration
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
import org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOriginKind.*
public enum class MemberKind { FIELD; METHOD }
public data class RawSignature(val name: String, val desc: String, val kind: MemberKind)
public enum class JvmDeclarationOriginKind {
OTHER
PACKAGE_FACADE
PACKAGE_PART
TRAIT_IMPL
DELEGATION_TO_TRAIT_IMPL
}
public class JvmDeclarationOrigin(
val originKind: JvmDeclarationOriginKind,
val element: PsiElement?,
val descriptor: DeclarationDescriptor?
) {
class object {
public val NO_ORIGIN: JvmDeclarationOrigin = JvmDeclarationOrigin(OTHER, null, null)
}
}
public fun OtherOrigin(element: PsiElement?, descriptor: DeclarationDescriptor?): JvmDeclarationOrigin =
if (element == null && descriptor == null)
JvmDeclarationOrigin.NO_ORIGIN
else JvmDeclarationOrigin(OTHER, element, descriptor)
public fun OtherOrigin(element: PsiElement?): JvmDeclarationOrigin = OtherOrigin(element, null)
public fun OtherOrigin(descriptor: DeclarationDescriptor?): JvmDeclarationOrigin = OtherOrigin(null, descriptor)
public fun PackageFacade(descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_FACADE, null, descriptor)
public fun PackagePart(file: JetFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor)
public fun TraitImpl(element: JetClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(TRAIT_IMPL, element, descriptor)
public fun DelegationToTraitImpl(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(DELEGATION_TO_TRAIT_IMPL, element, descriptor)