コード例 #1
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
 public Collection<IPath> getIncludeDirs(
     final IProject project, final Collection<IPath> includeDirs) {
   final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
   if (erlProject == null) {
     return includeDirs;
   }
   final Collection<IPath> projectIncludeDirs = erlProject.getIncludeDirs();
   final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
   for (IPath inc : projectIncludeDirs) {
     inc = PluginUtils.resolvePVMPath(pvm, inc);
     if (inc.isAbsolute()) {
       includeDirs.add(inc);
     } else {
       final IFolder folder = project.getFolder(inc);
       if (folder != null) {
         final IPath location = folder.getLocation();
         if (location != null) {
           includeDirs.add(location);
         } else {
           ErlLogger.warn("No location for %s", folder);
         }
       }
     }
   }
   return includeDirs;
 }
コード例 #2
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
 public void refreshOutputDir(final IProject project) throws CoreException {
   final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
   final IPath outputDir = erlProject.getOutputLocation();
   final IResource ebinDir = project.findMember(outputDir);
   if (ebinDir != null) {
     ebinDir.refreshLocal(IResource.DEPTH_ONE, null);
   }
 }
コード例 #3
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
 private IPath getBeamForErl(final IResource source) {
   final IErlProject erlProject =
       ErlModelManager.getErlangModel().getErlangProject(source.getProject());
   IPath p = erlProject.getOutputLocation();
   p = p.append(source.getName());
   if (!"erl".equals(p.getFileExtension())) {
     return null;
   }
   final IPath module = p.removeFileExtension();
   final IPath beamPath = module.addFileExtension("beam").setDevice(null);
   return beamPath;
 }
コード例 #4
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
  public void checkForClashes(final IBackend backend, final IProject project) {
    try {
      final OtpErlangList res = InternalErlideBuilder.getCodeClashes(backend);
      for (final OtpErlangObject elem : res) {
        final OtpErlangTuple t = (OtpErlangTuple) elem;
        final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
        final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();

        // add marker only for modules belonging to this project!
        final IResource r1 = project.findMember(f1);
        final IResource r2 = project.findMember(f2);
        if (r1 != null || r2 != null) {
          MarkerUtils.addMarker(
              project,
              null,
              project,
              "Code clash between " + f1 + " and " + f2,
              0,
              IMarker.SEVERITY_WARNING,
              "");
        }
      }

    } catch (final Exception e) {
    }
    try {
      final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
      final Collection<IPath> sd = erlProject.getSourceDirs();
      final String[] dirList = new String[sd.size()];
      int j = 0;
      for (final IPath sp : sd) {
        dirList[j++] = project.getLocation().toPortableString() + "/" + sp;
      }
      final OtpErlangList res = InternalErlideBuilder.getSourceClashes(backend, dirList);
      for (int i = 0; i < res.arity(); i++) {
        final OtpErlangTuple t = (OtpErlangTuple) res.elementAt(i);
        final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
        final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();
        MarkerUtils.addMarker(
            project,
            null,
            project,
            "Duplicated module name in " + f1 + " and " + f2,
            0,
            IMarker.SEVERITY_WARNING,
            "");
      }
    } catch (final Exception e) {
      ErlLogger.debug(e);
    }
  }
コード例 #5
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
  public boolean shouldCompile(final IProject project, final IResource source, final IResource beam)
      throws ErlModelException {
    boolean shouldCompile = beam == null;

    if (beam != null) {
      final IErlProject eprj = ErlModelManager.getErlangModel().findProject(project);
      if (eprj != null) {
        shouldCompile = shouldCompileModule(project, source, beam, shouldCompile, eprj);
      }
    }

    if (beam != null) {
      shouldCompile |= beam.getLocalTimeStamp() < source.getLocalTimeStamp();
    }
    return shouldCompile;
  }
コード例 #6
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
 public void addDependents(
     final IResource resource, final IProject my_project, final Set<BuildResource> result)
     throws ErlModelException {
   final IErlProject eprj = ErlModelManager.getErlangModel().findProject(my_project);
   if (eprj != null) {
     final Collection<IErlModule> ms = eprj.getModules();
     for (final IErlModule m : ms) {
       final Collection<ErlangIncludeFile> incs = m.getIncludeFiles();
       for (final ErlangIncludeFile ifile : incs) {
         if (samePath(ifile.getFilename(), resource.getName())) {
           if (m.getModuleKind() == ModuleKind.ERL) {
             final BuildResource bres = new BuildResource(m.getResource());
             result.add(bres);
           }
           break;
         }
       }
     }
   }
 }
コード例 #7
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
 @Override
 public boolean visit(final IResource resource) throws CoreException {
   if (fName == null) {
     return false;
   }
   if (getResult() != null) {
     return false;
   }
   final IErlProject erlProject =
       ErlModelManager.getErlangModel().getErlangProject(resource.getProject());
   if (resource.getType() == IResource.FILE
       && resource.getFileExtension() != null
       && "erl".equals(resource.getFileExtension())
       && isInCodePath(resource, erlProject)) {
     final String[] p = resource.getName().split("\\.");
     if (p[0].equals(fName)) {
       setResult(resource);
       return false;
     }
   }
   return true;
 }
コード例 #8
0
ファイル: BuilderHelper.java プロジェクト: sergeyzsg/erlide
 private void completeCompileForYrl(
     final IProject project,
     final IResource source,
     final IBackend backend,
     final OtpErlangList compilerOptions) {
   final IPath erl = getErlForYrl(source);
   if (erl != null) {
     try {
       source.getParent().refreshLocal(IResource.DEPTH_ONE, null);
       final IResource br = project.findMember(erl);
       if (br != null) {
         br.setDerived(true, null);
         final BuildResource bbr = new BuildResource(br);
         // br.touch() doesn't work...
         final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
         compileErl(
             project, bbr, erlProject.getOutputLocation().toString(), backend, compilerOptions);
       }
     } catch (final CoreException e) {
       ErlLogger.warn(e);
     }
   }
 }
コード例 #9
0
ファイル: ParsingTests.java プロジェクト: huiqing/erlide
 private boolean parse(final String s) {
   final String scannerModuleName = module.getScannerName();
   ErlideScanner.initialScan(scannerModuleName, "", s, false);
   final IErlParser parser = ErlModelManager.getErlangModel().getParser();
   return parser.parse(module, scannerModuleName, false, "", false);
 }
コード例 #10
0
ファイル: ParsingTests.java プロジェクト: huiqing/erlide
 /** @throws java.lang.Exception */
 @Before
 public void setUp() throws Exception {
   final IErlModel model = ErlModelManager.getErlangModel();
   module = model.getModuleFromText(model, "testing", "", null);
 }