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

Java PsiClassInitializer类代码示例

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

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



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

示例1: collectNodes

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
public void collectNodes(PsiClass psiClass) {
    for (PsiMethod psiMethod : psiClass.getMethods()) {
        elementsAddedByUser.put(getFqn(psiMethod), spManager.createSmartPsiElementPointer((PsiElement) psiMethod));
    }

    for (PsiField psiField : psiClass.getFields()) {
        elementsAddedByUser.put(getFqn(psiField), spManager.createSmartPsiElementPointer((PsiElement) psiField));
    }

    for (PsiClassInitializer psiClassInitializer : psiClass.getInitializers()) {
        elementsAddedByUser.put(getFqn(psiClassInitializer), spManager.createSmartPsiElementPointer((PsiElement) psiClassInitializer));
    }

    for (PsiClass innerClass : psiClass.getInnerClasses()) {
        elementsAddedByUser.put(getFqn(innerClass), spManager.createSmartPsiElementPointer((PsiElement) innerClass));
    }
}
 
开发者ID:Stefku,项目名称:intellij-reference-diagram,代码行数:18,代码来源:ReferenceDiagramDataModel.java


示例2: dispatch

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
public T dispatch(PsiElement psiElement) {
    if (psiElement instanceof PsiClass) {
        if (((PsiClass) psiElement).getContainingClass() == null) {
            return processClass((PsiClass) psiElement);
        } else {
            if (((PsiClass) psiElement).isEnum()) {
                return processEnum((PsiClass) psiElement);
            } else {
                if (((PsiClass) psiElement).hasModifierProperty("static")) {
                    return processStaticInnerClass((PsiClass) psiElement);
                } else {
                    return processInnerClass((PsiClass) psiElement);
                }
            }
        }
    } else if (psiElement instanceof PsiMethod) {
        return processMethod((PsiMethod) psiElement);
    } else if (psiElement instanceof PsiField) {
        return processField((PsiField) psiElement);
    } else if (psiElement instanceof PsiClassInitializer) {
        return processClassInitializer((PsiClassInitializer) psiElement);
    }
    throw new IllegalArgumentException("Type of PsiElement not supported: " + psiElement);
}
 
开发者ID:Stefku,项目名称:intellij-reference-diagram,代码行数:25,代码来源:PsiElementDispatcher.java


示例3: registerNestedClosures

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
private void registerNestedClosures(@NotNull DfaInstructionState instructionState, @NotNull PsiClass nestedClass)
{
	DfaMemoryState state = instructionState.getMemoryState();
	for(PsiMethod method : nestedClass.getMethods())
	{
		PsiCodeBlock body = method.getBody();
		if(body != null)
		{
			createClosureState(body, state);
		}
	}
	for(PsiClassInitializer initializer : nestedClass.getInitializers())
	{
		createClosureState(initializer.getBody(), state);
	}
	for(PsiField field : nestedClass.getFields())
	{
		createClosureState(field, state);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:DataFlowRunner.java


示例4: isInitializedInInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
private boolean isInitializedInInitializer(@NotNull PsiField field, UninitializedReadCollector uninitializedReadsCollector) {
  final PsiClass aClass = field.getContainingClass();
  if (aClass == null) {
    return false;
  }
  final PsiClassInitializer[] initializers = aClass.getInitializers();
  for (final PsiClassInitializer initializer : initializers) {
    if (!initializer.hasModifierProperty(PsiModifier.STATIC)) {
      final PsiCodeBlock body = initializer.getBody();
      if (uninitializedReadsCollector.blockAssignsVariable(body, field)) {
        return true;
      }
    }
  }
  return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:InstanceVariableUninitializedUseInspection.java


示例5: getDeclarationRange

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
@NotNull
public TextRange getDeclarationRange(@NotNull final PsiElement container) {
  PsiClassInitializer initializer = (PsiClassInitializer)container;
  int startOffset = initializer.getModifierList().getTextRange().getStartOffset();
  int endOffset = initializer.getBody().getTextRange().getStartOffset();
  return new TextRange(startOffset, endOffset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ClassInitializerDeclarationRangeHandler.java


示例6: calculateResult

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public Result calculateResult(@NotNull Expression[] params, final ExpressionContext context) {
  PsiElement place = context.getPsiElementAtStartOffset();
  while(place != null){
    if (place instanceof PsiMethod){
      return new TextResult(((PsiMethod)place).getName());
    } else if (place instanceof PsiClassInitializer) {
      return ((PsiClassInitializer) place).hasModifierProperty(PsiModifier.STATIC) ?
             new TextResult(LangBundle.message("java.terms.static.initializer")) :
             new TextResult(LangBundle.message("java.terms.instance.initializer"));
    }
    place = place.getParent();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:MethodNameMacro.java


示例7: visitClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public void visitClassInitializer(PsiClassInitializer initializer) {
  if (initializer.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiClass aClass = initializer.getContainingClass();
  if (!TestUtils.isJUnitTestClass(aClass) && !TestUtils.isJUnit4TestClass(aClass, true)) {
    return;
  }
  if (MethodUtils.isTrivial(initializer)) {
    return;
  }
  registerClassInitializerError(initializer, Boolean.TRUE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:TestCaseWithConstructorInspection.java


示例8: visitClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public void visitClassInitializer(
  @NotNull PsiClassInitializer initializer) {
  super.visitClassInitializer(initializer);
  final PsiCodeBlock body = initializer.getBody();
  if (!codeBlockIsEmpty(body)) {
    return;
  }
  registerClassInitializerError(initializer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:EmptyInitializerInspection.java


示例9: calculateInitializerComplexity

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
private int calculateInitializerComplexity(PsiClass aClass) {
  final CyclomaticComplexityVisitor visitor = new CyclomaticComplexityVisitor();
  int complexity = 0;
  final PsiClassInitializer[] initializers = aClass.getInitializers();
  for (final PsiClassInitializer initializer : initializers) {
    visitor.reset();
    initializer.accept(visitor);
    complexity += visitor.getComplexity();
  }
  return complexity;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ClassComplexityInspection.java


示例10: getRootPsiElementWithStack

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
private static PsiElement getRootPsiElementWithStack(PsiClass psiClass, PsiElement psiElement, List<PsiElement> stack) {
    stack.add(psiElement);
    PsiElement parent = psiElement.getParent();
    if (parent == null) {
        return null;
    }
    try {
        if (parent instanceof PsiMethod) {
            if (PsiUtils.classHasMethod(psiClass, (PsiMethod) parent)) {
                return parent;
            }
        } else if (parent instanceof PsiClassInitializer) {
            if (PsiUtils.classHasClassInitializer(psiClass, (PsiClassInitializer) parent)) {
                return parent;
            }
        } else if (parent instanceof PsiField) {
            if (PsiUtils.classHasField(psiClass, (PsiField) parent)) {
                return parent;
            }
        } else if (parent instanceof PsiClass) {
            if (psiClass.equals(((PsiClass) parent).getContainingClass())) {
                return parent;
            }
        } else if (parent instanceof PsiAnonymousClass) {
            if (((PsiAnonymousClass) parent).getContainingClass().equals(psiClass)) {
                return parent;
            }
        }
    } catch (Exception ex) {
        stack.add(parent);
        String preparedStack = prepareStack(stack);
        throw new IllegalStateException("Cannot get root element. Stack: " + preparedStack);
    }

    return getRootPsiElementWithStack(psiClass, parent, stack);
}
 
开发者ID:Stefku,项目名称:intellij-reference-diagram,代码行数:37,代码来源:PsiUtils.java


示例11: classHasClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
private static boolean classHasClassInitializer(PsiClass psiClass, PsiClassInitializer other) {
    for (PsiClassInitializer classInitializer : psiClass.getInitializers()) {
        if (classInitializer.equals(other)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:Stefku,项目名称:intellij-reference-diagram,代码行数:9,代码来源:PsiUtils.java


示例12: getName

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
public static String getName(PsiClassInitializer psiClassInitializer) {
    if (psiClassInitializer.getModifierList().hasModifierProperty("static")) {
        return "[static init]";
    } else {
        return "[init]";
    }
}
 
开发者ID:Stefku,项目名称:intellij-reference-diagram,代码行数:8,代码来源:PsiUtils.java


示例13: visitClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public void visitClassInitializer(PsiClassInitializer initializer) {
  super.visitClassInitializer(initializer);
  if (initializer.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  registerClassInitializerError(initializer);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:ClassInitializerInspection.java


示例14: calculateInitializerComplexity

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
private int calculateInitializerComplexity(PsiClass aClass) {
  final ComplexityVisitor visitor = new ComplexityVisitor();
  int complexity = 0;
  final PsiClassInitializer[] initializers = aClass.getInitializers();
  for (final PsiClassInitializer initializer : initializers) {
    visitor.reset();
    initializer.accept(visitor);
    complexity += visitor.getComplexity();
  }
  return complexity;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:ClassComplexityInspection.java


示例15: visitClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public void visitClassInitializer(PsiClassInitializer initializer)
{
	if(initializer.hasModifierProperty(PsiModifier.STATIC))
	{
		return;
	}

	final PsiClass containingClass = ClassUtils.getContainingClass(initializer);
	if(containingClass == null)
	{
		return;
	}
	for(Condition<PsiElement> addin : JavaExtensionPoints.CANT_BE_STATIC_EP_NAME.getExtensions())
	{
		if(addin.value(initializer))
		{
			return;
		}
	}
	final PsiElement scope = containingClass.getScope();
	if(!(scope instanceof PsiJavaFile) && !containingClass.hasModifierProperty(PsiModifier.STATIC))
	{
		return;
	}

	final MethodReferenceVisitor visitor = new MethodReferenceVisitor(initializer);
	initializer.accept(visitor);
	if(!visitor.areReferencesStaticallyAccessible())
	{
		return;
	}

	registerClassInitializerError(initializer);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:36,代码来源:ClassInitializerMayBeStaticInspection.java


示例16: visitClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public void visitClassInitializer(PsiClassInitializer initializer) {
    mVisitor.report("PsiClassInitializer", initializer.getText(), initializer);
    super.visitElement(initializer);
}
 
开发者ID:cch-robo,项目名称:Android_Lint_SRP_Practice_Example,代码行数:6,代码来源:PsiClassStructureDetector.java


示例17: value

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public boolean value(PsiElement psiElement) {
    return psiElement instanceof PsiClassInitializer && CuppaUtils.isCuppaClass(psiElement);
}
 
开发者ID:cuppa-framework,项目名称:cuppa-intellij-plugin,代码行数:5,代码来源:CuppaCantBeStaticExtension.java


示例18: isMatch

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
public final boolean isMatch(RangeEntry entry)
{
    final boolean result = (entry.getEnd() instanceof PsiMethod           ||
                            entry.getEnd() instanceof PsiClassInitializer   ) &&
                           super.isMatch           (entry               )     &&
                           abstractAttr.isMatch    (entry.getModifiers())     &&
                           overriddenAttr.isMatch  (entry.getModifiers())     &&
                           overridingAttr.isMatch  (entry.getModifiers())     &&
                           implementedAttr.isMatch (entry.getModifiers())     &&
                           implementingAttr.isMatch(entry.getModifiers())     &&
                           staticInitAttr.isMatch  (entry.getModifiers())     &&
                           nativeAttr.isMatch      (entry.getModifiers())     &&
                           syncAttr.isMatch        (entry.getModifiers())     &&
                           returnTypeAttr.isMatch  (entry.getType     ())     &&
                           minParamsAttr.isMatch   (entry.getEnd      ())     &&
                           maxParamsAttr.isMatch   (entry.getEnd      ());
    if (result == false)
        return false;
    boolean typeResult = false;
    if (isConstructorMethodType()) {
        typeResult |= (entry.getModifiers() & ModifierConstants.CONSTRUCTOR) == ModifierConstants.CONSTRUCTOR;
    }
    if (isGetterSetterMethodType() &&
            entry.getEnd() instanceof PsiMethod)
    {
        /**
         * determine if the method is a getter or setter according to this rule's specific
         * definition.
         */
        boolean isGetter = MethodUtil.isGetter((PsiMethod) entry.getEnd(),
                getterSetterDefinition           );
        boolean isSetter = MethodUtil.isSetter((PsiMethod) entry.getEnd(),
                getterSetterDefinition           );
        typeResult |= isGetter | isSetter;
    }
    if (isCanonicalMethodType()) {
        typeResult |= (entry.getModifiers() & ModifierConstants.CANONICAL) == ModifierConstants.CANONICAL;
    }
    if (isOtherMethodType()) {
        typeResult |= (entry.getModifiers() & ModifierConstants.OTHER_METHOD) == ModifierConstants.OTHER_METHOD;
    }
    typeResult ^= invertMethodType;
    if (!constructorMethodType  &&
        !getterSetterMethodType &&
        !canonicalMethodType    &&
        !otherMethodType          )
    {
        typeResult = true; // true if no method type options are selected.
    }
    return result && typeResult;
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:52,代码来源:MethodAttributes.java


示例19: createPsi

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override
public PsiClassInitializer createPsi(@NotNull final PsiClassInitializerStub stub) {
  return getPsiFactory(stub).createClassInitializer(stub);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JavaClassInitializerElementType.java


示例20: visitClassInitializer

import com.intellij.psi.PsiClassInitializer; //导入依赖的package包/类
@Override public void visitClassInitializer(final PsiClassInitializer clazzInit) {
  result = true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:JavaDocMatchingStrategy.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MutableList类代码示例发布时间:2022-05-23
下一篇:
Java AuthInfo类代码示例发布时间: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