Package org.intellij.erlang.psi

Examples of org.intellij.erlang.psi.ErlangFunction


  }

  @Override
  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    if (!file.getManager().isInProject(file)) return false;
    ErlangFunction function = findFunction(file, editor.getCaretModel().getOffset());
    if (function != null && file instanceof ErlangFile) {
      return !((ErlangFile) file).getExportedFunctions().contains(function);
    }
    return false;
  }
View Full Code Here


      throw new RuntimeConfigurationError("Invalid module name '" + entryPoint.getModuleName() + "'");
    }

    PsiFile containingFile = erlangModule.getContainingFile();
    assert containingFile instanceof ErlangFile;
    ErlangFunction function = ((ErlangFile) containingFile).getFunction(entryPoint.getFunctionName(), entryPoint.getArgsList().size());
    if (function == null) {
      throw new RuntimeConfigurationError("Module '" + entryPoint.getModuleName() + "' doesn't contain function '"
        + entryPoint.getFunctionName() + "' with " + entryPoint.getArgsList().size() + " arguments");
    }
  }
View Full Code Here

    return false;
  }

  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    ErlangFunction function = findFunction(file, editor.getCaretModel().getOffset());
    if (function != null) {
      ErlangExportFunctionFix.processFunction(project, function);
    }
  }
View Full Code Here

  }

  @Override
  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    if (!(file instanceof ErlangFile)) return false;
    ErlangFunction function = findFunction(file, editor.getCaretModel().getOffset());
    if (function == null) return false;

    return ErlangPsiImplUtil.getSpecification(function) == null;
  }
View Full Code Here

  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    if (!(file instanceof ErlangFile)) {
      throw new IncorrectOperationException("Only applicable to Erlang files.");
    }
    ErlangFunction function = findFunction(file, editor.getCaretModel().getOffset());
    if (function == null) {
      throw new IncorrectOperationException("Cursor should be placed on Erlang function.");
    }
    if (ErlangPsiImplUtil.getSpecification(function) != null) {
      throw new IncorrectOperationException("Specification for this function already exists.");
View Full Code Here

      public XSourcePosition compute() {
        ErlangFile erlangModule = ErlangModulesUtil.getErlangModuleFile(project, module);
        if (erlangModule == null) return null;

        //TODO use fun expression name to improve resolution (?)
        ErlangFunction function = erlangModule.getFunction(functionName, functionArity);
        ErlangCompositeElement clarifyingElement = inFunExpression && function != null ?
          ErlangPsiImplUtil.findFunExpression(function, funExpressionArity) : function;

        VirtualFile virtualFile = erlangModule.getVirtualFile();
        int offset = clarifyingElement != null ? clarifyingElement.getTextOffset() : 0;
View Full Code Here

    LanguageCodeInsightActionHandler handler = CodeInsightActions.GOTO_SUPER.forLanguage(ErlangLanguage.INSTANCE);
    assertNotNull("GotoSuperHandler for Erlang was not found.", handler);

    PsiElement focusedElement = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset());
    ErlangFunction function = PsiTreeUtil.getParentOfType(focusedElement, ErlangFunction.class);

    assertNotNull("Invalid test data. A caret should be placed to function.", function);

    List<ErlangCallbackSpec> callbackSpecFuns = ErlangNavigationUtil.getCallbackSpecs(function);
View Full Code Here

    return "Remove function";
  }

  @Override
  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    ErlangFunction function = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), ErlangFunction.class);
    if (function != null) {
      ErlangSpecification specification = ErlangPsiImplUtil.getSpecification(function);
      if (specification != null) {
        specification.getParent().delete();
      }
      function.delete();
    }
  }
View Full Code Here

    return "testData/debugger/";
  }

  public void testFunctionSourcePositionConstructor() throws Exception {
    ErlangSourcePosition sourcePosition = ErlangSourcePosition.create(getProject(), MODULE_NAME, "function", 0);
    ErlangFunction function = myErlangFile.getFunction("function", 0);

    assertNotNull(sourcePosition);
    assertNotNull(function);
    assertEquals(MODULE_NAME, sourcePosition.getErlangModuleName());
    assertEquals(myErlangFile.getVirtualFile(), sourcePosition.getFile());
    assertEquals(function.getTextOffset(), sourcePosition.getSourcePosition().getOffset());
    assertEquals(0, sourcePosition.getFunctionArity());
    assertEquals(-1, sourcePosition.getFunExpressionArity());
  }
View Full Code Here

  }

  public void testFunExpressionSourcePositionConstructor() throws Exception {
    ErlangSourcePosition sourcePosition =
      ErlangSourcePosition.create(getProject(), MODULE_NAME, "-function_with_fun_expression/0-fun-0-", 0);
    ErlangFunction function = myErlangFile.getFunction("function_with_fun_expression", 0);
    ErlangFunExpression funExpression = PsiTreeUtil.findChildOfType(function, ErlangFunExpression.class, true);
    ErlangFunClause funExpressionClause = PsiTreeUtil.findChildOfType(funExpression, ErlangFunClause.class, true);

    assertNotNull(sourcePosition);
    assertNotNull(function);
View Full Code Here

TOP

Related Classes of org.intellij.erlang.psi.ErlangFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.