• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PsiImplUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.impl.PsiImplUtil的典型用法代码示例。如果您正苦于以下问题:Java PsiImplUtil类的具体用法?Java PsiImplUtil怎么用?Java PsiImplUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PsiImplUtil类属于com.intellij.psi.impl包,在下文中一共展示了PsiImplUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: applyAnnotations

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TypeInfo.java


示例2: deleteChildInternal

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public void deleteChildInternal(@NotNull ASTNode child) {
  if (child.getElementType() == JAVA_CODE_REFERENCE){
    ASTNode next = PsiImplUtil.skipWhitespaceAndComments(child.getTreeNext());
    if (next != null && next.getElementType() == AND){
      deleteChildInternal(next);
    }
    else{
      ASTNode prev = PsiImplUtil.skipWhitespaceAndCommentsBack(child.getTreePrev());
      if (prev != null){
        if (prev.getElementType() == AND || prev.getElementType() == EXTENDS_KEYWORD){
          deleteChildInternal(prev);
        }
      }
    }
  }
  super.deleteChildInternal(child);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TypeParameterExtendsBoundsListElement.java


示例3: findChildByRole

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public ASTNode findChildByRole(int role){
  LOG.assertTrue(ChildRole.isUnique(role));
  switch(role){
    default:
      return null;

    case ChildRole.WHILE_KEYWORD:
      return findChildByType(WHILE_KEYWORD);

    case ChildRole.LPARENTH:
      return findChildByType(LPARENTH);

    case ChildRole.CONDITION:
      return findChildByType(EXPRESSION_BIT_SET);

    case ChildRole.RPARENTH:
      return findChildByType(RPARENTH);

    case ChildRole.LOOP_BODY:
      return PsiImplUtil.findStatementChild(this);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PsiWhileStatementImpl.java


示例4: findEnumConstantListDelimiterPlace

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Nullable
public ASTNode findEnumConstantListDelimiterPlace() {
  final ASTNode first = findChildByRole(ChildRole.LBRACE);
  if (first == null) return null;
  for (ASTNode child = first.getTreeNext(); child != null; child = child.getTreeNext()) {
    final IElementType childType = child.getElementType();
    if (PsiImplUtil.isWhitespaceOrComment(child) || childType == ERROR_ELEMENT || childType == ENUM_CONSTANT) {
    }
    else if (childType == COMMA) {
    }
    else if (childType == SEMICOLON) {
      return child;
    }
    else {
      return PsiImplUtil.skipWhitespaceAndCommentsBack(child.getTreePrev());
    }
  }

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


示例5: getNext

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Nullable
private static PsiElement getNext(@NotNull PsiElement current, PsiElement elementUnderLabel, PsiElement elementAfterLabel) {
  PsiElement e = current;

  do {
    if (e == elementUnderLabel) {
      e = elementAfterLabel;
    }
    else {
      e = e.getNextSibling();
    }
  } while (PsiImplUtil.isLeafElementOfType(e, TokenSets.WHITE_SPACES_OR_COMMENTS));

  if (e instanceof GrLabeledStatement) return null;

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


示例6: findChildByRole

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public ASTNode findChildByRole(int role){
  LOG.assertTrue(ChildRole.isUnique(role));
  switch(role){
    default:
      return null;

    case ChildRole.DOC_COMMENT:
      return PsiImplUtil.findDocComment(this);

    case ChildRole.NAME:
      return findChildByType(JavaTokenType.IDENTIFIER);

    case ChildRole.ARGUMENT_LIST:
      return findChildByType(EXPRESSION_LIST);

    case ChildRole.ANONYMOUS_CLASS:
      return findChildByType(ENUM_CONSTANT_INITIALIZER);

    case ChildRole.MODIFIER_LIST:
      return findChildByType(JavaElementType.MODIFIER_LIST);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EnumConstantElement.java


示例7: deleteChildInternal

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public void deleteChildInternal(@NotNull ASTNode child) {
  if (child.getElementType() == JavaElementType.JAVA_CODE_REFERENCE){
    ASTNode next = PsiImplUtil.skipWhitespaceAndComments(child.getTreeNext());
    if (next != null && next.getElementType() == JavaTokenType.COMMA){
      deleteChildInternal(next);
    }
    else{
      ASTNode prev = PsiImplUtil.skipWhitespaceAndCommentsBack(child.getTreePrev());
      if (prev != null){
        if (prev.getElementType() == JavaTokenType.COMMA
            || prev.getElementType() == getKeywordType()
            ){
          deleteChildInternal(prev);
        }
      }
    }
  }
  super.deleteChildInternal(child);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ReferenceListElement.java


示例8: findChildByRole

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public ASTNode findChildByRole(int role) {
  LOG.assertTrue(ChildRole.isUnique(role));
  switch(role){
    default:
      return null;

    case ChildRole.STATEMENT:
      return PsiImplUtil.findStatementChild(this);

    case ChildRole.COLON:
      return findChildByType(COLON);

    case ChildRole.LABEL_NAME:
      return getFirstChildNode();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiLabeledStatementImpl.java


示例9: addTypeUseAnnotations

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
private void addTypeUseAnnotations(List<PsiAnnotation> list) {
  PsiElement parent = this;
  while (parent instanceof PsiTypeElement) {
    PsiElement left = PsiTreeUtil.skipSiblingsBackward(parent, PsiComment.class, PsiWhiteSpace.class, PsiAnnotation.class);

    if (left instanceof PsiModifierList) {
      List<PsiAnnotation> annotations = PsiImplUtil.getTypeUseAnnotations((PsiModifierList)left);
      if (annotations != null && !annotations.isEmpty()) {
        list.addAll(annotations);
      }
      break;
    }

    if (left != null) break;

    parent = parent.getParent();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiTypeElementImpl.java


示例10: execute

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
  PsiMember member = (PsiMember)element;
  if (!isInteresting(element)) return true;
  if (myPsiClass.isInterface() && isObjectMember(element)) return true;
  if (!myAllMembers.contains(member) && isVisible(member, myPsiClass)) {
    if (member instanceof PsiMethod) {
      PsiMethod psiMethod = (PsiMethod)member;
      if (shouldAdd(psiMethod)) {
        mapMethodBySignature(psiMethod);
        myAllMembers.add(PsiImplUtil.handleMirror(psiMethod));
      }
    }
    else {
      myAllMembers.add(PsiImplUtil.handleMirror(member));
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AddAllMembersProcessor.java


示例11: getRetentionPolicy

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Nullable
public static RetentionPolicy getRetentionPolicy(@NotNull PsiClass annotation) {
  PsiModifierList modifierList = annotation.getModifierList();
  if (modifierList != null) {
    PsiAnnotation retentionAnno = modifierList.findAnnotation(CommonClassNames.JAVA_LANG_ANNOTATION_RETENTION);
    if (retentionAnno == null) return RetentionPolicy.CLASS;

    PsiAnnotationMemberValue policyRef = PsiImplUtil.findAttributeValue(retentionAnno, null);
    if (policyRef instanceof PsiReference) {
      PsiElement field = ((PsiReference)policyRef).resolve();
      if (field instanceof PsiEnumConstant) {
        String name = ((PsiEnumConstant)field).getName();
        try {
          return Enum.valueOf(RetentionPolicy.class, name);
        }
        catch (Exception e) {
          LOG.warn("Unknown policy: " + name);
        }
      }
    }
  }

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


示例12: isAnnotated

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
private static boolean isAnnotated(ASTNode element) {
  PsiJavaCodeReferenceElement ref = (PsiJavaCodeReferenceElement)element.getPsi();

  PsiElement qualifier = ref.getQualifier();
  if (qualifier instanceof PsiJavaCodeReferenceElement) {
    if (((PsiJavaCodeReferenceElement)qualifier).resolve() instanceof PsiPackage) {
      return false;
    }
    if (PsiTreeUtil.getChildOfType(qualifier, PsiAnnotation.class) != null) {
      return true;
    }
  }

  PsiModifierList modifierList = PsiImplUtil.findNeighbourModifierList(ref);
  if (modifierList != null) {
    for (PsiAnnotation annotation : modifierList.getAnnotations()) {
      if (PsiImplUtil.findApplicableTarget(annotation, PsiAnnotation.TargetType.TYPE_USE) != null) {
        return true;
      }
    }
  }

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


示例13: findDeclaredAttributeValue

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
@Nullable
public PsiAnnotationMemberValue findDeclaredAttributeValue(@NonNls final String attributeName) {
  final GrAnnotationStub stub = getStub();
  if (stub != null) {
    final GrAnnotation stubbedPsi = stub.getPsiElement();
    final PsiAnnotationMemberValue value = PsiImplUtil.findDeclaredAttributeValue(stubbedPsi, attributeName);
    if (value == null) {
      return null;
    }
  }
  return PsiImplUtil.findDeclaredAttributeValue(this, attributeName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GrAnnotationImpl.java


示例14: isDeprecated

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public boolean isDeprecated() {
  final GrFieldStub stub = getStub();
  if (stub != null) {
    return stub.isDeprecatedByDocTag() || PsiImplUtil.isDeprecatedByAnnotation(this);
  }

  return PsiImplUtil.isDeprecatedByDocTag(this) || PsiImplUtil.isDeprecatedByAnnotation(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrFieldImpl.java


示例15: registerReturnTypeConstraints

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
public void registerReturnTypeConstraints(PsiType returnType, PsiType targetType) {
  returnType = substituteWithInferenceVariables(returnType);
  final InferenceVariable inferenceVariable = shouldResolveAndInstantiate(returnType, targetType);
  if (inferenceVariable != null) {
    final PsiSubstitutor substitutor = resolveSubset(Collections.singletonList(inferenceVariable), mySiteSubstitutor);
    final PsiType substitutedReturnType = substitutor.substitute(inferenceVariable.getParameter());
    if (substitutedReturnType != null) {
      addConstraint(new TypeCompatibilityConstraint(targetType, PsiImplUtil.normalizeWildcardTypeByPosition(substitutedReturnType, (PsiExpression)myContext)));
    }
  } 
  else {
    if (FunctionalInterfaceParameterizationUtil.isWildcardParameterized(returnType)) {
      final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(returnType);
      final PsiClass psiClass = resolveResult.getElement();
      if (psiClass != null) {
        LOG.assertTrue(returnType instanceof PsiClassType);
        final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters();
        InferenceVariable[] copy = initBounds(null, typeParameters);
        final PsiType substitutedCapture = PsiImplUtil.normalizeWildcardTypeByPosition(returnType, (PsiExpression)myContext);
        myIncorporationPhase.addCapture(copy, (PsiClassType)substituteWithInferenceVariables(returnType));
        addConstraint(new TypeCompatibilityConstraint(targetType, substitutedCapture));
      }
    } else {
      addConstraint(new TypeCompatibilityConstraint(targetType, myErased ? TypeConversionUtil.erasure(returnType) : returnType));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:InferenceSession.java


示例16: bindToElement

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException{
  if(element instanceof PsiLabeledStatement){
    myIdentifier = (PsiIdentifier) PsiImplUtil.setName(myIdentifier, ((PsiLabeledStatement)element).getName());
    return myIdentifier;
  }
  throw new IncorrectOperationException("Can't bind not to labeled statement");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PsiLabelReference.java


示例17: getAnnotations

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
private List<PsiAnnotation> getAnnotations() {
  List<PsiAnnotation> annotations = PsiTreeUtil.getChildrenOfTypeAsList(this, PsiAnnotation.class);

  if (!isQualified()) {
    PsiModifierList modifierList = PsiImplUtil.findNeighbourModifierList(this);
    if (modifierList != null) {
      List<PsiAnnotation> typeAnnotations = PsiImplUtil.getTypeUseAnnotations(modifierList);
      if (typeAnnotations != null && !typeAnnotations.isEmpty()) {
        annotations.addAll(typeAnnotations);
      }
    }
  }

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


示例18: getVariants

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
@NotNull
public Object[] getVariants() {
  final ElementFilter filter;
  switch (getKind(getContainingFile())) {
    case CLASS_OR_PACKAGE_NAME_KIND:
      filter = new OrFilter();
      ((OrFilter)filter).addFilter(ElementClassFilter.CLASS);
      ((OrFilter)filter).addFilter(ElementClassFilter.PACKAGE_FILTER);
      break;
    case CLASS_NAME_KIND:
      filter = ElementClassFilter.CLASS;
      break;
    case PACKAGE_NAME_KIND:
      filter = ElementClassFilter.PACKAGE_FILTER;
      break;
    case CLASS_FQ_NAME_KIND:
    case CLASS_FQ_OR_PACKAGE_NAME_KIND:
      filter = new OrFilter();
      ((OrFilter)filter).addFilter(ElementClassFilter.PACKAGE_FILTER);
      if (isQualified()) {
        ((OrFilter)filter).addFilter(ElementClassFilter.CLASS);
      }
      break;
    case CLASS_IN_QUALIFIED_NEW_KIND:
      filter = ElementClassFilter.CLASS;
      break;
    default:
      throw new RuntimeException("Unknown reference type");
  }

  return PsiImplUtil.getReferenceVariantsByFilter(this, filter);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PsiJavaCodeReferenceElementImpl.java


示例19: unwrap

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public List<PsiElement> unwrap(Editor editor, PsiElement element) throws IncorrectOperationException {
  List<PsiElement> res = super.unwrap(editor, element);

  for (PsiElement e : res) {
    if (PsiImplUtil.isLeafElementOfType(e, GroovyTokenTypes.mNLS)) {
      CodeEditUtil.setNodeGenerated(e.getNode(), true);
    }
  }

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


示例20: findChildByRole

import com.intellij.psi.impl.PsiImplUtil; //导入依赖的package包/类
@Override
public ASTNode findChildByRole(int role){
  LOG.assertTrue(ChildRole.isUnique(role));
  switch(role){
    default:
      return null;

    case ChildRole.DO_KEYWORD:
      return findChildByType(DO_KEYWORD);

    case ChildRole.LOOP_BODY:
      return PsiImplUtil.findStatementChild(this);

    case ChildRole.WHILE_KEYWORD:
      return findChildByType(WHILE_KEYWORD);

    case ChildRole.LPARENTH:
      return findChildByType(LPARENTH);

    case ChildRole.CONDITION:
      return findChildByType(EXPRESSION_BIT_SET);

    case ChildRole.RPARENTH:
      return findChildByType(RPARENTH);

    case ChildRole.CLOSING_SEMICOLON:
      return TreeUtil.findChildBackward(this, SEMICOLON);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PsiDoWhileStatementImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UMLUtil类代码示例发布时间:2022-05-23
下一篇:
Java ICandleDataSet类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap