コード例 #1
0
  @Override
  public PsiElement resolve() {
    ErlangVarProcessor processor = new ErlangVarProcessor(myElement.getText(), myElement);
    ErlangListComprehension lc =
        PsiTreeUtil.getParentOfType(myElement, ErlangListComprehension.class);
    ErlangCompositeElement place = lc != null ? lc.getLcExprs() : myElement;
    ResolveUtil.treeWalkUp(place, processor);
    ErlangQVar result = processor.getResult();
    if (result != null) return result;

    ErlangModule module = getModule(myElement.getContainingFile());
    if (module == null) return null;
    module.processDeclarations(processor, ResolveState.initial(), module, module);

    return processor.getResult();
  }
コード例 #2
0
  @NotNull
  @Override
  public Object[] getVariants() {
    if (PsiTreeUtil.getParentOfType(myElement, ErlangArgumentDefinition.class) != null)
      return new Object[] {};

    final List<LookupElement> result = new ArrayList<LookupElement>();
    if (!(myElement.getParent() instanceof ErlangRecordExpression)) {
      final ErlangFunctionClause clause =
          PsiTreeUtil.getParentOfType(myElement, ErlangFunctionClause.class);
      BaseScopeProcessor processor =
          new BaseScopeProcessor() {
            @Override
            public boolean execute(@NotNull PsiElement psiElement, ResolveState resolveState) {
              if (!psiElement.equals(myElement)
                  && psiElement instanceof ErlangQVar
                  && !psiElement.getText().equals("_")
                  && !inColonQualified(myElement)) {
                if (PsiTreeUtil.isAncestor(clause, psiElement, false)
                    && (inDefinition(psiElement) || isLeftPartOfAssignment(psiElement))) {
                  result.add(
                      LookupElementBuilder.create((PsiNamedElement) psiElement)
                          .setIcon(ErlangIcons.VARIABLE));
                }
              }
              return true;
            }
          };
      ResolveUtil.treeWalkUp(myElement, processor);

      result.addAll(
          ErlangPsiImplUtil.getFunctionLookupElements(
              myElement.getContainingFile(),
              false,
              PsiTreeUtil.getParentOfType(myElement, ErlangColonQualifiedExpression.class)));
    }

    return ArrayUtil.toObjectArray(result);
  }