Java 类com.intellij.psi.stubs.StubElement 实例源码

项目:intellij-ce-playground    文件:StubsTest.java   
public void doTest() throws Exception {
  final List<String> data = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
  String fileText = data.get(0);

  PsiFile psiFile = TestUtils.createPseudoPhysicalGroovyFile(getProject(), fileText);

  ASTNode node = psiFile.getNode();
  Assert.assertNotNull(node);
  IElementType type = node.getElementType();
  Assert.assertTrue(type instanceof IStubFileElementType);

  IStubFileElementType stubFileType = (IStubFileElementType) type;
  StubBuilder builder = stubFileType.getBuilder();
  StubElement element = builder.buildStubTree(psiFile);
  StringBuffer buffer = new StringBuffer();
  getStubsTreeImpl(element, buffer, "");
  String stubTree = buffer.toString().trim();
  assertEquals(data.get(1), stubTree);
}
项目:intellij-ce-playground    文件:GroovyFileImpl.java   
private boolean processChildrenScopes(@NotNull PsiScopeProcessor processor,
                                      @NotNull ResolveState state,
                                      @Nullable PsiElement lastParent,
                                      @NotNull PsiElement place) {
  final StubElement<?> stub = getStub();
  if (stub != null) {
    return true; // only local usages are traversed here. Having a stub means the clients are outside and won't see our variables
  }

  PsiElement run = lastParent == null ? getLastChild() : lastParent.getPrevSibling();
  while (run != null) {
    if (shouldProcess(lastParent, run) &&
        !run.processDeclarations(processor, state, null, place)) {
      return false;
    }
    run = run.getPrevSibling();
  }

  return true;
}
项目:intellij-ce-playground    文件:JavaClassReferenceListElementType.java   
@Override
public void indexStub(@NotNull PsiClassReferenceListStub stub, @NotNull IndexSink sink) {
  PsiReferenceList.Role role = stub.getRole();
  if (role == PsiReferenceList.Role.EXTENDS_LIST || role == PsiReferenceList.Role.IMPLEMENTS_LIST) {
    String[] names = stub.getReferencedNames();
    for (String name : names) {
      String shortName = PsiNameHelper.getShortClassName(name);
      if (!StringUtil.isEmptyOrSpaces(shortName)) {
        sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, shortName);
      }
    }

    if (role == PsiReferenceList.Role.EXTENDS_LIST) {
      StubElement parentStub = stub.getParentStub();
      if (parentStub instanceof PsiClassStub) {
        PsiClassStub psiClassStub = (PsiClassStub)parentStub;
        if (psiClassStub.isEnum()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Enum");
        }
        if (psiClassStub.isAnnotationType()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Annotation");
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:JavaClassElementType.java   
@NotNull
@Override
public PsiClassStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  byte flags = dataStream.readByte();
  boolean isAnonymous = PsiClassStubImpl.isAnonymous(flags);
  boolean isEnumConst = PsiClassStubImpl.isEnumConstInitializer(flags);
  JavaClassElementType type = typeForClass(isAnonymous, isEnumConst);

  if (!isAnonymous) {
    StringRef name = dataStream.readName();
    StringRef qname = dataStream.readName();
    int languageLevelId = dataStream.readByte();
    StringRef sourceFileName = dataStream.readName();
    PsiClassStubImpl classStub = new PsiClassStubImpl(type, parentStub, qname, name, null, flags);
    classStub.setLanguageLevel(LanguageLevel.values()[languageLevelId]);
    classStub.setSourceFileName(sourceFileName);
    return classStub;
  }
  else {
    StringRef baseRef = dataStream.readName();
    return new PsiClassStubImpl(type, parentStub, null, null, baseRef, flags);
  }
}
项目:intellij-ce-playground    文件:JavaImportStatementElementType.java   
@Override
public PsiImportStatementStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
  boolean isOnDemand = false;
  String refText = null;

  for (LighterASTNode child : tree.getChildren(node)) {
    IElementType type = child.getTokenType();
    if (type == JavaElementType.JAVA_CODE_REFERENCE || type == JavaElementType.IMPORT_STATIC_REFERENCE) {
      refText = JavaSourceUtil.getReferenceText(tree, child);
    }
    else if (type == JavaTokenType.ASTERISK) {
      isOnDemand = true;
    }
  }

  byte flags = PsiImportStatementStubImpl.packFlags(isOnDemand, node.getTokenType() == JavaElementType.IMPORT_STATIC_STATEMENT);
  return new PsiImportStatementStubImpl(parentStub, refText, flags);
}
项目:intellij-ce-playground    文件:PyFunctionImpl.java   
@Nullable
private Modifier getWrappersFromStub() {
  final StubElement parentStub = getStub().getParentStub();
  final List childrenStubs = parentStub.getChildrenStubs();
  int index = childrenStubs.indexOf(getStub());
  if (index >= 0 && index < childrenStubs.size() - 1) {
    StubElement nextStub = (StubElement)childrenStubs.get(index + 1);
    if (nextStub instanceof PyTargetExpressionStub) {
      final PyTargetExpressionStub targetExpressionStub = (PyTargetExpressionStub)nextStub;
      if (targetExpressionStub.getInitializerType() == PyTargetExpressionStub.InitializerType.CallExpression) {
        final QualifiedName qualifiedName = targetExpressionStub.getInitializer();
        if (QualifiedName.fromComponents(PyNames.CLASSMETHOD).equals(qualifiedName)) {
          return CLASSMETHOD;
        }
        if (QualifiedName.fromComponents(PyNames.STATICMETHOD).equals(qualifiedName)) {
          return STATICMETHOD;
        }
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PyTargetExpressionElementType.java   
public PyTargetExpressionStub createStub(@NotNull final PyTargetExpression psi, final StubElement parentStub) {
  final String name = psi.getName();
  final PyExpression assignedValue = psi.findAssignedValue();
  final String docString = DocStringUtil.getDocStringValue(psi);
  for (CustomTargetExpressionStubType customStubType : getCustomStubTypes()) {
    CustomTargetExpressionStub customStub = customStubType.createStub(psi);
    if (customStub != null) {
      return new PyTargetExpressionStubImpl(name, docString, customStub, parentStub);
    }
  }
  PyTargetExpressionStub.InitializerType initializerType = PyTargetExpressionStub.InitializerType.Other;
  QualifiedName initializer = null;
  if (assignedValue instanceof PyReferenceExpression) {
    initializerType = PyTargetExpressionStub.InitializerType.ReferenceExpression;
    initializer = ((PyReferenceExpression) assignedValue).asQualifiedName();
  }
  else if (assignedValue instanceof PyCallExpression) {
    initializerType = PyTargetExpressionStub.InitializerType.CallExpression;
    final PyExpression callee = ((PyCallExpression)assignedValue).getCallee();
    if (callee instanceof PyReferenceExpression) {
      initializer = ((PyReferenceExpression) callee).asQualifiedName();
    }
  }
  return new PyTargetExpressionStubImpl(name, docString, initializerType, initializer, psi.isQualified(), parentStub);
}
项目:intellij-ce-playground    文件:TypeInfo.java   
@NotNull
public TypeInfo applyAnnotations(@NotNull StubBase<?> owner) {
  PsiModifierListStub modifierList = (PsiModifierListStub)owner.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
  if (modifierList == null) return this;

  List<PsiAnnotationStub> annotationStubs = null;
  for (StubElement child : modifierList.getChildrenStubs()) {
    if (!(child instanceof PsiAnnotationStub)) continue;
    PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
    if (PsiImplUtil.isTypeAnnotation(annotationStub.getPsiElement())) {
      if (annotationStubs == null) annotationStubs = new SmartList<PsiAnnotationStub>();
      annotationStubs.add(annotationStub);
    }
  }

  PsiAnnotationStub[] stubArray = PsiAnnotationStub.EMPTY_ARRAY;
  if (annotationStubs != null) stubArray = annotationStubs.toArray(new PsiAnnotationStub[annotationStubs.size()]);
  return new TypeInfo(text, arrayCount, isEllipsis, stubArray);
}
项目:intellij-ce-playground    文件:JavaLightStubBuilder.java   
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file, @NotNull LighterAST tree) {
  if (!(file instanceof PsiJavaFile)) {
    return super.createStubForFile(file, tree);
  }

  String refText = "";
  LighterASTNode pkg = LightTreeUtil.firstChildOfType(tree, tree.getRoot(), JavaElementType.PACKAGE_STATEMENT);
  if (pkg != null) {
    LighterASTNode ref = LightTreeUtil.firstChildOfType(tree, pkg, JavaElementType.JAVA_CODE_REFERENCE);
    if (ref != null) {
      refText = JavaSourceUtil.getReferenceText(tree, ref);
    }
  }
  return new PsiJavaFileStubImpl((PsiJavaFile)file, StringRef.fromString(refText), false);
}
项目:intellij-ce-playground    文件:JavaStubBuilderTest.java   
public void testSOEProof() {
  StringBuilder sb = new StringBuilder();
  SecureRandom random = new SecureRandom();
  sb.append("class SOE_test {\n BigInteger BIG = new BigInteger(\n");
  int i;
  for (i = 0; i < 100000; i++) {
    sb.append("  \"").append(Math.abs(random.nextInt())).append("\" +\n");
  }
  sb.append("  \"\");\n}");

  PsiJavaFile file = (PsiJavaFile)createLightFile("SOE_test.java", sb.toString());
  long t = System.currentTimeMillis();
  StubElement tree = myBuilder.buildStubTree(file);
  t = System.currentTimeMillis() - t;
  assertEquals("PsiJavaFileStub []\n" +
               "  IMPORT_LIST:PsiImportListStub\n" +
               "  CLASS:PsiClassStub[name=SOE_test fqn=SOE_test]\n" +
               "    MODIFIER_LIST:PsiModifierListStub[mask=4096]\n" +
               "    TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
               "    EXTENDS_LIST:PsiRefListStub[EXTENDS_LIST:]\n" +
               "    IMPLEMENTS_LIST:PsiRefListStub[IMPLEMENTS_LIST:]\n" +
               "    FIELD:PsiFieldStub[BIG:BigInteger=;INITIALIZER_NOT_STORED;]\n" +
               "      MODIFIER_LIST:PsiModifierListStub[mask=4096]\n",
               DebugUtil.stubTreeToString(tree));
  System.out.println("SOE depth=" + i + ", time=" + t + "ms");
}
项目:intellij-ce-playground    文件:JavaStubBuilderTest.java   
private void doTest(String source, String expected) {
  PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", source);
  FileASTNode fileNode = file.getNode();
  assertNotNull(fileNode);
  assertFalse(fileNode.isParsed());

  StubElement lightTree = myBuilder.buildStubTree(file);
  assertFalse(fileNode.isParsed());

  file.getNode().getChildren(null); // force switch to AST
  StubElement astBasedTree = myBuilder.buildStubTree(file);
  assertTrue(fileNode.isParsed());

  assertEquals("light tree differs", expected, DebugUtil.stubTreeToString(lightTree));
  assertEquals("AST-based tree differs", expected, DebugUtil.stubTreeToString(astBasedTree));
}
项目:reasonml-idea-plugin    文件:RmlFileStubElementType.java   
@Override
public StubBuilder getBuilder() {
    return new DefaultStubBuilder() {
        @NotNull
        @Override
        protected StubElement createStubForFile(@NotNull PsiFile file) {
            if (file instanceof RmlFile) {
                return new RmlFileStub((RmlFile) file);
            }
            return super.createStubForFile(file);
        }
    };
}
项目:bamboo-soy    文件:TemplateDefinitionStub.java   
@NotNull
@Override
public TemplateDefinitionStub deserialize(
    @NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  final StringRef ref = dataStream.readName();
  return new TemplateDefinitionStub(parentStub, ref.getString());
}
项目:bamboo-soy    文件:NamespaceDeclarationStub.java   
@NotNull
@Override
public NamespaceDeclarationStub deserialize(
    @NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  final StringRef ref = dataStream.readName();
  return new NamespaceDeclarationStub(parentStub, ref.getString());
}
项目:bamboo-soy    文件:FileStub.java   
@Override
public StubBuilder getBuilder() {
  return new DefaultStubBuilder() {
    @Override
    protected StubElement createStubForFile(@NotNull PsiFile file) {
      return new FileStub((SoyFile) file);
    }
  };
}
项目:bamboo-soy    文件:AtParamStub.java   
@NotNull
@Override
public AtParamStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub)
    throws IOException {
  final StringRef ref = dataStream.readName();
  final StringRef ref2 = dataStream.readName();
  return new AtParamStub(
      parentStub, ref.getString(), ref2.getString(), dataStream.readBoolean());
}
项目:bamboo-soy    文件:StubUtils.java   
public static FileStub getContainingStubFile(StubElement e) {
  StubElement parent = e.getParentStub();
  while (parent != null) {
    if (parent instanceof FileStub) {
      return (FileStub) parent;
    }
    parent = parent.getParentStub();
  }
  return null;
}
项目:lua-for-idea    文件:LuaStubModuleDeclarationType.java   
@Override
public LuaModuleDeclarationStub createStub(@NotNull LuaModuleExpression psi, StubElement parentStub) {

    log.debug(psi.getText());
    final String moduleName = psi.getModuleName();
    return new LuaModuleDeclarationStubImpl(parentStub, StringRef.fromNullableString(psi.getName()), StringRef.fromNullableString(moduleName),
            SerializationUtils.serialize(psi.getLuaType()));
}
项目:intellij-ce-playground    文件:GroovyFileImpl.java   
@Override
public GrPackageDefinition getPackageDefinition() {
  final StubElement<?> stub = getStub();
  if (stub != null) {
    for (StubElement element : stub.getChildrenStubs()) {
      if (element instanceof GrPackageDefinitionStub) return (GrPackageDefinition)element.getPsi();
    }
    return null;
  }

  ASTNode node = calcTreeElement().findChildByType(GroovyElementTypes.PACKAGE_DEFINITION);
  return node != null ? (GrPackageDefinition)node.getPsi() : null;
}
项目:lua-for-idea    文件:LuaCompoundIdentifierStubImpl.java   
public LuaCompoundIdentifierStubImpl(StubElement parent, StringRef name, boolean isDeclaration, byte[] type,
                                     LuaType luaType) {
    super(parent, LuaElementTypes.GETTABLE, name);
    this.isGlobalDeclaration = isDeclaration;
    myType = type;
    this.luaType = luaType;
}
项目:intellij-ce-playground    文件:PyFromImportStatementStubImpl.java   
public PyFromImportStatementStubImpl(QualifiedName importSourceQName, boolean isStarImport, int relativeLevel,
                                     final StubElement parent, IStubElementType elementType) {
  super(parent, elementType);
  myImportSourceQName = importSourceQName;
  myStarImport = isStarImport;
  myRelativeLevel = relativeLevel;
}
项目:intellij-ce-playground    文件:PyFunctionStubImpl.java   
public PyFunctionStubImpl(final String name, final String docString, @Nullable final StringRef deprecationMessage, boolean isAsync,
                          final StubElement parent, IStubElementType stubElementType) {
  super(parent, stubElementType);
  myName = name;
  myDocString = docString;
  myDeprecationMessage = deprecationMessage;
  myAsync = isAsync;
}
项目:protobuf-jetbrains-plugin    文件:FileStub.java   
@Override
public StubBuilder getBuilder() {
    return new DefaultStubBuilder() {
        @Override
        protected StubElement createStubForFile(@NotNull PsiFile file) {
            return new FileStub((ProtoPsiFileRoot) file);
        }
    };
}
项目:intellij-ce-playground    文件:GrMethodElementType.java   
@Override
public GrMethodStub createStub(@NotNull GrMethod psi, StubElement parentStub) {

  Set<String> namedParameters = psi.getNamedParameters().keySet();
  return new GrMethodStub(parentStub, StringRef.fromString(psi.getName()), GrStubUtils.getAnnotationNames(psi),
                          ArrayUtil.toStringArray(namedParameters), this,
                          GrStubUtils.getTypeText(psi.getReturnTypeElementGroovy()),
                          GrMethodStub.buildFlags(psi));
}
项目:intellij-ce-playground    文件:GroovyFileBaseImpl.java   
@Override
@NotNull
public GrTypeDefinition[] getTypeDefinitions() {
  final StubElement<?> stub = getStub();
  if (stub != null) {
    return stub.getChildrenByType(TokenSets.TYPE_DEFINITIONS, GrTypeDefinition.ARRAY_FACTORY);
  }

  return calcTreeElement().getChildrenAsPsiElements(TokenSets.TYPE_DEFINITIONS, GrTypeDefinition.ARRAY_FACTORY);
}
项目:intellij-ce-playground    文件:JavaMethodElementType.java   
@NotNull
@Override
public PsiMethodStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  StringRef name = dataStream.readName();
  final TypeInfo type = TypeInfo.readTYPE(dataStream);
  byte flags = dataStream.readByte();
  final StringRef defaultMethodValue = PsiMethodStubImpl.isAnnotationMethod(flags) ? dataStream.readName() : null;
  return new PsiMethodStubImpl(parentStub, StringRef.toString(name), type, flags, StringRef.toString(defaultMethodValue));
}
项目:intellij-ce-playground    文件:GrParameterStub.java   
public GrParameterStub(StubElement parent,
                       StringRef name,
                       final String[] annotations,
                       String typeText, 
                       int flags) {
  super(parent, GroovyElementTypes.PARAMETER);
  myName = name;
  myAnnotations = annotations;
  myTypeText = typeText;
  myFlags = flags;
}
项目:intellij-ce-playground    文件:PyClassStubImpl.java   
public PyClassStubImpl(final String name, StubElement parentStub, final QualifiedName[] superClasses, @Nullable QualifiedName metaClass,
                       final List<String> slots, String docString, IStubElementType stubElementType) {
  super(parentStub, stubElementType);
  myName = name;
  mySuperClasses = superClasses;
  myMetaClass = metaClass;
  mySlots = slots;
  myDocString = docString;
}
项目:intellij-ce-playground    文件:JavaStubElementType.java   
private PsiJavaFileStub getFileStub(StubT stub) {
  StubElement parent = stub;
  while (!(parent instanceof PsiFileStub)) {
    parent = parent.getParentStub();
  }

  return (PsiJavaFileStub)parent;
}
项目:intellij-ce-playground    文件:PyFromImportStatementElementType.java   
@NotNull
public PyFromImportStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  QualifiedName qName = QualifiedName.deserialize(dataStream);
  boolean isStarImport = dataStream.readBoolean();
  int relativeLevel = dataStream.readVarInt();
  return new PyFromImportStatementStubImpl(qName, isStarImport, relativeLevel, parentStub, getStubElementType());
}
项目:intellij-ce-playground    文件:GrFieldElementType.java   
static GrFieldStub deserializeFieldStub(StubInputStream dataStream, StubElement parentStub) throws IOException {
  StringRef ref = dataStream.readName();
  final String[] annNames = GrStubUtils.readStringArray(dataStream);
  final String[] namedParameters = GrStubUtils.readStringArray(dataStream);
  byte flags = dataStream.readByte();
  final String typeText = GrStubUtils.readNullableString(dataStream);
  return new GrFieldStub(parentStub, ref, annNames, namedParameters, GrFieldStub.isEnumConstant(flags) ? GroovyElementTypes.ENUM_CONSTANT
                                                                                                       : GroovyElementTypes.FIELD,
                             flags, typeText);
}
项目:intellij-ce-playground    文件:JavaFieldStubElementType.java   
@Override
public PsiFieldStub createStub(final LighterAST tree, final LighterASTNode node, final StubElement parentStub) {
  final TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);

  boolean isDeprecatedByComment = false;
  boolean hasDeprecatedAnnotation = false;
  boolean hasDocComment = false;
  String name = null;
  String initializer = null;

  boolean expectingInit = false;
  for (final LighterASTNode child : tree.getChildren(node)) {
    final IElementType type = child.getTokenType();
    if (type == JavaDocElementType.DOC_COMMENT) {
      hasDocComment = true;
      isDeprecatedByComment = RecordUtil.isDeprecatedByDocComment(tree, child);
    }
    else if (type == JavaElementType.MODIFIER_LIST) {
      hasDeprecatedAnnotation = RecordUtil.isDeprecatedByAnnotation(tree, child);
    }
    else if (type == JavaTokenType.IDENTIFIER) {
      name = RecordUtil.intern(tree.getCharTable(), child);
    }
    else if (type == JavaTokenType.EQ) {
      expectingInit = true;
    }
    else if (expectingInit && !ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type) && type != JavaTokenType.SEMICOLON) {
      initializer = encodeInitializer(tree, child);
      break;
    }
  }

  final boolean isEnumConst = node.getTokenType() == JavaElementType.ENUM_CONSTANT;
  final byte flags = PsiFieldStubImpl.packFlags(isEnumConst, isDeprecatedByComment, hasDeprecatedAnnotation, hasDocComment);

  return new PsiFieldStubImpl(parentStub, name, typeInfo, initializer, flags);
}
项目:intellij-ce-playground    文件:JavaFieldStubElementType.java   
@NotNull
@Override
public PsiFieldStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
  final StringRef name = dataStream.readName();
  final TypeInfo type = TypeInfo.readTYPE(dataStream);
  final StringRef initializerText = dataStream.readName();
  final byte flags = dataStream.readByte();
  return new PsiFieldStubImpl(parentStub, name, type, initializerText, flags);
}
项目:intellij-ce-playground    文件:JavaClassReferenceListElementType.java   
@NotNull
@Override
public PsiClassReferenceListStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  byte role = dataStream.readByte();

  int len = dataStream.readVarInt();
  StringRef[] names = StringRef.createArray(len);
  for (int i = 0; i < names.length; i++) {
    names[i] = dataStream.readName();
  }

  PsiReferenceList.Role decodedRole = decodeRole(role);
  return new PsiClassReferenceListStubImpl(roleToElementType(decodedRole), parentStub, names, decodedRole);
}
项目:intellij-ce-playground    文件:PsiMethodStubImpl.java   
public PsiMethodStubImpl(StubElement parent,
                         String name,
                         byte flags,
                         String signature,
                         @NotNull List<String> args,
                         @Nullable List<String> throwables,
                         String desc,
                         int modifiersMask) {
  super(parent, isAnnotationMethod(flags) ? JavaStubElementTypes.ANNOTATION_METHOD : JavaStubElementTypes.METHOD);
  myName = name;
  myDefaultValueText = null;

  new PsiModifierListStubImpl(this, modifiersMask);

  String returnType = null;
  boolean parsedViaGenericSignature = false;
  if (signature != null) {
    try {
      returnType = StubBuildingVisitor.parseMethodViaGenericSignature(signature, this, args, throwables);
      parsedViaGenericSignature = true;
    }
    catch (ClsFormatException ignored) { }
  }
  if (returnType == null) {
    returnType = StubBuildingVisitor.parseMethodViaDescription(desc, this, args);
  }

  myReturnType = TypeInfo.fromString(returnType);
  myFlags = (byte)(flags | (parsedViaGenericSignature ? PARSED_VIA_GENERIC_SIGNATURE : 0));
}
项目:intellij-ce-playground    文件:PsiTypeParameterStubImpl.java   
@Override
@NotNull
public List<PsiAnnotationStub> getAnnotations() {
  List<StubElement> children = getChildrenStubs();

  return ContainerUtil.mapNotNull(children, new Function<StubElement, PsiAnnotationStub>() {
    @Override
    public PsiAnnotationStub fun(StubElement stubElement) {
      return stubElement instanceof PsiAnnotationStub ? (PsiAnnotationStub)stubElement : null;
    }
  });
}
项目:intellij-ce-playground    文件:GrMethodStub.java   
public GrMethodStub(StubElement parent,
                    StringRef name,
                    final String[] annotations,
                    @NotNull final String[] namedParameters,
                    @NotNull GrMethodElementType elementType,
                    @Nullable String typeText,
                    byte flags) {
  super(parent, elementType);
  myName = name;
  myAnnotations = annotations;
  myNamedParameters = namedParameters;
  myTypeText = typeText;
  myFlags = flags;
}
项目:intellij-ce-playground    文件:PyTargetExpressionImpl.java   
@Override
public PyClass getContainingClass() {
  final PyTargetExpressionStub stub = getStub();
  if (stub != null) {
    final StubElement parentStub = stub.getParentStub();
    if (parentStub instanceof PyClassStub) {
      return ((PyClassStub)parentStub).getPsi();
    }
    if (parentStub instanceof PyFunctionStub) {
      final StubElement functionParent = parentStub.getParentStub();
      if (functionParent instanceof PyClassStub) {
        return ((PyClassStub) functionParent).getPsi();
      }
    }

    return null;
  }

  final PsiElement parent = PsiTreeUtil.getParentOfType(this, PyFunction.class, PyClass.class);
  if (parent instanceof PyClass) {
    return (PyClass)parent;
  }
  if (parent instanceof PyFunction) {
    return ((PyFunction)parent).getContainingClass();
  }
  return null;
}
项目:intellij-ce-playground    文件:PyFileStubBuilder.java   
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file) {
  if (file instanceof PyFile) {
    return new PyFileStubImpl((PyFile)file);
  }

  return super.createStubForFile(file);
}
项目:intellij-ce-playground    文件:GrTypeDefinitionStub.java   
public GrTypeDefinitionStub(StubElement parent,
                                final String name,
                                final String[] supers,
                                @NotNull IStubElementType elementType,
                                final String qualifiedName,
                                String[] annotations,
                                byte flags) {
  super(parent, elementType);
  myAnnotations = annotations;
  myName = StringRef.fromString(name);
  mySuperClasses = supers;
  myQualifiedName = StringRef.fromString(qualifiedName);
  myFlags = flags;
}