Package org.intellij.erlang.psi

Examples of org.intellij.erlang.psi.ErlangFunction


    int endOffset = lastChild.getTextRange().getEndOffset();

    boolean needNewline = !(lastChild instanceof PsiWhiteSpace && StringUtil.countNewLines(lastChild.getText()) > 0);

    CaretModel caretModel = editor.getCaretModel();
    ErlangFunction function = PsiTreeUtil.getParentOfType(psiFile.findElementAt(caretModel.getOffset()), ErlangFunction.class);
    String name = function != null ? function.getName() : "name";
    caretModel.moveToOffset(endOffset);
    insertTestFunction(project, editor, name, needNewline);
  }
View Full Code Here


          Location location = testProxy.getLocation(project, GlobalSearchScope.allScope(project));
          PsiElement psiElement = location != null ? location.getPsiElement() : null;

          if (!(psiElement instanceof ErlangFunction)) continue;

          ErlangFunction function = (ErlangFunction) psiElement;
          String functionName = ErlangPsiImplUtil.getQualifiedFunctionName(function);
          testsToRerun.add(functionName);
        }

        configuration.getConfigData().setFunctionNames(testsToRerun);
View Full Code Here

    return testFiles;
  }

  @Nullable
  public static ErlangFunction getZeroArityFunction(@Nullable PsiElement psiElement) {
    ErlangFunction function = psiElement instanceof ErlangFunction ? (ErlangFunction)psiElement : PsiTreeUtil.getParentOfType(psiElement, ErlangFunction.class);
    int arity = function == null ? -1 : function.getArity();
    return 0 == arity ? function : null;
  }
View Full Code Here

    return locations;
  }

  @Nullable
  private static Location getTestLocation(Project project, ErlangFile file, String function, String line) {
    ErlangFunction f = ContainerUtil.getFirstItem(file.getFunctionsByName(function));
    String fileText = file.getText();
    int lineNumber = StringUtil.parseInt(line, -1);
    if (f == null) return null;
    if (lineNumber != -1) {
      lineNumber -= 1;
      if (lineNumber != StringUtil.offsetToLineNumber(fileText, f.getTextOffset())) {
        PsiElement testElement = findTestElementInLine(file, fileText, lineNumber);
        if (testElement != null) {
          return new PsiLocation<PsiElement>(project, testElement);
        }
      }
View Full Code Here

  }

  @Nullable
  @Override
  public String getDocText() {
    ErlangFunction prevFunction = PsiTreeUtil.getPrevSiblingOfType(myErlangFunction, ErlangFunction.class);
    ErlangSpecification spec = ErlangPsiImplUtil.getSpecification(myErlangFunction);
    PsiComment comment = PsiTreeUtil.getPrevSiblingOfType(myErlangFunction, PsiComment.class);

    String commentText = "";
    if (spec != null && ErlangPsiImplUtil.notFromPreviousFunction(spec, prevFunction)) {
View Full Code Here

          @Nullable
          @Override
          public ErlangFunction fun(AbstractTestProxy testProxy) {
            Location location = testProxy.getLocation(project, GlobalSearchScope.allScope(project));
            PsiElement psiElement = location != null ? location.getPsiElement() : null;
            ErlangFunction function = psiElement instanceof ErlangFunction ? (ErlangFunction) psiElement : null;
            if (function != null && function.getArity() != 0) {
              failedGeneratedTests.add(function);
            }
            return function;
          }
        });
        Set<ErlangFile> suites = ContainerUtil.map2Set(failedTests, new Function<ErlangFunction, ErlangFile>() {
          @Nullable
          @Override
          public ErlangFile fun(ErlangFunction function) {
            PsiFile containingFile = function.getContainingFile();
            return containingFile instanceof ErlangFile ? (ErlangFile) containingFile : null;
          }
        });
        suites.remove(null);
View Full Code Here

  }

  @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

      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

    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

    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

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.