use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class MarkOccurencesSupport method installOccurrencesFinder.
protected void installOccurrencesFinder(final boolean forceUpdate) {
fMarkOccurrenceAnnotations = true;
fPostSelectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) selection, editor.getModule());
}
};
final ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider != null) {
((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fPostSelectionListener);
if (forceUpdate) {
fForcedMarkOccurrencesSelection = selectionProvider.getSelection();
final IErlModule module = editor.getModule();
if (module != null) {
editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, module);
}
}
}
if (fOccurrencesFinderJobCanceler == null) {
fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler();
fOccurrencesFinderJobCanceler.install();
}
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class RenameModuleQuickFix method run.
@Override
public void run() throws Exception {
final IMarker marker = getMarker();
final List<String> margs = getQuickFix().getArgs();
final String moduleName = margs.get(0);
final IErlModel svc = ErlangEngine.getInstance().getModel();
IErlModule newModule;
newModule = svc.findModule(moduleName);
if (newModule != null) {
MessageDialog.openInformation(null, "Rename module quickfix", "A module with name '" + moduleName + "' already exists.");
newModule.dispose();
return;
}
final IFile file = (IFile) marker.getResource();
final IErlModule oldModule = svc.findModule(file);
if (oldModule == null) {
return;
}
String in = Util.getInputStreamAsString(file.getContents(), file.getCharset());
in = in.replaceFirst("-module\\([^)]+\\)\\.", "-module(" + moduleName + ").");
file.setContents(new ByteArrayInputStream(in.getBytes()), IResource.FORCE, null);
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlangCompletionService method getAllPreprocessorDefs.
public static List<IErlPreprocessorDef> getAllPreprocessorDefs(final IErlModule module, final ErlElementKind kind) throws CoreException {
final List<IErlPreprocessorDef> result = Lists.newArrayList();
final List<IErlModule> modulesWithIncludes = Lists.newArrayList(ErlangEngine.getInstance().getModelFindService().findAllIncludedFiles(module));
modulesWithIncludes.add(module);
for (final IErlModule m : modulesWithIncludes) {
result.addAll(m.getPreprocessorDefs(kind));
}
return result;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlProject method getModulesAndIncludes.
@Override
public Collection<IErlModule> getModulesAndIncludes() throws ErlModelException {
final List<IErlModule> result = new ArrayList<>();
final ErlModelCache erlModelCache = ErlModelCache.getDefault();
final List<IErlModule> modulesForProject = erlModelCache.getModulesForProject(this);
final List<IErlModule> includesForProject = erlModelCache.getIncludesForProject(this);
if (modulesForProject != null && includesForProject != null) {
result.addAll(modulesForProject);
result.addAll(includesForProject);
} else {
final List<IErlModule> cached = erlModelCache.getModulesForProject(this);
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
if (cached == null) {
final List<IErlModule> modules = ErlProject.getModulesOrIncludes(fProject, model, getProperties().getSourceDirs(), true);
result.addAll(modules);
} else {
result.addAll(cached);
}
final Collection<IErlModule> includes = getIncludes();
result.addAll(includes);
}
return result;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlProject method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
final IResource r = getCorrespondingResource();
// check whether the Erlang project can be opened
if (!(r instanceof IContainer) || !r.isAccessible()) {
ErlLogger.warn("Project %s has no resources: res:%s acc:%s cont:%s", getName(), r, r == null ? "?" : r.isAccessible(), r instanceof IContainer);
throw new ErlModelException(new ErlModelStatus(ErlModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
}
addConfigurationChangeListeners();
try {
final IContainer c = (IContainer) r;
final IResource[] elems = c.members();
final List<IErlElement> children = new ArrayList<>(elems.length + 1);
// ErlLogger.debug(">>adding externals");
addExternals(children);
// ErlLogger.debug("childcount %d", children.size());
// ErlLogger.debug(">>adding otp");
addOtpExternals(children);
// ErlLogger.debug("childcount %d", children.size());
final IErlModel model = ErlangEngine.getInstance().getModel();
for (final IResource element : elems) {
if (element instanceof IFolder) {
final IFolder folder = (IFolder) element;
final IErlFolder erlFolder = (IErlFolder) model.create(folder);
children.add(erlFolder);
} else if (element instanceof IFile) {
final IFile file = (IFile) element;
if (CommonUtils.isErlangFileContentFileName(file.getName())) {
final IErlModule m = (IErlModule) model.create(file);
children.add(m);
}
}
}
setChildren(children);
} catch (final CoreException e) {
ErlLogger.error(e);
setChildren(new ArrayList<IErlModule>());
return false;
}
return true;
}
Aggregations