Search in sources :

Example 1 with TraitFieldDescriptor

use of org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor in project intellij-community by JetBrains.

the class GrTraitUtil method doCollectCompiledTraitFields.

private static void doCollectCompiledTraitFields(ClsClassImpl trait, Collection<GrField> result) {
    VirtualFile traitFile = trait.getContainingFile().getVirtualFile();
    if (traitFile == null)
        return;
    VirtualFile helperFile = traitFile.getParent().findChild(trait.getName() + GroovyTraitFieldsFileIndex.HELPER_SUFFIX);
    if (helperFile == null)
        return;
    int key = FileBasedIndex.getFileId(helperFile);
    final List<Collection<TraitFieldDescriptor>> values = FileBasedIndex.getInstance().getValues(GroovyTraitFieldsFileIndex.INDEX_ID, key, trait.getResolveScope());
    values.forEach(descriptors -> descriptors.forEach(descriptor -> result.add(createTraitField(descriptor, trait))));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiJavaFileStub(com.intellij.psi.impl.java.stubs.PsiJavaFileStub) GrLightMethodBuilder(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder) ABSTRACT(com.intellij.psi.PsiModifier.ABSTRACT) ContainerUtil(com.intellij.util.containers.ContainerUtil) GrLightField(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightField) CachedValueProvider(com.intellij.psi.util.CachedValueProvider) PsiModificationTracker(com.intellij.psi.util.PsiModificationTracker) GrAnnotationUtil(org.jetbrains.plugins.groovy.lang.psi.impl.GrAnnotationUtil) Map(java.util.Map) InheritanceUtil(com.intellij.psi.util.InheritanceUtil) Logger(com.intellij.openapi.diagnostic.Logger) GROOVY_TRAIT(org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_TRAIT) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) ClsClassImpl(com.intellij.psi.impl.compiled.ClsClassImpl) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) PsiJavaFileStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl) GROOVY_TRAIT_IMPLEMENTED(org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_TRAIT_IMPLEMENTED) Collection(java.util.Collection) TraitFieldDescriptor(org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor) CachedValuesManager(com.intellij.psi.util.CachedValuesManager) Nullable(org.jetbrains.annotations.Nullable) Contract(org.jetbrains.annotations.Contract) GroovyTraitFieldsFileIndex(org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex) List(java.util.List) GroovyTraitMethodsFileIndex(org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitMethodsFileIndex) AnnotationUtil(com.intellij.codeInsight.AnnotationUtil) GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) com.intellij.psi(com.intellij.psi) StubElement(com.intellij.psi.stubs.StubElement) NotNull(org.jetbrains.annotations.NotNull) GrModifierFlags(org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierFlags) Ref(com.intellij.openapi.util.Ref) PsiMethodStub(com.intellij.psi.impl.java.stubs.PsiMethodStub) Collection(java.util.Collection)

Example 2 with TraitFieldDescriptor

use of org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor in project intellij-community by JetBrains.

the class GroovyTraitFieldsFileIndex method save.

@Override
public void save(@NotNull DataOutput out, Collection<TraitFieldDescriptor> values) throws IOException {
    writeINT(out, values.size());
    for (TraitFieldDescriptor descriptor : values) {
        out.writeByte(descriptor.flags);
        writeUTF(out, descriptor.typeString);
        writeUTF(out, descriptor.name);
    }
}
Also used : TraitFieldDescriptor(org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor)

Example 3 with TraitFieldDescriptor

use of org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor in project intellij-community by JetBrains.

the class GroovyTraitFieldsFileIndex method read.

@Override
public Collection<TraitFieldDescriptor> read(@NotNull DataInput in) throws IOException {
    int size = readINT(in);
    Collection<TraitFieldDescriptor> result = ContainerUtil.newArrayListWithCapacity(size);
    for (int i = 0; i < size; i++) {
        result.add(new TraitFieldDescriptor(in.readByte(), readUTF(in), readUTF(in)));
    }
    return result;
}
Also used : TraitFieldDescriptor(org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor)

Aggregations

TraitFieldDescriptor (org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex.TraitFieldDescriptor)3 AnnotationUtil (com.intellij.codeInsight.AnnotationUtil)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Ref (com.intellij.openapi.util.Ref)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 com.intellij.psi (com.intellij.psi)1 ABSTRACT (com.intellij.psi.PsiModifier.ABSTRACT)1 ClsClassImpl (com.intellij.psi.impl.compiled.ClsClassImpl)1 PsiJavaFileStub (com.intellij.psi.impl.java.stubs.PsiJavaFileStub)1 PsiMethodStub (com.intellij.psi.impl.java.stubs.PsiMethodStub)1 PsiJavaFileStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl)1 StubElement (com.intellij.psi.stubs.StubElement)1 CachedValueProvider (com.intellij.psi.util.CachedValueProvider)1 CachedValuesManager (com.intellij.psi.util.CachedValuesManager)1 InheritanceUtil (com.intellij.psi.util.InheritanceUtil)1 PsiModificationTracker (com.intellij.psi.util.PsiModificationTracker)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)1 Collection (java.util.Collection)1 List (java.util.List)1