Java 类com.intellij.psi.PsiResolveHelper 实例源码

项目:intellij-ce-playground    文件:JavaCoreProjectEnvironment.java   
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
  super(parentDisposable, applicationEnvironment);

  myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
  myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
  myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
  myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
  myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
  myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
  myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());

  myPackageIndex = createCorePackageIndex();
  myProject.registerService(PackageIndex.class, myPackageIndex);

  myFileManager = createCoreFileManager();
  myProject.registerService(JavaFileManager.class, myFileManager);

  JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
  myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
}
项目:tools-idea    文件:JavaCoreProjectEnvironment.java   
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
  super(parentDisposable, applicationEnvironment);

  myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
  myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
  myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
  myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
  myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
  myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
  myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
  registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);

  myPackageIndex = createCorePackageIndex();
  myProject.registerService(PackageIndex.class, myPackageIndex);

  myFileManager = createCoreFileManager();
  myProject.registerService(JavaFileManager.class, myFileManager);

  JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
  registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
  myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
}
项目:consulo-java    文件:JavaCoreProjectEnvironment.java   
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
   super(parentDisposable, applicationEnvironment);

   myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
   myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
   myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
   myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
   myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
   myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
   registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);

/*   myPackageIndex = createCorePackageIndex();
   myProject.registerService(PackageIndex.class, myPackageIndex);     */

   myFileManager = createCoreFileManager();
   myProject.registerService(JavaFileManager.class, myFileManager);

   PsiPackageManager manager = new PsiPackageManagerImpl(getProject(), DirectoryIndex.getInstance(getProject()));

   myProject.registerService(PsiPackageManager.class, manager);

   JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, manager);
   registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
   myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
 }
项目:consulo-java    文件:MethodCallFixer.java   
@Nullable
private static Integer getUnambiguousParameterCount(PsiCallExpression call)
{
    int argCount = -1;
    for(CandidateInfo candidate : PsiResolveHelper.SERVICE.getInstance(call.getProject()).getReferencedMethodCandidates(call, false))
    {
        PsiElement element = candidate.getElement();
        if(!(element instanceof PsiMethod))
        {
            return null;
        }
        if(((PsiMethod) element).isVarArgs())
        {
            return null;
        }

        int count = ((PsiMethod) element).getParameterList().getParametersCount();
        if(argCount == -1)
        {
            argCount = count;
        }
        else if(argCount != count)
        {
            return null;
        }
    }
    return argCount;
}
项目:consulo-javaee    文件:JspJavaHighlightVisitorImpl.java   
public JspJavaHighlightVisitorImpl(@NotNull PsiResolveHelper resolveHelper)
{
    super(resolveHelper);
    myResolveHelper = resolveHelper;
}
项目:innerbuilder    文件:InnerBuilderCollector.java   
private static List<PsiFieldMember> collectFieldsInClass(final PsiElement element, final PsiClass accessObjectClass,
        final PsiClass clazz) {
    final List<PsiFieldMember> classFieldMembers = new ArrayList<PsiFieldMember>();
    final PsiResolveHelper helper = JavaPsiFacade.getInstance(clazz.getProject()).getResolveHelper();

    for (final PsiField field : clazz.getFields()) {

        // check access to the field from the builder container class (eg. private superclass fields)
        if ((helper.isAccessible(field, clazz, accessObjectClass) || hasSetter(clazz, field.getName()))
                && !PsiTreeUtil.isAncestor(field, element, false)) {

            // skip static fields
            if (field.hasModifierProperty(PsiModifier.STATIC)) {
                continue;
            }

            // skip any uppercase fields
            if (!hasLowerCaseChar(field.getName())) {
                continue;
            }

            // skip eventual logging fields
            final String fieldType = field.getType().getCanonicalText();
            if ("org.apache.log4j.Logger".equals(fieldType) || "org.apache.logging.log4j.Logger".equals(fieldType)
                    || "java.util.logging.Logger".equals(fieldType) || "org.slf4j.Logger".equals(fieldType)
                    || "ch.qos.logback.classic.Logger".equals(fieldType)
                    || "net.sf.microlog.core.Logger".equals(fieldType)
                    || "org.apache.commons.logging.Log".equals(fieldType)
                    || "org.pmw.tinylog.Logger".equals(fieldType) || "org.jboss.logging.Logger".equals(fieldType)
                    || "jodd.log.Logger".equals(fieldType)) {
                continue;
            }

            if (field.hasModifierProperty(PsiModifier.FINAL)) {
                if (field.getInitializer() != null) {
                    continue; // skip final fields that are assigned in the declaration
                }

                if (!accessObjectClass.isEquivalentTo(clazz)) {
                    continue; // skip final superclass fields
                }
            }

            final PsiClass containingClass = field.getContainingClass();
            if (containingClass != null) {
                classFieldMembers.add(buildFieldMember(field, containingClass, clazz));
            }
        }
    }

    return classFieldMembers;
}
项目:consulo-java    文件:ContextUtil.java   
@Nullable
public static PsiElement getContextElement(final StackFrameContext context, final SourcePosition position)
{
    if(LOG.isDebugEnabled())
    {
        final SourcePosition sourcePosition = getSourcePosition(context);
        LOG.assertTrue(Comparing.equal(sourcePosition, position));
    }

    return ReadAction.compute(() ->
    {
        final PsiElement element = getContextElement(position);

        if(element == null)
        {
            return null;
        }

        // further code is java specific, actually
        if(element.getLanguage().getAssociatedFileType() != DefaultCodeFragmentFactory.getInstance().getFileType())
        {
            return element;
        }

        final StackFrameProxyImpl frameProxy = (StackFrameProxyImpl) context.getFrameProxy();

        if(frameProxy == null)
        {
            return element;
        }

        try
        {
            List<LocalVariableProxyImpl> list = frameProxy.visibleVariables();

            PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(element.getProject()).getResolveHelper();
            StringBuilder buf = null;
            for(LocalVariableProxyImpl localVariable : list)
            {
                final String varName = localVariable.name();
                if(resolveHelper.resolveReferencedVariable(varName, element) == null)
                {
                    if(buf == null)
                    {
                        buf = new StringBuilder("{");
                    }
                    buf.append(localVariable.getVariable().typeName()).append(" ").append(varName).append(";");
                }
            }
            if(buf == null)
            {
                return element;
            }

            buf.append('}');

            final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(element.getProject()).getElementFactory();
            final PsiCodeBlock codeBlockFromText = elementFactory.createCodeBlockFromText(buf.toString(), element);

            final PsiStatement[] statements = codeBlockFromText.getStatements();
            for(PsiStatement statement : statements)
            {
                if(statement instanceof PsiDeclarationStatement)
                {
                    PsiDeclarationStatement declStatement = (PsiDeclarationStatement) statement;
                    PsiElement[] declaredElements = declStatement.getDeclaredElements();
                    for(PsiElement declaredElement : declaredElements)
                    {
                        declaredElement.putUserData(IS_JSP_IMPLICIT, Boolean.TRUE);
                    }
                }
            }
            return codeBlockFromText;
        }
        catch(IncorrectOperationException | EvaluateException ignored)
        {
            return element;
        }
    });
}