当前位置: 首页>>代码示例>>Java>>正文


Java StubElement.getStubType方法代码示例

本文整理汇总了Java中com.intellij.psi.stubs.StubElement.getStubType方法的典型用法代码示例。如果您正苦于以下问题:Java StubElement.getStubType方法的具体用法?Java StubElement.getStubType怎么用?Java StubElement.getStubType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.stubs.StubElement的用法示例。


在下文中一共展示了StubElement.getStubType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processStubProperties

import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@Nullable
private Property processStubProperties(@Nullable String name, @Nullable Processor<Property> propertyProcessor) {
  final PyClassStub stub = getStub();
  if (stub != null) {
    for (StubElement subStub : stub.getChildrenStubs()) {
      if (subStub.getStubType() == PyElementTypes.TARGET_EXPRESSION) {
        final PyTargetExpressionStub targetStub = (PyTargetExpressionStub)subStub;
        PropertyStubStorage prop = targetStub.getCustomStub(PropertyStubStorage.class);
        if (prop != null && (name == null || name.equals(targetStub.getName()))) {
          Maybe<PyCallable> getter = fromPacked(prop.getGetter());
          Maybe<PyCallable> setter = fromPacked(prop.getSetter());
          Maybe<PyCallable> deleter = fromPacked(prop.getDeleter());
          String doc = prop.getDoc();
          if (getter != NONE || setter != NONE || deleter != NONE) {
            final PropertyImpl property = new PropertyImpl(targetStub.getName(), getter, setter, deleter, doc, targetStub.getPsi());
            if (propertyProcessor == null || propertyProcessor.process(property)) return property;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PyClassImpl.java

示例2: collectStubChildren

import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@NotNull
static <T, U extends PsiElement> List<T> collectStubChildren(U e,
                                                             final StubElement<U> stub, final IElementType elementType,
                                                             final Class<T> itemClass) {
  final List<T> result = new ArrayList<T>();
  if (stub != null) {
    final List<StubElement> children = stub.getChildrenStubs();
    for (StubElement child : children) {
      if (child.getStubType() == elementType) {
        //noinspection unchecked
        result.add((T)child.getPsi());
      }
    }
  }
  else {
    e.acceptChildren(new TopLevelVisitor() {
      @Override
      protected void checkAddElement(PsiElement node) {
        if (node.getNode().getElementType() == elementType) {
          //noinspection unchecked
          result.add((T)node);
        }
      }
    });
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:PyPsiUtils.java

示例3: packModifierList

import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
public static int packModifierList(@NotNull LighterAST tree, @NotNull LighterASTNode modList, @NotNull StubElement parent) {
  int packed = 0;

  final LighterASTNode modListOwner = tree.getParent(modList);
  if (modListOwner != null && modListOwner.getTokenType() == parent.getStubType()) {
    final StubElement grandParent = parent.getParentStub();
    if (parent instanceof PsiClassStub) {
      if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
        packed |= ModifierFlags.PUBLIC_MASK;
        packed |= ModifierFlags.STATIC_MASK;
      }
      if (((PsiClassStub)parent).isInterface()) {
        packed |= ModifierFlags.ABSTRACT_MASK;
        if (grandParent instanceof PsiClassStub) {
          packed |= ModifierFlags.STATIC_MASK;
        }
      }
      else if (((PsiClassStub)parent).isEnum()) {
        if (!(grandParent instanceof PsiFileStub)) {
          packed |= ModifierFlags.STATIC_MASK;
        }

        boolean isFinal = true;
        final List<LighterASTNode> enumConstants = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.ENUM_CONSTANT);
        for (final LighterASTNode constant : enumConstants) {
          if (LightTreeUtil.firstChildOfType(tree, constant, JavaElementType.ENUM_CONSTANT_INITIALIZER) != null) {
            isFinal = false;
            break;
          }
        }
        if (isFinal) {
          packed |= ModifierFlags.FINAL_MASK;
        }

        final List<LighterASTNode> methods = LightTreeUtil.getChildrenOfType(tree, modListOwner, JavaElementType.METHOD);
        for (final LighterASTNode method : methods) {
          final LighterASTNode mods = LightTreeUtil.requiredChildOfType(tree, method, JavaElementType.MODIFIER_LIST);
          if (LightTreeUtil.firstChildOfType(tree, mods, JavaTokenType.ABSTRACT_KEYWORD) != null) {
            packed |= ModifierFlags.ABSTRACT_MASK;
            break;
          }
        }
      }
    }
    else if (parent instanceof PsiMethodStub) {
      if (grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
        packed |= ModifierFlags.PUBLIC_MASK;
        packed |= ModifierFlags.ABSTRACT_MASK;
      }
    }
    else if (parent instanceof PsiFieldStub) {
      if (parent.getStubType() == JavaElementType.ENUM_CONSTANT ||
          grandParent instanceof PsiClassStub && ((PsiClassStub)grandParent).isInterface()) {
        packed |= ModifierFlags.PUBLIC_MASK;
        packed |= ModifierFlags.STATIC_MASK;
        packed |= ModifierFlags.FINAL_MASK;
      }
    }
  }

  for (final LighterASTNode child : tree.getChildren(modList)) {
    final int flag = ModifierFlags.KEYWORD_TO_MODIFIER_FLAG_MAP.get(child.getTokenType());
    if (flag != 0) {
      packed |= flag;
    }
  }

  if ((packed & ModifierFlags.DEFENDER_MASK) != 0) {
    packed &= ~ModifierFlags.ABSTRACT_MASK;
  }

  if ((packed & (ModifierFlags.PRIVATE_MASK | ModifierFlags.PROTECTED_MASK | ModifierFlags.PUBLIC_MASK)) == 0) {
    packed |= ModifierFlags.PACKAGE_LOCAL_MASK;
  }

  return packed;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:78,代码来源:RecordUtil.java

示例4: restoreFromStubIndex

import com.intellij.psi.stubs.StubElement; //导入方法依赖的package包/类
@Nullable
public static PsiElement restoreFromStubIndex(PsiFileWithStubSupport fileImpl,
                                              int index,
                                              @NotNull IStubElementType elementType, boolean throwIfNull) {
  if (fileImpl == null) {
    if (throwIfNull) throw new AssertionError("Null file");
    return null;
  }
  StubTree tree = fileImpl.getStubTree();

  boolean foreign = tree == null;
  if (foreign) {
    if (fileImpl instanceof PsiFileImpl) {
      // Note: as far as this is a realization of StubIndexReference fileImpl#getContentElementType() must be instance of IStubFileElementType
      tree = ((PsiFileImpl)fileImpl).calcStubTree();
    }
    else {
      if (throwIfNull) throw new AssertionError("Not PsiFileImpl: " + fileImpl.getClass());
      return null;
    }
  }

  List<StubElement<?>> list = tree.getPlainList();
  if (index >= list.size()) {
    if (throwIfNull) throw new AssertionError("Too large index: " + index + ">=" + list.size());
    return null;
  }
  StubElement stub = list.get(index);

  if (stub.getStubType() != elementType) {
    if (throwIfNull) throw new AssertionError("Element type mismatch: " + stub.getStubType() + "!=" + elementType);
    return null;
  }

  if (foreign) {
    final PsiElement cachedPsi = ((StubBase)stub).getCachedPsi();
    if (cachedPsi != null) return cachedPsi;

    final ASTNode ast = fileImpl.findTreeForStub(tree, stub);
    if (ast != null) {
      return ast.getPsi();
    }

    if (throwIfNull) throw new AssertionError("No AST for stub");
    return null;
  }
  return stub.getPsi();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:PsiAnchor.java


注:本文中的com.intellij.psi.stubs.StubElement.getStubType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。