Package org.intellij.erlang.psi

Examples of org.intellij.erlang.psi.ErlangModule


    return new PsiLocation<PsiElement>(project, f);
  }

  @Nullable
  private static Location getModuleLocation(Project project, ErlangFile file) {
    ErlangModule module = file.getModule();
    return module != null ? new PsiLocation<PsiElement>(project, module) : null;
  }
View Full Code Here


  public static ErlangFile getErlangModuleFile(final Project project, final String moduleName) {
    return ApplicationManager.getApplication().runReadAction(new Computable<ErlangFile>() {
      @Nullable
      @Override
      public ErlangFile compute() {
        ErlangModule module = doGetErlangModule(project, moduleName);
        PsiFile containingFile = module != null ? module.getContainingFile() : null;
        return containingFile instanceof ErlangFile ? (ErlangFile) containingFile : null;
      }
    });
  }
View Full Code Here

      return "Rename module";
    }

    @Override
    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
      ErlangModule module = PsiTreeUtil.getParentOfType(problemDescriptor.getPsiElement(), ErlangModule.class);
      if (module == null) return;
      AccessToken token = WriteAction.start();
      String name;
      try {
        ErlangElementFactory.createQAtomFromText(project, myShouldBeName);
        name = myShouldBeName;
      } catch (Exception e) {
        name = "'" + myShouldBeName + "'";
      }
      try {
        module.setName(name);
      } finally {
        token.finish();
      }
    }
View Full Code Here

      return "Rename containing file";
    }

    @Override
    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
      ErlangModule module = PsiTreeUtil.getParentOfType(problemDescriptor.getPsiElement(), ErlangModule.class);
      if (module == null) return;
      AccessToken token = WriteAction.start();
      try {
        VirtualFile virtualFile = module.getContainingFile().getVirtualFile();
        String extension = FileUtilRt.getExtension(module.getContainingFile().getName());
        if (virtualFile != null) {
          virtualFile.rename(problemDescriptor, StringUtil.replace(module.getName(), "'", "") + "." + extension);
        }
      } catch (IOException ignored) {
      } finally {
        token.finish();
      }
View Full Code Here

    }

    ErlangRunningState.ErlangEntryPoint entryPoint = ErlangRunningState.ErlangEntryPoint.fromModuleAndFunction(myModuleAndFunction, myParams);
    if (entryPoint == null) throw new RuntimeConfigurationError("Invalid module and function entry point");

    ErlangModule erlangModule = ErlangModulesUtil.getErlangModule(getProject(), entryPoint.getModuleName());
    if (erlangModule == null) {
      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

  public static Icon getIcon(@NotNull ErlangFile file) {
    if (!file.isValid()) return null;
    VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
    FileType fileType = virtualFile.getFileType();
    if (ErlangFileType.MODULE == fileType) {
      ErlangModule module = file.getModule();
      boolean isEunit = module != null && ErlangPsiImplUtil.isEunitTestFile(file);
      return isEunit ? ErlangIcons.EUNIT : getModuleType(file).icon;
    }
    return fileType.getIcon();
  }
View Full Code Here

TOP

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

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.