Exemple #1
0
 public static IErlProject createErlProject(final IPath path, final String name)
     throws CoreException {
   final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   final IProject project2 = root.getProject(name);
   try {
     project2.delete(true, null);
   } catch (final CoreException x) {
     // ignore
   }
   final IErlProject erlProject = ErlangCore.getModel().newProject(name, path.toPortableString());
   final IProject project = erlProject.getProject();
   final IOldErlangProjectProperties prefs = new OldErlangProjectProperties(project);
   final List<IPath> srcDirs = new ArrayList<IPath>();
   srcDirs.add(new Path("src"));
   prefs.setSourceDirs(srcDirs);
   buildPaths(root, project, srcDirs);
   final List<IPath> includeDirs = new ArrayList<IPath>();
   includeDirs.add(new Path("include"));
   buildPaths(root, project, includeDirs);
   prefs.setIncludeDirs(includeDirs);
   final List<IPath> ebinDirs = new ArrayList<IPath>();
   ebinDirs.add(new Path("ebin"));
   buildPaths(root, project, ebinDirs);
   prefs.setOutputDir(ebinDirs.get(0));
   return erlProject;
 }
  public OtpErlangList getSearchPath() {
    IProject project = file.getProject();
    IErlModel model = ErlangCore.getModel();
    IErlProject actualProject = model.getErlangProject(project.getName());
    OldErlangProjectProperties prop = actualProject.getProperties();
    IPath projectLocation = actualProject.getProject().getLocation();

    List<String> sourcDirs = prop.getSourceDirs();
    OtpErlangString[] searchPath = new OtpErlangString[sourcDirs.size()];
    for (int i = 0; i < sourcDirs.size(); ++i) {
      searchPath[i] = new OtpErlangString(projectLocation.append(sourcDirs.get(i)).toOSString());
    }
    return new OtpErlangList(searchPath);
  }
Exemple #3
0
 public static void addDialyzerWarningMarkersFromResultList(
     final IErlProject project, final Backend backend, final OtpErlangList result) {
   if (result == null) {
     return;
   }
   final IProject p = project.getProject();
   for (final OtpErlangObject i : result) {
     final OtpErlangTuple t = (OtpErlangTuple) i;
     final OtpErlangTuple fileLine = (OtpErlangTuple) t.elementAt(1);
     final String filename = Util.stringValue(fileLine.elementAt(0));
     final OtpErlangLong lineL = (OtpErlangLong) fileLine.elementAt(1);
     int line = 1;
     try {
       line = lineL.intValue();
     } catch (final OtpErlangRangeException e) {
       ErlLogger.error(e);
     }
     String s = ErlideDialyze.formatWarning(backend, t).trim();
     final int j = s.indexOf(": ");
     if (j != -1) {
       s = s.substring(j + 1);
     }
     addDialyzerWarningMarker(p, filename, line, s);
   }
 }
Exemple #4
0
 public static IErlModule createErlModule(
     final IErlProject erlProject, final String moduleName, final String moduleContents)
     throws CoreException {
   final IProject project = erlProject.getProject();
   final IFolder folder = project.getFolder("src");
   final IFile file = folder.getFile(moduleName);
   file.create(new ByteArrayInputStream(moduleContents.getBytes()), true, null);
   return ErlangCore.getModel().findModule(file);
 }
Exemple #5
0
 @SuppressWarnings("unused")
 private static void getMarkersFor(final IResource resource, final IErlProject p)
     throws ErlModelException {
   final IErlModule m = p.getModule(resource.getName());
   if (m == null) {
     return;
   }
   m.getScanner();
   final Collection<IErlComment> cl = m.getComments();
   for (final IErlComment c : cl) {
     final String text = c.getName();
     final int line = c.getLineStart();
     mkMarker(resource, line, text, "TODO", IMarker.PRIORITY_NORMAL);
     mkMarker(resource, line, text, "XXX", IMarker.PRIORITY_NORMAL);
     mkMarker(resource, line, text, "FIXME", IMarker.PRIORITY_HIGH);
   }
   m.disposeScanner();
 }
Exemple #6
0
 public static void openOpenResult(
     final ErlangEditor editor,
     final IErlModule module,
     final Backend backend,
     final int offset,
     final IErlProject erlProject,
     final OpenResult res)
     throws CoreException, ErlModelException, PartInitException, BadLocationException,
         OtpErlangRangeException, BackendException {
   final IErlModel model = ErlangCore.getModel();
   final IProject project = erlProject == null ? null : erlProject.getProject();
   final IErlElement element = editor.getElementAt(offset, true);
   IErlElement foundElement = null;
   ISourceRange foundSourceRange = null;
   final boolean checkAllProjects = NavigationPreferencePage.getCheckAllProjects();
   if (res.isExternalCall()) {
     foundElement = findExternalCallOrType(module, res, project, element, checkAllProjects);
   } else if (res.isInclude()) {
     foundElement = findInclude(module, erlProject, res, model, project);
   } else if (res.isLocalCall()) {
     foundElement =
         findLocalCall(module, backend, erlProject, res, project, element, checkAllProjects);
   } else if (res.isVariable() && element instanceof ISourceReference) {
     final ISourceReference sref = (ISourceReference) element;
     final ISourceRange range = sref.getSourceRange();
     final String elementText = editor.getDocument().get(range.getOffset(), range.getLength());
     foundSourceRange = ErlModelUtils.findVariable(backend, range, res.getName(), elementText);
   } else if (res.isRecord() || res.isMacro()) {
     final IErlElement.Kind kind =
         res.isMacro() ? IErlElement.Kind.MACRO_DEF : IErlElement.Kind.RECORD_DEF;
     foundElement =
         ErlModelUtils.findPreprocessorDef(
             backend, project, module, res.getName(), kind, model.getExternalIncludes(erlProject));
   }
   if (foundElement != null) {
     ErlModelUtils.openElement(foundElement);
   } else if (foundSourceRange != null) {
     ErlModelUtils.openSourceRange(module, foundSourceRange);
   }
 }
Exemple #7
0
 public static void invokeBuilderOn(final IErlProject erlProject) throws CoreException {
   final IProject project = erlProject.getProject();
   project.build(IncrementalProjectBuilder.FULL_BUILD, null);
 }
Exemple #8
0
 public static void deleteErlProject(final IErlProject erlProject) throws CoreException {
   final IProject project = erlProject.getProject();
   project.delete(true, null);
 }