Rendering class or package proto when JPS test fails.

This commit is contained in:
Evgeny Gerashchenko
2014-02-13 20:39:53 +04:00
parent 5f77a4548e
commit 5c8253c099
4 changed files with 44 additions and 39 deletions
@@ -1,31 +0,0 @@
/*
* 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.kotlin;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.kotlin.header.KotlinClassHeader;
public class ReadClassHeader {
@Nullable
public static KotlinClassHeader readClassHeader(@NotNull byte[] fileContents) {
Pair<JvmClassName, KotlinClassHeader> pair = VirtualFileKotlinClass.readClassNameAndHeader(fileContents);
return pair == null ? null : pair.second;
}
}
@@ -49,7 +49,7 @@ public class VirtualFileKotlinClass implements KotlinJvmBinaryClass {
}
@Nullable
/* package */ static Pair<JvmClassName, KotlinClassHeader> readClassNameAndHeader(@NotNull byte[] fileContents) {
private static Pair<JvmClassName, KotlinClassHeader> readClassNameAndHeader(@NotNull byte[] fileContents) {
final ReadKotlinClassHeaderAnnotationVisitor readHeaderVisitor = new ReadKotlinClassHeaderAnnotationVisitor();
final Ref<JvmClassName> classNameRef = Ref.create();
new ClassReader(fileContents).accept(new ClassVisitor(ASM4) {
@@ -95,6 +95,12 @@ public class VirtualFileKotlinClass implements KotlinJvmBinaryClass {
}
}
@Nullable
public static KotlinClassHeader readClassHeader(@NotNull byte[] fileContents) {
Pair<JvmClassName, KotlinClassHeader> pair = readClassNameAndHeader(fileContents);
return pair == null ? null : pair.second;
}
@NotNull
public VirtualFile getFile() {
return file;