Package org.intellij.erlang.psi

Examples of org.intellij.erlang.psi.ErlangFile


      String moduleName = linkMatcher.group(1);
      PsiFile[] psiFiles = FilenameIndex.getFilesByName(
        project, moduleName + ".erl", GlobalSearchScope.allScope(project));
      for (PsiFile psiFile : psiFiles) {
        if (psiFile instanceof ErlangFile) {
          ErlangFile erlFile = (ErlangFile) psiFile;
          if (linkMatcher.group(2) == null) {
            return erlFile.getModule();
          }
          else {
            String functionName = linkMatcher.group(3);
            if (functionName.equals("type")) {
              String typeName = linkMatcher.group(4);
              return erlFile.getType(typeName);
            }
            else {
              int arity = Integer.valueOf(linkMatcher.group(4));
              return erlFile.getFunction(functionName, arity);
            }
          }
        }
      }
    }
View Full Code Here


    });
  }

  private PsiFile createModifiedConfigPsi(File oldConfig) throws IOException {
    String oldConfigText = oldConfig.exists() ? new String(FileUtil.loadFileText(oldConfig)) : "";
    ErlangFile configPsi = (ErlangFile) PsiFileFactory.getInstance(myConfiguration.getProject())
      .createFileFromText(CONFIG_FILE_NAME, ErlangFileType.TERMS, oldConfigText);
    List<ErlangTupleExpression> eunitOptsSections = ErlangTermFileUtil.getConfigSections(configPsi, "eunit_opts");
    if (eunitOptsSections.isEmpty()) {
      ErlangExpression form = ErlangTermFileUtil.createForm(EUNIT_OPTS);
      assert form != null;
      configPsi.add(form);
    } else {
      removeReportOptions(eunitOptsSections);
      addEunitTeamcityReportOptions(eunitOptsSections.get(0));
    }
    return configPsi;
View Full Code Here

public class ErlangFoldingBuilder extends FoldingBuilderEx implements DumbAware {
  @NotNull
  @Override
  public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
    if (!(root instanceof ErlangFile)) return FoldingDescriptor.EMPTY;
    ErlangFile file = (ErlangFile) root;

    final List<FoldingDescriptor> result = ContainerUtil.newArrayList();
    for (ErlangFunction function : file.getFunctions()) {
      result.add(new FoldingDescriptor(function, function.getTextRange()));
    }

    if (!quick) {
      PsiTreeUtil.processElements(file, new PsiElementProcessor() {
View Full Code Here

    String functionName = mySourcePosition != null ? mySourcePosition.getFunctionName() : null;
    if (functionName != null) {
      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

    return create(project, traceElement.getModule(), traceElement.getFunction(), traceElement.getFunctionArgs().arity());
  }

  @Nullable
  public static ErlangSourcePosition create(@NotNull Project project, @NotNull String module, int line) {
    ErlangFile file = ErlangModulesUtil.getErlangModuleFile(project, module);
    VirtualFile moduleFile = file != null ? file.getVirtualFile() : null;
    XSourcePosition sourcePosition = XDebuggerUtil.getInstance().createPosition(moduleFile, line);
    return sourcePosition != null ? new ErlangSourcePosition(sourcePosition) : null;
  }
View Full Code Here

    XSourcePosition position = ApplicationManager.getApplication().runReadAction(new Computable<XSourcePosition>() {
      @Nullable
      @Override
      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;

        return XDebuggerUtil.getInstance().createPositionByOffset(virtualFile, offset);
      }
    });
View Full Code Here

    doTest(0, files);
  }

  private void doTest(int expectedIncludedFiles, String... files) throws Exception {
    myFixture.configureByFiles(files);
    ErlangFile file = (ErlangFile) myFixture.getFile();
    List<ErlangFile> directlyIncludedFiles = ErlangPsiImplUtil.getDirectlyIncludedFiles(file);
    assertEquals("Include attribute resolved to unexpected number of files.", expectedIncludedFiles, directlyIncludedFiles.size());
  }
View Full Code Here

TOP

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

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.