Java 类com.intellij.psi.impl.java.stubs.JavaStubElementTypes 实例源码

项目: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    文件:PsiBuilderTest.java   
public void testProgramWithSingleKeyword() throws Exception {
  myBuilder = createBuilder("package");

  final PsiBuilder.Marker fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  final PsiBuilder.Marker packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.done(JavaElementType.PACKAGE_STATEMENT);
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);

  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("package", fileNode.getText());
  assertSame(fileNode.getFirstChildNode(), fileNode.getLastChildNode());
  ASTNode packageNode = fileNode.getFirstChildNode();
  assertNotNull(packageNode);
  assertEquals("package", packageNode.getText());
  assertEquals(JavaElementType.PACKAGE_STATEMENT, packageNode.getElementType());

  ASTNode leaf = packageNode.getFirstChildNode();
  assertNotNull(leaf);
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, leaf.getElementType());
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
public void testDrop() throws Exception {
  myBuilder = createBuilder("package");

  final PsiBuilder.Marker fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  final PsiBuilder.Marker packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.drop();
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);

  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("package", fileNode.getText());
  assertSame(fileNode.getFirstChildNode(), fileNode.getLastChildNode());

  ASTNode leaf = fileNode.getFirstChildNode();
  assertNotNull(leaf);
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, leaf.getElementType());
  assertEquals("package", leaf.getText());
  assertNull(leaf.getFirstChildNode());
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
private void parseWhenEmptyElementAfterWhitespaceIsLastChild() {
  final PsiBuilder.Marker root = myBuilder.mark();

  final PsiBuilder.Marker composite = myBuilder.mark();
  final PsiBuilder.Marker backup = myBuilder.mark();
  if ("foo".equals(myBuilder.getTokenText())) {
    myBuilder.advanceLexer();
    myBuilder.getTokenType();
    myBuilder.mark().done(JavaStubElementTypes.TYPE_PARAMETER_LIST);
    backup.done(JavaStubElementTypes.ANNOTATION_METHOD);
  } else {
    backup.rollbackTo();
  }
  composite.done(JavaStubElementTypes.ANONYMOUS_CLASS);

  myBuilder.getTokenType();
  myBuilder.advanceLexer();
  root.done(JavaStubElementTypes.ENUM_CONSTANT_INITIALIZER);
}
项目:tools-idea    文件:PsiBuilderTest.java   
public void testProgramWithSingleKeyword() throws Exception {
  myBuilder = createBuilder("package");

  final PsiBuilder.Marker fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  final PsiBuilder.Marker packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.done(JavaElementType.PACKAGE_STATEMENT);
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);

  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("package", fileNode.getText());
  assertSame(fileNode.getFirstChildNode(), fileNode.getLastChildNode());
  ASTNode packageNode = fileNode.getFirstChildNode();
  assertNotNull(packageNode);
  assertEquals("package", packageNode.getText());
  assertEquals(JavaElementType.PACKAGE_STATEMENT, packageNode.getElementType());

  ASTNode leaf = packageNode.getFirstChildNode();
  assertNotNull(leaf);
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, leaf.getElementType());
}
项目:tools-idea    文件:PsiBuilderTest.java   
public void testDrop() throws Exception {
  myBuilder = createBuilder("package");

  final PsiBuilder.Marker fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  final PsiBuilder.Marker packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.drop();
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);

  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("package", fileNode.getText());
  assertSame(fileNode.getFirstChildNode(), fileNode.getLastChildNode());

  ASTNode leaf = fileNode.getFirstChildNode();
  assertNotNull(leaf);
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, leaf.getElementType());
  assertEquals("package", leaf.getText());
  assertNull(leaf.getFirstChildNode());
}
项目:tools-idea    文件:PsiBuilderTest.java   
private void parseWhenEmptyElementAfterWhitespaceIsLastChild() {
  final PsiBuilder.Marker root = myBuilder.mark();

  final PsiBuilder.Marker composite = myBuilder.mark();
  final PsiBuilder.Marker backup = myBuilder.mark();
  if ("foo".equals(myBuilder.getTokenText())) {
    myBuilder.advanceLexer();
    myBuilder.getTokenType();
    myBuilder.mark().done(JavaStubElementTypes.TYPE_PARAMETER_LIST);
    backup.done(JavaStubElementTypes.ANNOTATION_METHOD);
  } else {
    backup.rollbackTo();
  }
  composite.done(JavaStubElementTypes.ANONYMOUS_CLASS);

  myBuilder.getTokenType();
  myBuilder.advanceLexer();
  root.done(JavaStubElementTypes.ENUM_CONSTANT_INITIALIZER);
}
项目:consulo-java    文件:ClsFileImpl.java   
@Override
public PsiPackageStatement getPackageStatement()
{
    ClsPackageStatementImpl statement = myPackageStatement;
    if(statement == null)
    {
        statement = ClsPackageStatementImpl.NULL_PACKAGE;
        PsiClassHolderFileStub<?> stub = getStub();
        if(!(stub instanceof PsiJavaFileStub) || stub.findChildStubByType(JavaStubElementTypes.MODULE) == null)
        {
            String packageName = findPackageName(stub);
            if(packageName != null)
            {
                statement = new ClsPackageStatementImpl(this, packageName);
            }
        }
        myPackageStatement = statement;
    }
    return statement != ClsPackageStatementImpl.NULL_PACKAGE ? statement : null;
}
项目:consulo-java    文件:RecordUtil.java   
public static boolean isStaticNonPrivateMember(@NotNull StubElement<?> stub)
{
    StubElement<PsiModifierList> type = stub.findChildStubByType(JavaStubElementTypes.MODIFIER_LIST);
    if(!(type instanceof PsiModifierListStub))
    {
        return false;
    }

    int mask = ((PsiModifierListStub) type).getModifiersMask();
    if(ModifierFlags.hasModifierProperty(PsiModifier.PRIVATE, mask))
    {
        return false;
    }

    if(ModifierFlags.hasModifierProperty(PsiModifier.STATIC, mask))
    {
        return true;
    }

    return stub instanceof PsiFieldStub && stub.getStubType() == JavaElementType.ENUM_CONSTANT || stub.getParentStub() instanceof PsiClassStub && ((PsiClassStub) stub.getParentStub()).isInterface();
}
项目:consulo-java    文件:PsiJavaFileBaseImpl.java   
@Override
@Nullable
public PsiImportList getImportList()
{
    StubElement<?> stub = getGreenStub();
    if(stub != null)
    {
        PsiImportList[] nodes = stub.getChildrenByType(JavaStubElementTypes.IMPORT_LIST, PsiImportList.ARRAY_FACTORY);
        if(nodes.length == 1)
        {
            return nodes[0];
        }
        if(nodes.length == 0)
        {
            return null;
        }
        reportStubAstMismatch(stub + "; " + stub.getChildrenStubs(), getStubTree());
    }

    ASTNode node = calcTreeElement().findChildByType(JavaElementType.IMPORT_LIST);
    return (PsiImportList) SourceTreeToPsiMap.treeElementToPsi(node);
}
项目:consulo-java    文件:PsiClassImpl.java   
@Nullable
private StubElement getContextStub()
{
    PsiClassStub<?> stub = getStub();
    if(stub == null)
    {
        return null;
    }

    // if AST is not loaded, then we only can need context to resolve supertype references
    // this can be done by stubs unless there are local/anonymous classes referencing other local classes
    StubElement parent = stub.getParentStub();
    if(parent instanceof PsiClassInitializerStub || parent instanceof PsiMethodStub)
    {
        if(parent.getChildrenByType(JavaStubElementTypes.CLASS, PsiElement.ARRAY_FACTORY).length <= 1)
        {
            parent = parent.getParentStub();
        }
    }
    return parent instanceof PsiClassStub ? parent : null;
}
项目: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    文件:PsiMethodStubImpl.java   
public PsiMethodStubImpl(StubElement parent, String name, @NotNull TypeInfo returnType, byte flags, @Nullable String defaultValueText) {
  super(parent, isAnnotationMethod(flags) ? JavaStubElementTypes.ANNOTATION_METHOD : JavaStubElementTypes.METHOD);
  myReturnType = returnType;
  myFlags = flags;
  myName = name;
  myDefaultValueText = defaultValueText;
}
项目:intellij-ce-playground    文件:PsiFieldStubImpl.java   
public PsiFieldStubImpl(StubElement parent, StringRef name, @NotNull TypeInfo type, @Nullable StringRef initializer, byte flags) {
  super(parent, isEnumConst(flags) ? JavaStubElementTypes.ENUM_CONSTANT : JavaStubElementTypes.FIELD);
  myName = name;
  myType = type;
  myInitializer = initializer;
  myFlags = flags;
}
项目:intellij-ce-playground    文件:SignatureParsing.java   
private static PsiTypeParameterStub parseTypeParameter(CharacterIterator iterator, PsiTypeParameterListStub parent) throws ClsFormatException {
  StringBuilder name = new StringBuilder();
  while (iterator.current() != ':' && iterator.current() != CharacterIterator.DONE) {
    name.append(iterator.current());
    iterator.next();
  }
  if (iterator.current() == CharacterIterator.DONE) {
    throw new ClsFormatException();
  }

  //todo parse annotations on type param
  PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(parent, StringRef.fromString(name.toString()));

  // postpone list allocation till a second bound is seen; ignore sole Object bound
  List<String> bounds = null;
  boolean jlo = false;
  while (iterator.current() == ':') {
    iterator.next();
    String bound = parseTopLevelClassRefSignature(iterator);
    if (bound == null) continue;
    if (bounds == null) {
      if (CommonClassNames.JAVA_LANG_OBJECT.equals(bound)) {
        jlo = true;
        continue;
      }
      bounds = ContainerUtil.newSmartList();
      if (jlo) {
        bounds.add(CommonClassNames.JAVA_LANG_OBJECT);
      }
    }
    bounds.add(bound);
  }

  StubBuildingVisitor.newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, ArrayUtil.toStringArray(bounds));

  return parameterStub;
}
项目:intellij-ce-playground    文件:PsiModifierListImpl.java   
@Override
@NotNull
public PsiAnnotation[] getAnnotations() {
  final PsiAnnotation[] own = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
  final List<PsiAnnotation> ext = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
  return ArrayUtil.mergeArrayAndCollection(own, ext, PsiAnnotation.ARRAY_FACTORY);
}
项目:intellij-ce-playground    文件:PsiJavaFileBaseImpl.java   
@Override
@NotNull
public PsiClass[] getClasses() {
  final StubElement<?> stub = getStub();
  if (stub != null) {
    return stub.getChildrenByType(JavaStubElementTypes.CLASS, PsiClass.ARRAY_FACTORY);
  }

  return calcTreeElement().getChildrenAsPsiElements(Constants.CLASS_BIT_SET, PsiClass.ARRAY_FACTORY);
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
public void testEmptyProgram() throws Exception {
  myBuilder = createBuilder("");
  final PsiBuilder.Marker fileMarker = myBuilder.mark();
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);
  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("", fileNode.getText());
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
public void testTrailingWhitespaces() throws Exception {
  myBuilder = createBuilder("foo\n\nx");
  final PsiBuilder.Marker marker = myBuilder.mark();
  while (!myBuilder.eof()) {
    myBuilder.advanceLexer();
  }
  marker.done(JavaStubElementTypes.JAVA_FILE);
  assertEquals("foo\n\nx", myBuilder.getTreeBuilt().getText());
}
项目:intellij-ce-playground    文件:PsiBuilderTest.java   
public void testRollback() throws Exception {
  myBuilder = createBuilder("package");

  PsiBuilder.Marker fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  PsiBuilder.Marker packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.done(JavaElementType.PACKAGE_STATEMENT);

  fileMarker.rollbackTo();

  fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.done(JavaElementType.PACKAGE_STATEMENT);
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);

  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("package", fileNode.getText());
  assertSame(fileNode.getFirstChildNode(), fileNode.getLastChildNode());
  ASTNode packageNode = fileNode.getFirstChildNode();
  assertNotNull(packageNode);
  assertEquals("package", packageNode.getText());
  assertEquals(JavaElementType.PACKAGE_STATEMENT, packageNode.getElementType());

  ASTNode leaf = packageNode.getFirstChildNode();
  assertNotNull(leaf);
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, leaf.getElementType());
}
项目:tools-idea    文件:PsiMethodStubImpl.java   
public PsiMethodStubImpl(StubElement parent, StringRef name, TypeInfo returnType, byte flags, StringRef defaultValueText) {
  super(parent, isAnnotationMethod(flags) ? JavaStubElementTypes.ANNOTATION_METHOD : JavaStubElementTypes.METHOD);
  myReturnType = returnType;
  myFlags = flags;
  myName = name;
  myDefaultValueText = defaultValueText;
}
项目:tools-idea    文件:PsiFieldStubImpl.java   
public PsiFieldStubImpl(StubElement parent, StringRef name, @NotNull TypeInfo type, @Nullable StringRef initializer, byte flags) {
  super(parent, isEnumConst(flags) ? JavaStubElementTypes.ENUM_CONSTANT : JavaStubElementTypes.FIELD);
  myName = name;
  myType = type;
  myInitializer = initializer;
  myFlags = flags;
}
项目:tools-idea    文件:SignatureParsing.java   
private static PsiTypeParameterStub parseTypeParameter(CharacterIterator signatureIterator, PsiTypeParameterListStub parent)
    throws ClsFormatException {
  StringBuilder name = new StringBuilder();
  while (signatureIterator.current() != ':' && signatureIterator.current() != CharacterIterator.DONE) {
    name.append(signatureIterator.current());
    signatureIterator.next();
  }
  if (signatureIterator.current() == CharacterIterator.DONE) {
    throw new ClsFormatException();
  }

  //todo parse annotations on type param
  PsiTypeParameterStub parameterStub = new PsiTypeParameterStubImpl(parent, StringRef.fromString(name.toString()));

  ArrayList<String> bounds = null;
  while (signatureIterator.current() == ':') {
    signatureIterator.next();
    String bound = parseTopLevelClassRefSignature(signatureIterator);
    if (bound != null && !bound.equals(CommonClassNames.JAVA_LANG_OBJECT)) {
      if (bounds == null) bounds = new ArrayList<String>();
      bounds.add(bound);
    }
  }

  StubBuildingVisitor.newReferenceList(JavaStubElementTypes.EXTENDS_BOUND_LIST, parameterStub, ArrayUtil.toStringArray(bounds));

  return parameterStub;
}
项目:tools-idea    文件: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 = ContainerUtil.newArrayList();
  for (StubElement child : modifierList.getChildrenStubs()) {
    if (!(child instanceof PsiAnnotationStub)) continue;
    PsiAnnotationStub annotationStub = (PsiAnnotationStub)child;
    if (PsiImplUtil.findApplicableTarget(annotationStub.getPsiElement(), TargetType.TYPE_USE) == TargetType.TYPE_USE) {
      annotationStubs.add(annotationStub);
    }
  }
  return new TypeInfo(text, arrayCount, isEllipsis, annotationStubs);
}
项目:tools-idea    文件:PsiModifierListImpl.java   
@Override
@NotNull
public PsiAnnotation[] getAnnotations() {
  final PsiAnnotation[] own = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
  final List<PsiAnnotation> ext = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
  return ArrayUtil.mergeArrayAndCollection(own, ext, PsiAnnotation.ARRAY_FACTORY);
}
项目:tools-idea    文件:PsiJavaFileBaseImpl.java   
@Override
@NotNull
public PsiClass[] getClasses() {
  final StubElement<?> stub = getStub();
  if (stub != null) {
    return stub.getChildrenByType(JavaStubElementTypes.CLASS, PsiClass.ARRAY_FACTORY);
  }

  return calcTreeElement().getChildrenAsPsiElements(Constants.CLASS_BIT_SET, PsiClass.ARRAY_FACTORY);
}
项目:tools-idea    文件:PsiBuilderTest.java   
public void testEmptyProgram() throws Exception {
  myBuilder = createBuilder("");
  final PsiBuilder.Marker fileMarker = myBuilder.mark();
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);
  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("", fileNode.getText());
}
项目:tools-idea    文件:PsiBuilderTest.java   
public void testTrailingWhitespaces() throws Exception {
  myBuilder = createBuilder("foo\n\nx");
  final PsiBuilder.Marker marker = myBuilder.mark();
  while (!myBuilder.eof()) {
    myBuilder.advanceLexer();
  }
  marker.done(JavaStubElementTypes.JAVA_FILE);
  assertEquals("foo\n\nx", myBuilder.getTreeBuilt().getText());
}
项目:tools-idea    文件:PsiBuilderTest.java   
public void testRollback() throws Exception {
  myBuilder = createBuilder("package");

  PsiBuilder.Marker fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  PsiBuilder.Marker packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.done(JavaElementType.PACKAGE_STATEMENT);

  fileMarker.rollbackTo();

  fileMarker = myBuilder.mark();
  assertEquals("package", myBuilder.getTokenText());
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, myBuilder.getTokenType());
  packageStatementMarker = myBuilder.mark();
  myBuilder.advanceLexer();
  assertTrue(myBuilder.eof());
  packageStatementMarker.done(JavaElementType.PACKAGE_STATEMENT);
  fileMarker.done(JavaStubElementTypes.JAVA_FILE);

  ASTNode fileNode = myBuilder.getTreeBuilt();
  assertNotNull(fileNode);
  assertEquals("package", fileNode.getText());
  assertSame(fileNode.getFirstChildNode(), fileNode.getLastChildNode());
  ASTNode packageNode = fileNode.getFirstChildNode();
  assertNotNull(packageNode);
  assertEquals("package", packageNode.getText());
  assertEquals(JavaElementType.PACKAGE_STATEMENT, packageNode.getElementType());

  ASTNode leaf = packageNode.getFirstChildNode();
  assertNotNull(leaf);
  assertEquals(JavaTokenType.PACKAGE_KEYWORD, leaf.getElementType());
}
项目:consulo-java    文件:PsiMethodStubImpl.java   
public PsiMethodStubImpl(StubElement parent, String name, @NotNull TypeInfo returnType, byte flags, @Nullable String defaultValueText)
{
    super(parent, isAnnotationMethod(flags) ? JavaStubElementTypes.ANNOTATION_METHOD : JavaStubElementTypes.METHOD);
    myReturnType = returnType;
    myFlags = flags;
    myName = name;
    myDefaultValueText = defaultValueText;
}
项目:consulo-java    文件:PsiFieldStubImpl.java   
public PsiFieldStubImpl(StubElement parent,
        StringRef name,
        @NotNull TypeInfo type,
        @Nullable StringRef initializer,
        byte flags)
{
    super(parent, isEnumConst(flags) ? JavaStubElementTypes.ENUM_CONSTANT : JavaStubElementTypes.FIELD);
    myName = name;
    myType = type;
    myInitializer = initializer;
    myFlags = flags;
}
项目:consulo-java    文件:PsiParameterStubImpl.java   
public PsiParameterStubImpl(StubElement parent, @NotNull String name, @NotNull TypeInfo type, byte flags)
{
    super(parent, JavaStubElementTypes.PARAMETER);
    myName = name;
    myType = type;
    myFlags = flags;
}
项目:consulo-java    文件: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);
}
项目:consulo-java    文件:PsiModifierListImpl.java   
@Override
@NotNull
public PsiAnnotation[] getAnnotations()
{
    final PsiAnnotation[] own = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
    final List<PsiAnnotation> ext = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
    return ArrayUtil.mergeArrayAndCollection(own, ext, PsiAnnotation.ARRAY_FACTORY);
}
项目:consulo-java    文件:PsiMethodImpl.java   
@Override
@NotNull
public PsiReferenceList getThrowsList()
{
    PsiReferenceList child = getStubOrPsiChild(JavaStubElementTypes.THROWS_LIST);
    if(child != null)
    {
        return child;
    }

    PsiMethodStub stub = getStub();
    Stream<String> children = stub != null ? stub.getChildrenStubs().stream().map(s -> s.getClass().getSimpleName() + " : " + s.getStubType()) : Stream.of(getChildren()).map(e -> e.getClass()
            .getSimpleName() + " : " + e.getNode().getElementType());
    throw new AssertionError("Missing throws list, file=" + getContainingFile() + " children:\n" + children.collect(Collectors.joining("\n")));
}
项目:consulo-java    文件:PsiJavaFileBaseImpl.java   
@Override
@NotNull
public PsiClass[] getClasses()
{
    final StubElement<?> stub = getStub();
    if(stub != null)
    {
        return stub.getChildrenByType(JavaStubElementTypes.CLASS, PsiClass.ARRAY_FACTORY);
    }

    return calcTreeElement().getChildrenAsPsiElements(Constants.CLASS_BIT_SET, PsiClass.ARRAY_FACTORY);
}
项目:consulo-java    文件:JavaNullMethodArgumentIndex.java   
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter()
{
    return new DefaultFileTypeSpecificInputFilter(JavaFileType.INSTANCE)
    {
        @Override
        public boolean acceptInput(@Nullable Project project, @NotNull VirtualFile file)
        {
            return JavaStubElementTypes.JAVA_FILE.shouldBuildStubFor(file);
        }
    };
}
项目:intellij-ce-playground    文件:JavaParserDefinition.java   
@Override
public IFileElementType getFileNodeType() {
  return JavaStubElementTypes.JAVA_FILE;
}
项目:intellij-ce-playground    文件:PsiImportListStubImpl.java   
public PsiImportListStubImpl(final StubElement parent) {
  super(parent, JavaStubElementTypes.IMPORT_LIST);
}
项目:intellij-ce-playground    文件:PsiNameValuePairStubImpl.java   
public PsiNameValuePairStubImpl(StubElement parent, @Nullable StringRef name, @Nullable StringRef value) {
  super(parent, JavaStubElementTypes.NAME_VALUE_PAIR);
  myName = name;
  myValue = value;
}