• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PsiScopesUtil类的典型用法和代码示例

java 1次浏览

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

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

示例1: processDeclarations

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                   @NotNull ResolveState state,
                                   PsiElement lastParent,
                                   @NotNull PsiElement place) {
  processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
  if (lastParent == null) return true;

  if (!PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place)) return false;

  final PsiParameter[] parameters = getParameterList().getParameters();
  for (PsiParameter parameter : parameters) {
    if (!processor.execute(parameter, state)) return false;
  }

  return true;
}
 

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

示例2: getReferencedMethodCandidates

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
@Override
public CandidateInfo[] getReferencedMethodCandidates(@NotNull PsiCallExpression expr,
                                                     boolean dummyImplicitConstructor,
                                                     final boolean checkVarargs) {
  PsiFile containingFile = expr.getContainingFile();
  final MethodCandidatesProcessor processor = new MethodCandidatesProcessor(expr, containingFile) {
    @Override
    protected boolean acceptVarargs() {
      return checkVarargs;
    }
  };
  try {
    PsiScopesUtil.setupAndRunProcessor(processor, expr, dummyImplicitConstructor);
  }
  catch (MethodProcessorSetupFailedException e) {
    return CandidateInfo.EMPTY_ARRAY;
  }
  return processor.getCandidates();
}
 

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

示例3: resolve

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] resolve(@NotNull PsiJavaReference ref, @NotNull PsiFile containingFile, boolean incompleteCode) {
  PsiJavaCodeReferenceElementImpl referenceElement = (PsiJavaCodeReferenceElementImpl)ref;
  int kind = referenceElement.getKind(containingFile);
  JavaResolveResult[] result = referenceElement.resolve(kind, containingFile);

  if (incompleteCode && result.length == 0 && kind != CLASS_FQ_NAME_KIND && kind != CLASS_FQ_OR_PACKAGE_NAME_KIND) {
    VariableResolverProcessor processor = new VariableResolverProcessor(referenceElement, containingFile);
    PsiScopesUtil.resolveAndWalk(processor, referenceElement, null, true);
    result = processor.getResult();
    if (result.length == 0 && kind == CLASS_NAME_KIND) {
      result = referenceElement.resolve(PACKAGE_NAME_KIND, containingFile);
    }
  }

  JavaResolveUtil.substituteResults(referenceElement, result);

  return result;
}
 

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

示例4: processDeclarations

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                   @NotNull ResolveState state,
                                   PsiElement lastParent,
                                   @NotNull PsiElement place) {
  processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
  if (lastParent == null || lastParent.getParent() != this)
    // Parent element should not see our vars
    return true;

  final PsiParameter catchParameter = getParameter();
  if (catchParameter != null) {
    return processor.execute(catchParameter, state);
  }

  return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
}
 

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

示例5: findPreviousVariable

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Nullable
private PsiVariable findPreviousVariable() {
  PsiElement scope = myVariable.getParent();
  while (scope != null) {
    if (scope instanceof PsiFile || scope instanceof PsiMethod || scope instanceof PsiClassInitializer) break;
    scope = scope.getParent();
  }
  if (scope == null) return null;

  PsiIdentifier nameIdentifier = myVariable.getNameIdentifier();
  if (nameIdentifier == null) {
    return null;
  }

  final VariablesNotProcessor processor = new VariablesNotProcessor(myVariable, false);
  PsiScopesUtil.treeWalkUp(processor, nameIdentifier, scope);
  return processor.size() > 0 ? processor.getResult(0) : null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:19,
代码来源:ReuseVariableDeclarationFix.java

示例6: getVariablesVisibleAt

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull public static PsiVariable[] getVariablesVisibleAt(@Nullable final PsiElement place, String prefix) {
  if (place == null) {
    return new PsiVariable[0];
  }

  final Set<String> usedNames = ContainerUtil.newHashSet();
  final List<PsiVariable> list = new ArrayList<PsiVariable>();
  VariablesProcessor varproc = new VariablesProcessor(prefix, true, list) {
    @Override
    public boolean execute(@NotNull PsiElement pe, @NotNull ResolveState state) {
      if (pe instanceof PsiVariable) {
        if (!usedNames.add(((PsiVariable)pe).getName())) {
          return false;
        }
        //exclude variables that are initialized in 'place'
        final PsiExpression initializer = ((PsiVariable)pe).getInitializer();
        if (initializer != null && PsiTreeUtil.isAncestor(initializer, place, false)) return true;
      }
      return pe instanceof PsiField && !PsiUtil.isAccessible((PsiField)pe, place, null) || super.execute(pe, state);
    }
  };
  PsiScopesUtil.treeWalkUp(varproc, place, null);
  return varproc.getResultsAsArray();
}
 

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

示例7: findVariablesOfType

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
static VariablesProcessor findVariablesOfType(final PsiDeclarationStatement declaration, final PsiType type) {
  VariablesProcessor proc = new VariablesProcessor(false) {
    @Override
    protected boolean check(PsiVariable var, ResolveState state) {
      for (PsiElement element : declaration.getDeclaredElements()) {
        if (element == var) return false;
      }
      return TypeConversionUtil.isAssignable(var.getType(), type);
    }
  };
  PsiElement scope = declaration;
  while (scope != null) {
    if (scope instanceof PsiFile || 
        scope instanceof PsiMethod || 
        scope instanceof PsiLambdaExpression ||
        scope instanceof PsiClassInitializer) break;
    scope = scope.getParent();
  }
  if (scope == null) return proc;
  PsiScopesUtil.treeWalkUp(proc, declaration, scope);
  return proc;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:23,
代码来源:ReassignVariableUtil.java

示例8: addAvailableMethodsOfType

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
private static void addAvailableMethodsOfType(final PsiClassType type, final PsiLiteralExpression context, final Collection<String> result) {
  PsiScopesUtil.treeWalkUp(new PsiScopeProcessor() {
    @Override
    public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
      if (element instanceof PsiMethod) {
        PsiMethod method = (PsiMethod)element;
        PsiType returnType = method.getReturnType();
        if (returnType != null && TypeConversionUtil.isAssignable(type, returnType)
            && method.getParameterList().getParametersCount() == 0) {
          result.add(method.getName() + "()");
        }
      }
      return true;
    }

    @Override
    public <T> T getHint(@NotNull Key<T> hintKey) {
      return null;
    }

    @Override
    public void handleEvent(@NotNull Event event, Object associated) {

    }
  }, context, null);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:27,
代码来源:JavaI18nUtil.java

示例9: EnvironmentProcessor

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
public EnvironmentProcessor(final @NotNull Converter converter, final @NotNull PsiElement place, final int lastEdit) {
  final Place where = new Place(converter.project,place);

  // Walk up the PSI tree, also processing import statements
  final EddyThread thread = EddyThread.getEddyThread();
  final Processor P = new Processor(thread,where);
  pushScope("tree walking");
  if (thread != null) thread.pushSoftInterrupts();
  try {
    PsiScopesUtil.treeWalkUp(P, place, place.getContainingFile());
  } finally {
    popScope();
    if (thread != null) thread.popSoftInterrupts();
  }
  // only do this if we got through the processor
  pushScope("fillLocalInfo");
  try {
    this.placeInfo = fillLocalInfo(P,where,converter,lastEdit);
  } finally { popScope(); }
}
 

开发者ID:eddysystems,
项目名称:eddy,
代码行数:21,
代码来源:EnvironmentProcessor.java

示例10: resolve

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
@Override
public JavaResolveResult[] resolve(@NotNull PsiJavaReference ref, boolean incompleteCode) {
  PsiJavaCodeReferenceElementImpl referenceElement = (PsiJavaCodeReferenceElementImpl)ref;
  int kind = referenceElement.getKind();
  PsiFile containingFile = referenceElement.getContainingFile();
  JavaResolveResult[] result = referenceElement.resolve(kind, containingFile);

  if (incompleteCode && result.length == 0 && kind != CLASS_FQ_NAME_KIND && kind != CLASS_FQ_OR_PACKAGE_NAME_KIND) {
    VariableResolverProcessor processor = new VariableResolverProcessor(referenceElement, containingFile);
    PsiScopesUtil.resolveAndWalk(processor, referenceElement, null, incompleteCode);
    result = processor.getResult();
    if (result.length == 0 && kind == CLASS_NAME_KIND) {
      result = referenceElement.resolve(PACKAGE_NAME_KIND, containingFile);
    }
  }

  JavaResolveUtil.substituteResults((PsiJavaCodeReferenceElement)ref, result);

  return result;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:22,
代码来源:PsiJavaCodeReferenceElementImpl.java

示例11: getVariablesVisibleAt

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull public static PsiVariable[] getVariablesVisibleAt(@Nullable final PsiElement place, String prefix) {
  if (place == null) {
    return new PsiVariable[0];
  }

  final Set<String> usedNames = ContainerUtil.newHashSet();
  final List<PsiVariable> list = new ArrayList<PsiVariable>();
  VariablesProcessor varproc = new VariablesProcessor(prefix, true, list) {
    @Override
    public boolean execute(@NotNull PsiElement pe, ResolveState state) {
      if (pe instanceof PsiVariable) {
        if (!usedNames.add(((PsiVariable)pe).getName())) {
          return false;
        }
        //exclude variables that are initialized in 'place'
        final PsiExpression initializer = ((PsiVariable)pe).getInitializer();
        if (initializer != null && PsiTreeUtil.isAncestor(initializer, place, false)) return true;
      }
      return pe instanceof PsiField && !PsiUtil.isAccessible((PsiField)pe, place, null) || super.execute(pe, state);
    }
  };
  PsiScopesUtil.treeWalkUp(varproc, place, null);
  return varproc.getResultsAsArray();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:25,
代码来源:MacroUtil.java

示例12: findVariablesOfType

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
static VariablesProcessor findVariablesOfType(final PsiDeclarationStatement declaration, final PsiType type) {
  VariablesProcessor proc = new VariablesProcessor(false) {
    @Override
    protected boolean check(PsiVariable var, ResolveState state) {
      for (PsiElement element : declaration.getDeclaredElements()) {
        if (element == var) return false;
      }
      return TypeConversionUtil.isAssignable(var.getType(), type);
    }
  };
  PsiElement scope = declaration;
  while (scope != null) {
    if (scope instanceof PsiFile || scope instanceof PsiMethod || scope instanceof PsiClassInitializer) break;
    scope = scope.getParent();
  }
  if (scope == null) return proc;
  PsiScopesUtil.treeWalkUp(proc, declaration, scope);
  return proc;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:20,
代码来源:ReassignVariableUtil.java

示例13: addAvailableMethodsOfType

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
private static void addAvailableMethodsOfType(final PsiClassType type, final PsiLiteralExpression context, final Collection<String> result) {
  PsiScopesUtil.treeWalkUp(new PsiScopeProcessor() {
    @Override
    public boolean execute(@NotNull PsiElement element, ResolveState state) {
      if (element instanceof PsiMethod) {
        PsiMethod method = (PsiMethod)element;
        PsiType returnType = method.getReturnType();
        if (returnType != null && TypeConversionUtil.isAssignable(type, returnType)
            && method.getParameterList().getParametersCount() == 0) {
          result.add(method.getName() + "()");
        }
      }
      return true;
    }

    @Override
    public <T> T getHint(@NotNull Key<T> hintKey) {
      return null;
    }

    @Override
    public void handleEvent(Event event, Object associated) {

    }
  }, context, null);
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:27,
代码来源:JavaI18nUtil.java

示例14: processDeclarations

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place)
{
	processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
	if(lastParent == null)
	{
		return true;
	}

	if(!PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place))
	{
		return false;
	}

	final PsiParameter[] parameters = getParameterList().getParameters();
	for(PsiParameter parameter : parameters)
	{
		if(!processor.execute(parameter, state))
		{
			return false;
		}
	}

	return true;
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:26,
代码来源:ClsMethodImpl.java

示例15: getReferencedMethodCandidates

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
@Override
public CandidateInfo[] getReferencedMethodCandidates(@NotNull PsiCallExpression expr, boolean dummyImplicitConstructor, final boolean checkVarargs)
{
	PsiFile containingFile = expr.getContainingFile();
	final MethodCandidatesProcessor processor = new MethodCandidatesProcessor(expr, containingFile)
	{
		@Override
		protected boolean acceptVarargs()
		{
			return checkVarargs;
		}
	};
	try
	{
		PsiScopesUtil.setupAndRunProcessor(processor, expr, dummyImplicitConstructor);
	}
	catch(MethodProcessorSetupFailedException e)
	{
		return CandidateInfo.EMPTY_ARRAY;
	}
	return processor.getCandidates();
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:24,
代码来源:PsiResolveHelperImpl.java

示例16: resolve

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
@Override
public ResolveResult[] resolve(@NotNull PsiJavaReference ref, @NotNull PsiFile containingFile, boolean incompleteCode)
{
	PsiJavaCodeReferenceElementImpl referenceElement = (PsiJavaCodeReferenceElementImpl) ref;
	int kind = referenceElement.getKind(containingFile);
	JavaResolveResult[] result = referenceElement.resolve(kind, containingFile);

	if(incompleteCode && result.length == 0 && kind != CLASS_FQ_NAME_KIND && kind != CLASS_FQ_OR_PACKAGE_NAME_KIND)
	{
		VariableResolverProcessor processor = new VariableResolverProcessor(referenceElement, containingFile);
		PsiScopesUtil.resolveAndWalk(processor, referenceElement, null, true);
		result = processor.getResult();
		if(result.length == 0 && kind == CLASS_NAME_KIND)
		{
			result = referenceElement.resolve(PACKAGE_NAME_KIND, containingFile);
		}
	}

	JavaResolveUtil.substituteResults(referenceElement, result);

	return result;
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:24,
代码来源:PsiJavaCodeReferenceElementImpl.java

示例17: getCandidates

点赞 3

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
private static CandidateInfo[] getCandidates(PsiCallExpression call)
{
	final MethodCandidatesProcessor processor = new MethodResolverProcessor(call, call.getContainingFile(), new PsiConflictResolver[0])
	{
		@Override
		protected boolean acceptVarargs()
		{
			return false;
		}
	};

	try
	{
		PsiScopesUtil.setupAndRunProcessor(processor, call, true);
	}
	catch(MethodProcessorSetupFailedException e)
	{
		return CandidateInfo.EMPTY_ARRAY;
	}
	final List<CandidateInfo> results = processor.getResults();
	return results.toArray(new CandidateInfo[results.size()]);
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:23,
代码来源:MethodParameterInfoHandler.java

示例18: resolveVariable

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
public static PsiVariable resolveVariable(@NotNull PsiJavaCodeReferenceElement ref,
                                          boolean[] problemWithAccess,
                                          boolean[] problemWithStatic
) {

  /*
  long time1 = System.currentTimeMillis();
  */

  final VariableResolverProcessor processor = new VariableResolverProcessor(ref, ref.getContainingFile());
  PsiScopesUtil.resolveAndWalk(processor, ref, null);

  /*
  long time2 = System.currentTimeMillis();
  Statistics.resolveVariableTime += (time2 - time1);
  Statistics.resolveVariableCount++;
  */
  final JavaResolveResult[] result = processor.getResult();
  if (result.length != 1) return null;
  final PsiVariable refVar = (PsiVariable)result[0].getElement();

  if (problemWithAccess != null) {
    problemWithAccess[0] = !result[0].isAccessible();
  }
  if (problemWithStatic != null) {
    problemWithStatic[0] = !result[0].isStaticsScopeCorrect();
  }


  return refVar;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:32,
代码来源:ResolveVariableUtil.java

示例19: getResults

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
protected JavaResolveResult[] getResults(@NotNull PsiCallExpression contextCall, final int exprIdx) throws MethodProcessorSetupFailedException {
  PsiFile containingFile = contextCall.getContainingFile();
  final MethodCandidatesProcessor processor = new MethodCandidatesProcessor(contextCall, containingFile);
  //can't call resolve() since it obtains full substitution, that may result in infinite recursion
  PsiScopesUtil.setupAndRunProcessor(processor, contextCall, false);
  return processor.getResult();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:9,
代码来源:ProcessCandidateParameterTypeInferencePolicy.java

示例20: resolveToMethod

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
private JavaResolveResult[] resolveToMethod(@NotNull PsiFile containingFile) {
  final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)getParent();
  final MethodResolverProcessor processor = new MethodResolverProcessor(methodCall, containingFile);
  try {
    PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
  }
  catch (MethodProcessorSetupFailedException e) {
    return JavaResolveResult.EMPTY_ARRAY;
  }
  return processor.getResult();
}
 

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

示例21: resolveToClass

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
private JavaResolveResult[] resolveToClass(@NotNull PsiElement classNameElement, @NotNull PsiFile containingFile) {
  final String className = classNameElement.getText();

  final ClassResolverProcessor processor = new ClassResolverProcessor(className, this, containingFile);
  PsiScopesUtil.resolveAndWalk(processor, this, null);
  return processor.getResult();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:9,
代码来源:PsiReferenceExpressionImpl.java

示例22: processDeclarations

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
  processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
  if (lastParent == null || lastParent.getParent() != this)
    // Parent element should not see our vars
    return true;

  return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:PsiForStatementImpl.java

示例23: processDeclarations

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
  processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
  if (lastParent == null) {
    // Parent element should not see our vars
    return true;
  }
  Couple<Set<String>> pair = buildMaps();
  boolean conflict = pair == null;
  final Set<String> classesSet = conflict ? null : pair.getFirst();
  final Set<String> variablesSet = conflict ? null : pair.getSecond();
  final NameHint hint = processor.getHint(NameHint.KEY);
  if (hint != null && !conflict) {
    final ElementClassHint elementClassHint = processor.getHint(ElementClassHint.KEY);
    final String name = hint.getName(state);
    if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) && classesSet.contains(name)) {
      return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
    }
    if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) && variablesSet.contains(name)) {
      return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
    }
  }
  else {
    return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
  }
  return true;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:28,
代码来源:PsiCodeBlockImpl.java

示例24: getArtificialOutputVariable

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Nullable
private PsiVariable getArtificialOutputVariable() {
  if (myOutputVariables.length == 0 && myExitStatements.isEmpty()) {
    if (myCanBeChainedConstructor) {
      final Set<PsiField> fields = new HashSet<PsiField>();
      for (PsiElement element : myElements) {
        element.accept(new JavaRecursiveElementWalkingVisitor() {
          @Override
          public void visitReferenceExpression(PsiReferenceExpression expression) {
            super.visitReferenceExpression(expression);
            final PsiElement resolve = expression.resolve();
            if (resolve instanceof PsiField && ((PsiField)resolve).hasModifierProperty(PsiModifier.FINAL) &&
                PsiUtil.isAccessedForWriting(expression)) {
              fields.add((PsiField)resolve);
            }
          }
        });
      }
      if (!fields.isEmpty()) {
        return fields.size() == 1 ? fields.iterator().next() : null;
      }
    }
    final VariablesProcessor processor = new VariablesProcessor(true) {
      @Override
      protected boolean check(PsiVariable var, ResolveState state) {
        return isDeclaredInside(var);
      }
    };
    PsiScopesUtil.treeWalkUp(processor, myElements[myElements.length - 1], myCodeFragmentMember);
    if (processor.size() == 1) {
      return processor.getResult(0);
    }
  }
  return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:36,
代码来源:ExtractMethodProcessor.java

示例25: createOccurrenceManager

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
private static ExpressionOccurrenceManager createOccurrenceManager(PsiExpression expr, PsiElement tempContainer) {
  boolean skipForStatement = true;
  final PsiForStatement forStatement = PsiTreeUtil.getParentOfType(expr, PsiForStatement.class);
  if (forStatement != null) {
    final VariablesProcessor variablesProcessor = new VariablesProcessor(false) {
      @Override
      protected boolean check(PsiVariable var, ResolveState state) {
        return PsiTreeUtil.isAncestor(forStatement.getInitialization(), var, true);
      }
    };
    PsiScopesUtil.treeWalkUp(variablesProcessor, expr, null);
    skipForStatement = variablesProcessor.size() == 0;
  }

  PsiElement containerParent = tempContainer;
  PsiElement lastScope = tempContainer;
  while (true) {
    if (containerParent instanceof PsiFile) break;
    if (containerParent instanceof PsiMethod) break;
    if (containerParent instanceof PsiLambdaExpression) break;
    if (!skipForStatement && containerParent instanceof PsiForStatement) break;
    containerParent = containerParent.getParent();
    if (containerParent instanceof PsiCodeBlock) {
      lastScope = containerParent;
    }
  }

  return new ExpressionOccurrenceManager(expr, lastScope, NotInSuperCallOccurrenceFilter.INSTANCE);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:30,
代码来源:IntroduceVariableBase.java

示例26: EnvironmentProcessorTest

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
public EnvironmentProcessorTest(@NotNull Project project, PsiElement place, boolean honorPrivate) {
  this.project = project;
  this.place = place;
  this.honorPrivate = honorPrivate;

  // this is set to null when we go to java.lang
  this.currentFileContext = place;

  logger.setLevel(Level.DEBUG);

  PsiScopesUtil.treeWalkUp(this, place, this.place.getContainingFile());

  // TODO: find import statements and add those to scope
}
 

开发者ID:eddysystems,
项目名称:eddy,
代码行数:15,
代码来源:EnvironmentProcessorTest.java

示例27: getReferencedMethodCandidates

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
@NotNull
public CandidateInfo[] getReferencedMethodCandidates(@NotNull PsiCallExpression expr, boolean dummyImplicitConstructor) {
  PsiFile containingFile = expr.getContainingFile();
  final MethodCandidatesProcessor processor = new MethodCandidatesProcessor(expr, containingFile);
  try {
    PsiScopesUtil.setupAndRunProcessor(processor, expr, dummyImplicitConstructor);
  }
  catch (MethodProcessorSetupFailedException e) {
    return CandidateInfo.EMPTY_ARRAY;
  }
  return processor.getCandidates();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:14,
代码来源:PsiResolveHelperImpl.java

示例28: resolveToClass

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@NotNull
private JavaResolveResult[] resolveToClass(@NotNull PsiElement classNameElement, PsiFile containingFile) {
  final String className = classNameElement.getText();

  final ClassResolverProcessor processor = new ClassResolverProcessor(className, this, containingFile);
  PsiScopesUtil.resolveAndWalk(processor, this, null);
  return processor.getResult();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:9,
代码来源:PsiReferenceExpressionImpl.java

示例29: processDeclarations

点赞 2

import com.intellij.psi.scope.util.PsiScopesUtil; //导入依赖的package包/类
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
  processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, this);
  if (lastParent == null) {
    // Parent element should not see our vars
    return true;
  }
  Pair<Set<String>, Set<String>> pair = buildMaps();
  boolean conflict = pair == null;
  final Set<String> classesSet = conflict ? null : pair.getFirst();
  final Set<String> variablesSet = conflict ? null : pair.getSecond();
  final NameHint hint = processor.getHint(NameHint.KEY);
  if (hint != null && !conflict) {
    final ElementClassHint elementClassHint = processor.getHint(ElementClassHint.KEY);
    final String name = hint.getName(state);
    if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) && classesSet.contains(name)) {
      return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
    }
    if ((elementClassHint == null || elementClassHint.shouldProcess(ElementClassHint.DeclarationKind.VARIABLE)) && variablesSet.contains(name)) {
      return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
    }
  }
  else {
    return PsiScopesUtil.walkChildrenScopes(this, processor, state, lastParent, place);
  }
  return true;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:28,
代码来源:PsiCodeBlockImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)