Examples of ErlangFunction


Examples of org.intellij.erlang.psi.ErlangFunction

  }

  @Override
  public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
    PsiElement focusedElement = file.findElementAt(editor.getCaretModel().getOffset());
    ErlangFunction function = focusedElement == null ? null : PsiTreeUtil.getParentOfType(focusedElement, ErlangFunction.class);

    if (function == null) return;

    List<ErlangCallbackSpec> callbackSpecs = ErlangNavigationUtil.getCallbackSpecs(function);
    String presentation = ErlangPsiImplUtil.createFunctionPresentation(function);
View Full Code Here

Examples of org.intellij.erlang.psi.ErlangFunction

      VirtualFile file = mySourcePosition.getSourcePosition().getFile();
      Document document = FileDocumentManager.getInstance().getDocument(file);
      PsiFile psiFile = document != null ? PsiDocumentManager.getInstance(myProject).getPsiFile(document) : null;
      ErlangFile module = ObjectUtils.tryCast(psiFile, ErlangFile.class);

      ErlangFunction function = module != null ? module.getFunction(functionName, mySourcePosition.getFunctionArity()) : null;
      if (function != null) {
        String title = ErlangPsiImplUtil.getQualifiedFunctionName(function);
        ErlangFunExpression funExpression = ErlangPsiImplUtil.findFunExpression(function, mySourcePosition.getFunExpressionArity());
        if (funExpression != null) {
          int line = 1 + StringUtil.offsetToLineNumber(funExpression.getContainingFile().getText(), funExpression.getTextOffset());
View Full Code Here

Examples of org.intellij.erlang.psi.ErlangFunction

    PsiElement psiElement = sourceElement.get();
    if (psiElement == null || !psiElement.isValid()) {
      return false;
    }

    ErlangFunction function = PsiTreeUtil.getParentOfType(psiElement, ErlangFunction.class);
    PsiFile containingFile = psiElement.getContainingFile();

    if (!(containingFile instanceof ErlangFile) || function == null ||
      ErlangPsiImplUtil.isEunitTestFunction(function) ||
      ErlangPsiImplUtil.isPrivateFunction(containingFile, function)) {
      return false;
    }

    Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
    VirtualFile vFile = containingFile.getVirtualFile();
    if (vFile == null) return false;
    String moduleName = vFile.getNameWithoutExtension();
    String functionName = function.getName();

    configuration.setModuleAndFunction(moduleNameAndFunction(moduleName, functionName));
    configuration.setName(moduleName + "." + functionName);
    if (module != null) {
      configuration.setModule(module);
View Full Code Here

Examples of org.intellij.erlang.psi.ErlangFunction

    Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
    if (module == null || !module.equals(configuration.getConfigurationModule().getModule())) {
      return false;
    }

    ErlangFunction function = PsiTreeUtil.getParentOfType(psiElement, ErlangFunction.class);
    PsiFile containingFile = psiElement.getContainingFile();
    VirtualFile vFile = containingFile != null ? containingFile.getVirtualFile() : null;
    if (function == null || vFile == null) return false;

    return StringUtil.equals(configuration.getModuleAndFunction(),
      moduleNameAndFunction(vFile.getNameWithoutExtension(), function.getName()));
  }
View Full Code Here

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

Examples of org.intellij.erlang.psi.ErlangFunction

      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

Examples of org.intellij.erlang.psi.ErlangFunction

    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

Examples of org.intellij.erlang.psi.ErlangFunction

  }

  @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

Examples of org.intellij.erlang.psi.ErlangFunction

  @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

Examples of org.intellij.erlang.psi.ErlangFunction

      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
TOP
Copyright © 2018 www.massapi.com. 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.