Convert and rename JetClsStubBuilder

This commit is contained in:
Pavel V. Talanov
2014-10-27 17:36:42 +03:00
parent 97cbadef61
commit f47d8239c4
3 changed files with 41 additions and 47 deletions
@@ -24,7 +24,7 @@ import com.intellij.psi.compiled.ClsStubBuilder;
import org.jetbrains.annotations.NotNull;
public class JetClassFileDecompiler extends ClassFileDecompilers.Full {
private final ClsStubBuilder stubBuilder = new JetClsStubBuilder();
private final ClsStubBuilder stubBuilder = new KotlinClsStubBuilder();
@Override
public boolean accepts(@NotNull VirtualFile file) {
@@ -1,46 +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.plugin.libraries;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.compiled.ClsStubBuilder;
import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
import com.intellij.psi.impl.compiled.ClsFileImpl;
import com.intellij.psi.stubs.PsiFileStub;
import com.intellij.util.cls.ClsFormatException;
import com.intellij.util.indexing.FileContent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class JetClsStubBuilder extends ClsStubBuilder {
@Override
public int getStubVersion() {
return ClassFileStubBuilder.STUB_VERSION + 1;
}
@Nullable
@Override
public PsiFileStub<?> buildFileStub(@NotNull FileContent content) throws ClsFormatException {
VirtualFile file = content.getFile();
if (LibrariesPackage.isKotlinInternalCompiledFile(file)) {
return null;
}
return ClsFileImpl.buildFileStub(file, content.getContent());
}
}
@@ -0,0 +1,40 @@
/*
* 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.plugin.libraries
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.compiled.ClsStubBuilder
import com.intellij.psi.impl.compiled.ClassFileStubBuilder
import com.intellij.psi.impl.compiled.ClsFileImpl
import com.intellij.psi.stubs.PsiFileStub
import com.intellij.util.cls.ClsFormatException
import com.intellij.util.indexing.FileContent
public class KotlinClsStubBuilder : ClsStubBuilder() {
override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1
throws(javaClass<ClsFormatException>())
override fun buildFileStub(content: FileContent): PsiFileStub<*>? {
val file = content.getFile()
if (isKotlinInternalCompiledFile(file)) {
return null
}
return ClsFileImpl.buildFileStub(file, content.getContent())
}
}