Example #1
0
 private boolean shouldCompileModule(
     final IProject project,
     final IResource source,
     final IResource beam,
     boolean shouldCompile,
     final IErlProject eprj)
     throws ErlModelException {
   final IErlModule m = eprj.getModule(source.getName());
   if (m != null) {
     final Collection<ErlangIncludeFile> incs = m.getIncludeFiles();
     for (final ErlangIncludeFile ifile : incs) {
       final IResource rifile = findResourceByName(project, ifile.getFilename());
       if (rifile != null && rifile.getLocalTimeStamp() > beam.getLocalTimeStamp()) {
         shouldCompile = true;
         break;
       }
     }
   }
   return shouldCompile;
 }
Example #2
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;
         }
       }
     }
   }
 }
Example #3
0
 @Test
 public void parseCompileDirective() throws ErlModelException {
   final String sourceContent = "[inline,{hipe,[{regalloc,linear_scan}]}]";
   final String source = "-compile(" + sourceContent + ").";
   assertTrue(parse(source));
   final IErlElement attribute =
       TestingSupport.createErlAttribute(module, "compile", null, sourceContent, 0, 50);
   final List<IErlElement> expected = new ArrayList<IErlElement>(1);
   expected.add(attribute);
   final Collection<IErlElement> actual = module.getChildren();
   // assertEquals(expected, actual);
   assertEquals(expected.toString(), actual.toString());
 }
 /**
  * Provide the text selection that is needed to execute the command. Default implementation,
  * extend to Erlang elements selected.
  *
  * @param document text {@link IDocument}
  * @param selection selection affected by command (extended by extendSelection)
  * @return new {@link ITextSelection} with all text up to selection
  */
 protected ITextSelection getTextSelection(
     final IDocument document, final ITextSelection selection) {
   if (getTextEditor() instanceof ErlangEditor) {
     final ErlangEditor erlangEditor = (ErlangEditor) getTextEditor();
     final IErlModule module = erlangEditor.getModule();
     if (module != null) {
       final int offset1 = selection.getOffset(), offset2 = offset1 + selection.getLength();
       try {
         final IErlElement e1 = module.getElementAt(offset1);
         final IErlElement e2 = module.getElementAt(offset2);
         if (e1 instanceof ISourceReference) {
           final ISourceReference ref1 = (ISourceReference) e1;
           final ISourceRange r1 = ref1.getSourceRange();
           if (e1 == e2) {
             return extendSelectionToWholeLines(
                 document, new TextSelection(document, r1.getOffset(), r1.getLength()));
           } else if (e2 == null) {
             return extendSelectionToWholeLines(
                 document,
                 new TextSelection(
                     document,
                     r1.getOffset(),
                     selection.getLength() + selection.getOffset() - r1.getOffset()));
           } else if (e2 instanceof ISourceReference) {
             final ISourceReference ref2 = (ISourceReference) e2;
             final ISourceRange r2 = ref2.getSourceRange();
             return extendSelectionToWholeLines(
                 document,
                 new TextSelection(
                     document, r1.getOffset(), r2.getOffset() - r1.getOffset() + r2.getLength()));
           }
         }
       } catch (final ErlModelException e) {
       }
     }
   }
   return extendSelectionToWholeLines(document, selection);
 }
Example #5
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);
 }
Example #6
0
 /** @throws java.lang.Exception */
 @After
 public void tearDown() throws Exception {
   module.dispose();
   module = null;
 }