Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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);
   }
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
  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);
    }
  }
Exemplo n.º 5
0
  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;
  }
Exemplo n.º 6
0
 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;
         }
       }
     }
   }
 }
Exemplo n.º 7
0
 @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;
 }
Exemplo n.º 8
0
 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);
     }
   }
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 /** @throws java.lang.Exception */
 @Before
 public void setUp() throws Exception {
   final IErlModel model = ErlModelManager.getErlangModel();
   module = model.getModuleFromText(model, "testing", "", null);
 }