use of com.intellij.psi.stubs.Stub in project intellij-community by JetBrains.
the class JavaStubIndexer method indexFile.
@Nullable
@Override
public Unit indexFile(@NotNull FileContent content) {
Stub stubTree = StubTreeBuilder.buildStubTree(content);
if (!(stubTree instanceof PsiJavaFileStub))
return null;
PsiJavaFileStub javaFileStub = (PsiJavaFileStub) stubTree;
new StubTree(javaFileStub, false);
List<ClassDecl> classList = new ArrayList<>();
Set<String> usedNames = new HashSet<>();
for (StubElement<?> el : javaFileStub.getChildrenStubs()) {
if (el instanceof PsiClassStubImpl) {
classList.add(processClassDecl((PsiClassStubImpl<?>) el, usedNames));
}
}
List<IndexTree.Import> importList = new ArrayList<>();
for (StubElement<?> el : javaFileStub.getChildrenStubs()) {
if (el instanceof PsiImportListStub) {
processImport((PsiImportListStub) el, importList, usedNames);
}
}
ClassDecl[] classes = classList.isEmpty() ? ClassDecl.EMPTY_ARRAY : classList.toArray(new ClassDecl[classList.size()]);
IndexTree.Import[] imports = importList.isEmpty() ? IndexTree.Import.EMPTY_ARRAY : importList.toArray(new IndexTree.Import[importList.size()]);
byte type = javaFileStub.isCompiled() ? IndexTree.BYTECODE : IndexTree.JAVA;
return new Unit(javaFileStub.getPackageName(), type, imports, classes);
}
use of com.intellij.psi.stubs.Stub in project intellij-community by JetBrains.
the class DebugUtil method stubTreeToBuffer.
public static void stubTreeToBuffer(final Stub node, final Appendable buffer, final int indent) {
StringUtil.repeatSymbol(buffer, ' ', indent);
try {
final ObjectStubSerializer stubType = node.getStubType();
if (stubType != null) {
buffer.append(stubType.toString()).append(':');
}
buffer.append(node.toString()).append('\n');
@SuppressWarnings({ "unchecked" }) final List<? extends Stub> children = node.getChildrenStubs();
for (final Stub child : children) {
stubTreeToBuffer(child, buffer, indent + 2);
}
} catch (IOException e) {
LOG.error(e);
}
}
use of com.intellij.psi.stubs.Stub in project intellij-community by JetBrains.
the class GrStubIndexer method indexFile.
@Nullable
@Override
public Unit indexFile(@NotNull FileContent content) {
if (!isNormalGroovyFile(((FileContentImpl) content).getPsiFileForPsiDependentIndex()))
return null;
Stub stubTree = StubTreeBuilder.buildStubTree(content);
if (!(stubTree instanceof GrFileStub))
return null;
GrFileStub grFileStub = (GrFileStub) stubTree;
new StubTree(grFileStub, false);
String pid = "";
ArrayList<ClassDecl> classList = new ArrayList<>();
Set<String> usedNames = new HashSet<>();
for (StubElement<?> el : grFileStub.getChildrenStubs()) {
if (el instanceof GrPackageDefinitionStub) {
GrPackageDefinitionStub packageStub = (GrPackageDefinitionStub) el;
String pkgName = packageStub.getPackageName();
if (pkgName != null) {
pid = id(pkgName, false, null);
}
}
if (el instanceof GrTypeDefinitionStub) {
ClassDecl classDecl = processClassDecl((GrTypeDefinitionStub) el, usedNames, false);
if (classDecl != null) {
classList.add(classDecl);
}
}
}
ArrayList<Import> importList = new ArrayList<>();
for (StubElement<?> el : grFileStub.getChildrenStubs()) {
if (el instanceof GrImportStatementStub) {
processImport((GrImportStatementStub) el, importList, usedNames);
}
}
ClassDecl[] classes = classList.isEmpty() ? ClassDecl.EMPTY_ARRAY : classList.toArray(new ClassDecl[classList.size()]);
Import[] imports = importList.isEmpty() ? Import.EMPTY_ARRAY : importList.toArray(new Import[importList.size()]);
return new Unit(pid, IndexTree.GROOVY, imports, classes);
}
Aggregations