com.intellij.psi.PsiElement#processDeclarations ( )源码实例Demo

下面列出了com.intellij.psi.PsiElement#processDeclarations ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo-csharp   文件: CSharpLinqQueryBodyImpl.java
@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);
}
 
源代码2 项目: consulo-csharp   文件: CSharpLinqExpressionImpl.java
@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);
}
 
源代码3 项目: consulo   文件: PsiScopesUtilCore.java
public static boolean walkChildrenScopes(@Nonnull PsiElement thisElement,
                                         @Nonnull PsiScopeProcessor processor,
                                         @Nonnull ResolveState state,
                                         PsiElement lastParent,
                                         PsiElement place) {
  PsiElement child = null;
  if (lastParent != null && lastParent.getParent() == thisElement) {
    child = lastParent.getPrevSibling();
    if (child == null) return true; // first element
  }

  if (child == null) {
    child = thisElement.getLastChild();
  }

  while (child != null) {
    if (!child.processDeclarations(processor, state, null, place)) return false;
    child = child.getPrevSibling();
  }

  return true;
}
 
源代码4 项目: BashSupport   文件: BashResolveUtil.java
public static boolean processContainerDeclarations(BashPsiElement thisElement, @NotNull final PsiScopeProcessor processor, @NotNull final ResolveState state, final PsiElement lastParent, @NotNull final PsiElement place) {
    if (thisElement == lastParent) {
        return true;
    }

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

    //process the current's elements children from first until lastParent is reached, a definition has to be before the use
    List<PsiElement> functions = Lists.newLinkedList();

    //fixme use stubs
    for (PsiElement child = thisElement.getFirstChild(); child != null && child != lastParent; child = child.getNextSibling()) {
        if (child instanceof BashFunctionDef) {
            functions.add(child);
        } else if (!child.processDeclarations(processor, state, lastParent, place)) {
            return false;
        }
    }

    for (PsiElement function : functions) {
        if (!function.processDeclarations(processor, state, lastParent, place)) {
            return false;
        }
    }

    //fixme this is very slow atm
    if (lastParent != null && lastParent.getParent().isEquivalentTo(thisElement) && BashPsiUtils.findNextVarDefFunctionDefScope(place) != null) {
        for (PsiElement sibling = lastParent.getNextSibling(); sibling != null; sibling = sibling.getNextSibling()) {
            if (!sibling.processDeclarations(processor, state, null, place)) {
                return false;
            }
        }
    }

    return true;
}
 
源代码5 项目: glsl4idea   文件: GLSLFile.java
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @Nullable PsiElement lastParent, @NotNull PsiElement place) {
    if (lastParent == null) {
        return true;
    }
    PsiElement child = lastParent.getPrevSibling();
    while (child != null) {
        if (!child.processDeclarations(processor, state, lastParent, place)) return false;
        child = child.getPrevSibling();
    }
    return true;
}
 
源代码6 项目: consulo-csharp   文件: CSharpXAccessorImpl.java
@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;
}
 
源代码7 项目: intellij-xquery   文件: ResolveUtil.java
public static <T extends XQueryPsiElement> boolean processChildren(PsiElement element, PsiScopeProcessor processor,
        ResolveState substitutor, PsiElement lastParent, PsiElement place, Class<T>... childClassesToSkip) {
    PsiElement run = lastParent == null ? element.getLastChild() : lastParent.getPrevSibling();
    while (run != null) {
        if (!isAnyOf(run, childClassesToSkip) &&PsiTreeUtil.findCommonParent(place, run) != run && !run.processDeclarations(processor, substitutor,
                null, place)) {
            return false;
        }
        run = run.getPrevSibling();
    }

    return true;
}
 
源代码8 项目: consulo   文件: PsiScopesUtilCore.java
public static boolean treeWalkUp(@Nonnull final PsiScopeProcessor processor,
                                 @Nonnull final PsiElement entrance,
                                 @Nullable final PsiElement maxScope,
                                 @Nonnull final ResolveState state) {
  if (!entrance.isValid()) {
    LOGGER.error(new PsiInvalidElementAccessException(entrance));
  }
  PsiElement prevParent = entrance;
  PsiElement scope = entrance;

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

    if (!scope.processDeclarations(processor, state, prevParent, entrance)) {
      return false; // resolved
    }


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

  }

  return true;
}
 
源代码9 项目: consulo-csharp   文件: CSharpResolveUtil.java
public static boolean treeWalkUp(@Nonnull final PsiScopeProcessor processor,
		@Nonnull final PsiElement entrance,
		@Nonnull final PsiElement sender,
		@Nullable PsiElement maxScope,
		@Nonnull final ResolveState state)
{
	if(!entrance.isValid())
	{
		CSharpResolveUtil.LOG.error(new PsiInvalidElementAccessException(entrance));
	}

	PsiElement prevParent = entrance;
	PsiElement scope = entrance;

	if(maxScope == null)
	{
		maxScope = sender.getContainingFile();
	}

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

		if(entrance != sender && scope instanceof PsiFile)
		{
			break;
		}

		if(!scope.processDeclarations(processor, state, prevParent, entrance))
		{
			return false; // resolved
		}

		if(entrance != sender)
		{
			break;
		}

		if(scope == maxScope)
		{
			break;
		}

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

	return true;
}