Java Code Examples for com.intellij.psi.scope.PsiScopeProcessor#execute()

The following examples show how to use com.intellij.psi.scope.PsiScopeProcessor#execute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSharpForeachStatementImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent,
		@Nonnull PsiElement place)
{
	if(lastParent == null || !PsiTreeUtil.isAncestor(this, lastParent, false))
	{
		return true;
	}
	CSharpLocalVariable variable = getVariable();
	if(variable != null)
	{
		if(!processor.execute(variable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 2
Source File: CSharpFixedStatementImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent,
		@Nonnull PsiElement place)
{
	if(lastParent == null || !PsiTreeUtil.isAncestor(this, lastParent, false))
	{
		return true;
	}

	for(DotNetVariable dotNetVariable : getVariables())
	{
		if(!processor.execute(dotNetVariable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 3
Source File: CSharpResolveUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
public static boolean walkForLabel(@Nonnull final PsiScopeProcessor processor, @Nonnull final PsiElement entrance, @Nonnull ResolveState state)
{
	PsiElement[] children = entrance.getChildren();
	for(PsiElement child : children)
	{
		if(ExecuteTargetUtil.isMyElement(processor, child))
		{
			if(!processor.execute(child, state))
			{
				return false;
			}
		}

		if(!walkForLabel(processor, child, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 4
Source File: CSharpForStatementImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent, @Nonnull PsiElement
		place)
{
	if(lastParent == null || !PsiTreeUtil.isAncestor(this, lastParent, false))
	{
		return true;
	}

	for(DotNetVariable dotNetVariable : getVariables())
	{
		if(!processor.execute(dotNetVariable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 5
Source File: CSharpLinqJoinClauseImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor,
		@Nonnull ResolveState state,
		PsiElement lastParent,
		@Nonnull PsiElement place)
{
	CSharpLinqVariableImpl variable = getVariable();
	if(variable != null)
	{
		if(!processor.execute(variable, state))
		{
			return false;
		}
	}

	CSharpLinqIntoClauseImpl intoClause = getIntoClause();
	if(intoClause != null)
	{
		if(!intoClause.processDeclarations(processor, state, lastParent, place))
		{
			return false;
		}
	}
	return true;
}
 
Example 6
Source File: CSharpUsingStatementImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent,
		@Nonnull PsiElement place)
{
	if(lastParent == null || !PsiTreeUtil.isAncestor(this, lastParent, false))
	{
		return true;
	}

	DotNetVariable variable = getVariable();
	if(variable != null)
	{
		if(!processor.execute(variable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 7
Source File: CSharpIsExpressionImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent, @Nonnull PsiElement place)
{
	CSharpIsVariableImpl variable = getVariable();
	if(variable != null && !processor.execute(variable, state))
	{
		return false;
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example 8
Source File: CSharpLambdaExpressionImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent, @Nonnull PsiElement place)
{
	for(CSharpLambdaParameter parameter : getParameters())
	{
		if(!processor.execute(parameter, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 9
Source File: CSharpLocalVariableDeclarationStatementImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent, @Nonnull PsiElement
		place)
{
	for(CSharpLocalVariable variable : getVariables())
	{
		if(!processor.execute(variable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 10
Source File: CSharpXAccessorImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor,
		@Nonnull ResolveState state,
		PsiElement lastParent,
		@Nonnull PsiElement place)
{
	if(ExecuteTargetUtil.canProcess(processor, ExecuteTarget.LOCAL_VARIABLE_OR_PARAMETER_OR_LOCAL_METHOD))
	{
		PsiElement parent = getParent();
		if(!parent.processDeclarations(processor, state, lastParent, place))
		{
			return false;
		}

		Kind accessorKind = getAccessorKind();
		if(accessorKind == Kind.SET || accessorKind == Kind.ADD || accessorKind == Kind.REMOVE)
		{
			Pair<DotNetTypeRef, DotNetQualifiedElement> pair = getTypeRefOfParent();
			if(pair.getSecond() == null)
			{
				return true;
			}

			CSharpLightLocalVariableBuilder builder = new CSharpLightLocalVariableBuilder(pair.getSecond()).withName(VALUE).withParent(this)
					.withTypeRef(pair.getFirst());

			builder.putUserData(CSharpResolveUtil.ACCESSOR_VALUE_VARIABLE_OWNER, pair.getSecond());

			if(!processor.execute(builder, state))
			{
				return false;
			}
		}
	}
	return true;
}
 
Example 11
Source File: CSharpElementGroupImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent, @Nonnull PsiElement place)
{
	for(T element : myElements)
	{
		ProgressManager.checkCanceled();

		if(!processor.execute(element, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 12
Source File: CSharpLikeMethodDeclarationImplUtil.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public static boolean processDeclarations(@Nonnull DotNetLikeMethodDeclaration methodDeclaration,
										  @Nonnull PsiScopeProcessor processor,
										  @Nonnull ResolveState state,
										  PsiElement lastParent,
										  @Nonnull PsiElement place)
{
	if(ExecuteTargetUtil.canProcess(processor, ExecuteTarget.GENERIC_PARAMETER))
	{
		for(DotNetGenericParameter dotNetGenericParameter : methodDeclaration.getGenericParameters())
		{
			if(!processor.execute(dotNetGenericParameter, state))
			{
				return false;
			}
		}
	}

	if(ExecuteTargetUtil.canProcess(processor, ExecuteTarget.LOCAL_VARIABLE_OR_PARAMETER_OR_LOCAL_METHOD))
	{
		for(DotNetParameter parameter : methodDeclaration.getParameters())
		{
			if(!processor.execute(parameter, state))
			{
				return false;
			}
		}
	}

	return true;
}
 
Example 13
Source File: BashWordImpl.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    if (!processor.execute(this, state)) {
        return false;
    }

    if (isSingleChildParent() && isWrapped()) {
        return true;
    }

    return BashElementSharedImpl.walkDefinitionScope(this, processor, state, lastParent, place);
}
 
Example 14
Source File: BashStringImpl.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    if (!processor.execute(this, state)) {
        return false;
    }

    boolean walkOn = isStatic() || BashElementSharedImpl.walkDefinitionScope(this, processor, state, lastParent, place);

    /*if (walkOn && isValidHost()) {
        walkOn = InjectionUtils.walkInjection(this, processor, state, lastParent, place, true);
    } */

    return walkOn;
}
 
Example 15
Source File: HaxePsiCompositeElementImpl.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                   @NotNull ResolveState state,
                                   PsiElement lastParent,
                                   @NotNull PsiElement place) {
  for (PsiElement element : getDeclarationElementToProcess(lastParent)) {
    if (!processor.execute(element, state)) {
      return false;
    }
  }
  return super.processDeclarations(processor, state, lastParent, place);
}
 
Example 16
Source File: BashFunctionDefImpl.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    if (lastParent != null && lastParent.equals(functionBody())) {
        return processor.execute(this, state);
    }

    return BashResolveUtil.processContainerDeclarations(this, processor, state, lastParent, place);
}
 
Example 17
Source File: BashBaseStubElementImpl.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    if (!processor.execute(this, state)) {
        return false;
    }

    return BashElementSharedImpl.walkDefinitionScope(this, processor, state, lastParent, place);
}
 
Example 18
Source File: CSharpResolveUtil.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
public static boolean walkUsing(@Nonnull final PsiScopeProcessor processor, @Nonnull final PsiElement entrance, @Nullable PsiElement maxScope, @Nonnull final ResolveState state)
{
	if(!entrance.isValid())
	{
		LOG.error(new PsiInvalidElementAccessException(entrance));
	}

	DotNetNamespaceAsElement root = DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace("", entrance.getResolveScope());

	// skip null - indexing
	if(root == null)
	{
		return true;
	}

	if(!processor.execute(root, state))
	{
		return false;
	}

	// we cant go to use list
	if(PsiTreeUtil.getParentOfType(entrance, CSharpUsingListChild.class) != null)
	{
		return true;
	}

	CSharpResolveSelector selector = state.get(SELECTOR);
	if(selector instanceof MemberByNameSelector)
	{
		((MemberByNameSelector) selector).putUserData(BaseDotNetNamespaceAsElement.FILTER, DotNetNamespaceAsElement.ChildrenFilter.ONLY_ELEMENTS);
	}

	PsiElement prevParent = entrance;
	PsiElement scope = entrance;

	maxScope = validateMaxScope(entrance, maxScope);

	while(scope != null)
	{
		ProgressManager.checkCanceled();

		if(scope instanceof CSharpUsingListOwner)
		{
			CSharpUsingListChild[] usingStatements = ((CSharpUsingListOwner) scope).getUsingStatements();
			for(CSharpUsingListChild usingStatement : usingStatements)
			{
				ProgressManager.checkCanceled();

				if(!processor.execute(usingStatement, state))
				{
					return false;
				}
			}
		}

		if(scope == maxScope)
		{
			break;
		}

		prevParent = scope;
		scope = prevParent.getContext();
		if(scope != null && scope != prevParent.getParent() && !scope.isValid())
		{
			break;
		}
	}

	return true;
}
 
Example 19
Source File: CSharpResolveUtil.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
public static boolean walkChildren(@Nonnull final PsiScopeProcessor processor, @Nonnull final PsiElement entrance, boolean walkParent, boolean walkDeep, @Nonnull ResolveState state)
{
	if(walkDeep)
	{
		state = state.put(WALK_DEEP, Boolean.TRUE);
	}

	ProgressIndicatorProvider.checkCanceled();
	GlobalSearchScope resolveScope = entrance.getResolveScope();
	if(entrance instanceof CSharpTypeDeclaration)
	{
		if(!processor.execute(entrance, state))
		{
			return false;
		}

		if(walkParent)
		{
			PsiElement parent = entrance.getContext();
			if(parent == null)
			{
				return true;
			}

			if(!walkChildren(processor, parent, walkParent, walkDeep, state))
			{
				return false;
			}
		}
	}
	else if(entrance instanceof CSharpTypeDefStatement)
	{
		DotNetTypeRef dotNetTypeRef = ((CSharpTypeDefStatement) entrance).toTypeRef();

		DotNetTypeResolveResult typeResolveResult = dotNetTypeRef.resolve();

		PsiElement element = typeResolveResult.getElement();
		if(element == null)
		{
			return true;
		}

		CSharpResolveSelector selector = state.get(SELECTOR);
		ResolveState newState = ResolveState.initial().put(SELECTOR, selector).put(EXTRACTOR, typeResolveResult.getGenericExtractor());
		return walkChildren(processor, element, walkParent, walkDeep, newState);
	}
	else if(entrance instanceof DotNetGenericParameter)
	{
		if(!processor.execute(entrance, state))
		{
			return false;
		}
	}
	else if(entrance instanceof DotNetNamespaceAsElement)
	{
		state = state.put(BaseDotNetNamespaceAsElement.RESOLVE_SCOPE, resolveScope);
		state = state.put(BaseDotNetNamespaceAsElement.FILTER, DotNetNamespaceAsElement.ChildrenFilter.NONE);

		if(!processor.execute(entrance, state))
		{
			return false;
		}

		String parentQName = ((DotNetNamespaceAsElement) entrance).getPresentableParentQName();
		// dont go to root namespace
		if(StringUtil.isEmpty(parentQName))
		{
			return true;
		}

		if(walkParent)
		{
			DotNetNamespaceAsElement parentNamespace = DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace(parentQName, resolveScope);
			if(parentNamespace != null && !walkChildren(processor, parentNamespace, walkParent, walkDeep, state))
			{
				return false;
			}
		}
	}
	else if(entrance instanceof DotNetNamespaceDeclaration)
	{
		String presentableQName = ((DotNetNamespaceDeclaration) entrance).getPresentableQName();
		if(presentableQName == null)
		{
			return true;
		}

		state = state.put(BaseDotNetNamespaceAsElement.RESOLVE_SCOPE, resolveScope);
		state = state.put(BaseDotNetNamespaceAsElement.FILTER, DotNetNamespaceAsElement.ChildrenFilter.NONE);

		DotNetNamespaceAsElement namespace = DotNetPsiSearcher.getInstance(entrance.getProject()).findNamespace(presentableQName, resolveScope);
		if(namespace != null && !walkChildren(processor, namespace, walkParent, walkDeep, state))
		{
			return false;
		}
	}
	return true;
}
 
Example 20
Source File: AbstractHeredocMarker.java    From BashSupport with Apache License 2.0 4 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
    return processor.execute(this, state);
}