com.intellij.psi.scope.PsiScopeProcessor Java Examples

The following examples show how to use com.intellij.psi.scope.PsiScopeProcessor. 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: CSharpCatchStatementImpl.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 && variable.getNameIdentifier() != null)   // variable can be without name
	{
		if(!processor.execute(variable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example #2
Source File: BashPsiUtils.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
/**
 * This tree walkup method does continue even if a valid definition has been found on an more-inner level.
 * Bash is different in regard to the definitions, the most outer definitions count, not the most inner / the first one found.
 *
 * @param processor
 * @param entrance
 * @param maxScope
 * @param state
 * @return
 */
public static boolean varResolveTreeWalkUp(@NotNull final PsiScopeProcessor processor,
                                           @NotNull final BashVar entrance,
                                           @Nullable final PsiElement maxScope,
                                           @NotNull final ResolveState state) {
    PsiElement prevParent = entrance;
    PsiElement scope = entrance;

    boolean hasResult = false;

    while (scope != null) {
        hasResult |= !scope.processDeclarations(processor, state, prevParent, entrance);

        if (scope == maxScope) {
            break;
        }

        prevParent = scope;
        scope = PsiTreeUtil.getStubOrPsiParent(prevParent);
    }

    return !hasResult;
}
 
Example #3
Source File: CSharpBinaryExpressionImpl.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)
{
	DotNetExpression leftExpression = getLeftExpression();
	if(leftExpression != null && !leftExpression.processDeclarations(processor, state, lastParent, place))
	{
		return false;
	}

	DotNetExpression rightExpression = getRightExpression();
	if(rightExpression != null && !rightExpression.processDeclarations(processor, state, lastParent, place))
	{
		return false;
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
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: CSharpLinqIntoClauseImpl.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;
		}
	}
	return true;
}
 
Example #7
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 #8
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 #9
Source File: CSharpLinqExpressionImpl.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(PsiElement psiElement : getChildren())
	{
		if(!psiElement.processDeclarations(processor, state, lastParent, place))
		{
			return false;
		}
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example #10
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 #11
Source File: GLSLStructDefinition.java    From glsl4idea with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
    if (!processor.execute(this, state))
        return false;

    if (lastParent == null) {
        // Do not show declarations of parameters to outside scopes
        return true;
    }

    for (GLSLDeclarator declarator : getDeclarators()) {
        if (declarator == lastParent)
            continue;
        if (!processor.execute(declarator, state))
            return false;
    }
    return true;
}
 
Example #12
Source File: CSharpCasePatternStatementImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Override
@RequiredReadAction
public boolean processDeclarations(@Nonnull PsiScopeProcessor processor, @Nonnull ResolveState state, PsiElement lastParent, @Nonnull PsiElement place)
{
	DotNetVariable variable = getVariable();
	if(!processor.execute(variable, state))
	{
		return false;
	}

	DotNetExpression whenExpression = getWhenExpression();
	if(whenExpression != null && !whenExpression.processDeclarations(processor, state, lastParent, place))
	{
		return false;
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example #13
Source File: GLSLFunctionDefinitionImpl.java    From glsl4idea with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
    if (lastParent == null) {
        // Do not show declarations of parameters to outside scopes
        return true;
    }

    for (GLSLParameterDeclaration parameter : getParameters()) {
        if (parameter == lastParent) // TODO(jp): sloppy, parameter is probably not direct child, so this will fail
            continue;

        if (!parameter.processDeclarations(processor, state, lastParent, place)) return false;
    }

    return true;
}
 
Example #14
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 #15
Source File: ExecuteTargetUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
public static boolean isMyElement(@Nonnull PsiScopeProcessor psiScopeProcessor, @Nonnull PsiElement element)
{
	EnumSet<ExecuteTarget> hint = psiScopeProcessor.getHint(EXECUTE_TARGETS);
	if(hint == null)
	{
		return false;
	}
	for(ExecuteTarget executeTarget : hint)
	{
		if(executeTarget.isMyElement(element))
		{
			return true;
		}
	}
	return false;
}
 
Example #16
Source File: ExecuteTargetUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
public static boolean canProcess(@Nonnull PsiScopeProcessor psiScopeProcessor, @Nonnull ExecuteTarget... executeTargets)
{
	EnumSet<ExecuteTarget> hint = psiScopeProcessor.getHint(EXECUTE_TARGETS);
	if(hint == null)
	{
		return false;
	}

	for(ExecuteTarget executeTarget : executeTargets)
	{
		if(hint.contains(executeTarget))
		{
			return true;
		}
	}
	return false;
}
 
Example #17
Source File: OverrideUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Collection<PsiElement> filterOverrideElements(@Nonnull PsiScopeProcessor processor,
		@Nonnull PsiElement scopeElement,
		@Nonnull Collection<PsiElement> psiElements,
		@Nonnull OverrideProcessor overrideProcessor)
{
	if(psiElements.size() == 0)
	{
		return psiElements;
	}

	if(!ExecuteTargetUtil.canProcess(processor, ExecuteTarget.ELEMENT_GROUP, ExecuteTarget.EVENT, ExecuteTarget.PROPERTY))
	{
		return CSharpResolveUtil.mergeGroupsToIterable(psiElements);
	}

	List<PsiElement> elements = CSharpResolveUtil.mergeGroupsToIterable(psiElements);

	return filterOverrideElements(scopeElement, elements, overrideProcessor);
}
 
Example #18
Source File: CSharpLinqQueryBodyImpl.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(PsiElement psiElement : getChildren())
	{
		if(!psiElement.processDeclarations(processor, state, lastParent, place))
		{
			return false;
		}
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example #19
Source File: GLSLCompoundStatement.java    From glsl4idea with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state,
                                   @Nullable PsiElement lastParent, @NotNull PsiElement place) {
    if (lastParent == null) {
        // Do not show declarations of nested variables to outside scopes
        return true;
    }

    for (GLSLStatement statement : getStatements()) {
        if (statement == null)
            continue;
        if (!statement.processDeclarations(processor, state, lastParent, place)) return false;
    }

    return true;
}
 
Example #20
Source File: CSharpTypeDeclarationImpl.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.GENERIC_PARAMETER))
	{
		for(DotNetGenericParameter dotNetGenericParameter : getGenericParameters())
		{
			if(!processor.execute(dotNetGenericParameter, state))
			{
				return false;
			}
		}
	}
	return true;
}
 
Example #21
Source File: CSharpPrefixExpressionImpl.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)
{
	DotNetExpression expression = getExpression();
	if(expression != null && !expression.processDeclarations(processor, state, lastParent, place))
	{
		return false;
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example #22
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 #23
Source File: CSharpCompositeElementGroupImpl.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(CSharpElementGroup<T> element : myGroups)
	{
		if(!processor.execute(element, state))
		{
			return false;
		}
	}
	return true;
}
 
Example #24
Source File: CSharpOutRefVariableExpressionImpl.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)
{
	DotNetVariable variable = getVariable();
	if(!processor.execute(variable, state))
	{
		return false;
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example #25
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 #26
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 #27
Source File: CSharpIfStatementImpl.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)
{
	DotNetExpression conditionExpression = getConditionExpression();
	if(conditionExpression != null)
	{
		if(!conditionExpression.processDeclarations(processor, state, lastParent, place))
		{
			return false;
		}
	}
	return super.processDeclarations(processor, state, lastParent, place);
}
 
Example #28
Source File: CSharpLinqFromClauseImpl.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)
{
	CSharpLinqVariableImpl variable = getVariable();
	if(variable != null)
	{
		if(!processor.execute(variable, state))
		{
			return false;
		}
	}
	return true;
}
 
Example #29
Source File: CSharpStubLikeMethodDeclarationImpl.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)
{
	return CSharpLikeMethodDeclarationImplUtil.processDeclarations(this, processor, state, lastParent, place);
}
 
Example #30
Source File: CSharpLocalMethodDeclarationStatementImpl.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)
{
	CSharpMethodDeclaration method = getMethod();
	if(!processor.execute(method, state))
	{
		return false;
	}
	return super.processDeclarations(processor, state, lastParent, place);
}