use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ParserDB method run.
private void run(final IErlModel model, final Collection<SourcePathProvider> sourcePathProviders, final boolean includeTests) throws ErlModelException {
// we include all projects in workspace - create one for OTP too
int normal = 0;
int test = 0;
final Collection<IErlProject> projects = model.getErlangProjects();
for (final IErlProject project : projects) {
final Collection<IErlModule> modules = project.getModulesAndIncludes();
for (final IErlModule module : modules) {
if (isTest(module.getResource().getLocation().toPortableString())) {
test++;
} else {
normal++;
}
handleModule(module);
}
if (includeTests) {
// final TestCodeBuilder builder = new TestCodeBuilder();
// try {
// final Set<BuildResource> resources = builder
// .getAffectedResources(
// (IProject) project.getResource(),
// new NullProgressMonitor(), false);
// for (final BuildResource res : resources) {
// if (res.getResource().isLinked()
// || res.getResource().isDerived()) {
// System.out.println("SKIP!!!! " + res.getResource());
// continue;
// }
// test++;
// final IErlModule module = ErlModelManager
// .getInstance().getModel().findModule(
// (IFile) res.getResource());
// handleModule(module);
// }
// } catch (final CoreException e) {
// ErlLogger.error(e);
// }
}
}
ParserDB.out.println("--- " + normal + " " + test);
System.out.println("--- " + normal + " " + test);
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class SearchCoreUtil method addFileToScope.
static void addFileToScope(final IFile file, final ErlSearchScope result) {
if (SourceKind.hasModuleExtension(file.getName())) {
final IErlModule module = ErlangEngine.getInstance().getModel().findModule(file);
result.addModule(module);
}
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class SearchCoreUtil method getWorkspaceScope.
public static ErlSearchScope getWorkspaceScope(final boolean addExternals, final boolean addOtp) throws ErlModelException {
final ErlSearchScope result = new ErlSearchScope();
final Collection<IErlProject> erlangProjects = ErlangEngine.getInstance().getModel().getErlangProjects();
for (final IErlProject i : erlangProjects) {
final Collection<IErlModule> modules = i.getModulesAndIncludes();
for (final IErlModule j : modules) {
result.addModule(j);
}
// addProjectEbin(i, result);
}
final Set<String> externalModulePaths = new HashSet<>();
for (final IErlProject project : erlangProjects) {
SearchCoreUtil.addExternalModules(project, result, externalModulePaths, addExternals, addOtp);
}
return result;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class DialyzerUtils method doDialyze.
public static void doDialyze(final IProgressMonitor monitor, final Set<IErlModule> modules, final Set<IErlProject> projects, final IBackend backend) throws InvocationTargetException, DialyzerErrorException {
if (backend == null) {
ErlLogger.warn("Trying to dialyze with null backend");
return;
}
try {
for (final IErlModule module : modules) {
DialyzerMarkerUtils.removeDialyzerMarkersFor(module.getResource());
}
// TODO handle preferences from multiple projects
final DialyzerPreferences prefs = DialyzerPreferences.get(null);
final Collection<String> pltPaths = prefs.getPltPaths();
// prefs.getFromSource();
final boolean fromSource = false;
// prefs.getNoCheckPLT();
final boolean noCheckPLT = true;
final List<String> files = Lists.newArrayList();
final List<IPath> includeDirs = Lists.newArrayList();
final List<String> names = Lists.newArrayList();
DialyzerUtils.collectFilesAndIncludeDirs(modules, projects, files, names, includeDirs, fromSource);
if (names.isEmpty()) {
return;
}
final String fileNames = names.size() + " modules [" + DialyzerUtils.getFileNames(names) + "]";
monitor.subTask(fileNames);
ErlLogger.trace("dialyzer", "run %s", fileNames);
final IOtpRpc b = backend.getOtpRpc();
final RpcFuture future = ErlideDialyze.dialyze(b, files, pltPaths, includeDirs, fromSource, noCheckPLT);
while (!future.isDone()) {
// check cancellation
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
// check backend down
if (!backend.isRunning()) {
throw new BackendException("Dialyzer: backend " + backend.getName() + " is down");
}
OtpErlangObject r = null;
try {
r = future.checkedGet(500, TimeUnit.MILLISECONDS);
} catch (final TimeoutException e) {
} catch (final RpcTimeoutException e) {
}
if (r != null) {
DialyzerUtils.processResult(b, r);
}
}
} catch (final RpcException e) {
throw new InvocationTargetException(e);
} catch (final BackendException e) {
throw new InvocationTargetException(e);
}
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class DialyzerUtils method collectModulesFromResource.
public static Set<IErlModule> collectModulesFromResource(final IErlElementLocator model, final IResource resource) throws ErlModelException {
final Set<IErlModule> result = Sets.newHashSet();
final IErlElement element = model.findElement(resource, true);
if (element == null) {
return result;
}
if (element instanceof IErlFolder) {
final IErlFolder folder = (IErlFolder) element;
folder.open(null);
result.addAll(folder.getModules());
} else if (element instanceof IErlModule) {
final IErlModule module = (IErlModule) element;
result.add(module);
} else if (element instanceof IErlProject) {
final IErlProject project = (IErlProject) element;
project.open(null);
result.addAll(project.getModules());
}
return result;
}
Aggregations