use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class CompilerPreferencePage method doLinkActivated.
void doLinkActivated(final Link widget) {
if (isProjectPreferencePage()) {
openWorkspacePreferences(null);
} else {
final List<IProject> erlProjects = new ArrayList<>();
final Set<IProject> projectsWithSpecifics = new HashSet<>();
final IErlModel model = ErlangEngine.getInstance().getModel();
try {
for (final IErlProject ep : model.getErlangProjects()) {
final IProject p = ep.getWorkspaceProject();
if (hasProjectSpecificOptions(p)) {
projectsWithSpecifics.add(p);
}
erlProjects.add(p);
}
} catch (final ErlModelException e) {
}
final ProjectSelectionDialog dialog = new ProjectSelectionDialog(getShell(), erlProjects, projectsWithSpecifics);
if (dialog.open() == Window.OK) {
final IProject res = (IProject) dialog.getFirstResult();
openProjectProperties(res);
}
}
}
use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class ErlangExternalEditorInputFactory method createElement.
@Override
public IAdaptable createElement(final IMemento memento) {
// Get the file name.
final String externalModulePath = memento.getString(ErlangExternalEditorInputFactory.TAG_EXTERNAL_MODULE_PATH);
if (externalModulePath == null) {
return null;
}
IErlModule module;
try {
final IErlModel model = ErlangEngine.getInstance().getModel();
module = ErlangEngine.getInstance().getModelUtilService().getModuleFromExternalModulePath(model, externalModulePath);
} catch (final ErlModelException e1) {
return null;
}
if (module == null) {
return null;
}
// Get the file name.
final String uriString = memento.getString(ErlangExternalEditorInputFactory.TAG_URI);
if (uriString == null) {
return null;
}
URI uri;
try {
uri = new URI(uriString);
} catch (final URISyntaxException e) {
return null;
}
try {
return new ErlangExternalEditorInput(EFS.getStore(uri), module);
} catch (final CoreException e) {
return null;
}
}
use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class WranglerUtils method notifyErlide.
/**
* Notifies Erlide about the changed files.
*
* @param changedFiles
* changed files
*/
public static void notifyErlide(final List<ChangedFile> changedFiles) {
final IErlModel model = ErlangEngine.getInstance().getModel();
for (final ChangedFile f : changedFiles) {
IFile file;
try {
file = WranglerUtils.getFileFromPath(f.getNewPath());
final IErlElement element = model.findElement(file);
final IErlModule m = (IErlModule) element;
m.resourceChanged(null);
final IEditorPart editor = GlobalParameters.getEditor();
if (editor instanceof ErlangEditor) {
((ErlangEditor) editor).resetAndCacheScannerAndParser();
}
model.notifyChange(m);
} catch (final Exception e) {
ErlLogger.error(e);
}
}
}
use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class AbstractErlSelection method getSearchPath.
@Override
public OtpErlangList getSearchPath() {
final IProject project = file.getProject();
final IErlModel model = ErlangEngine.getInstance().getModel();
final IErlProject actualProject = model.getErlangProject(project);
final IPath projectLocation = actualProject.getWorkspaceProject().getLocation();
final Collection<IPath> sourcDirs = actualProject.getProperties().getSourceDirs();
final OtpErlangString[] searchPath = new OtpErlangString[sourcDirs.size()];
int i = 0;
for (final IPath src : sourcDirs) {
searchPath[i++] = new OtpErlangString(projectLocation.append(src).toOSString());
}
return new OtpErlangList(searchPath);
}
use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class ErlModelUtils method getModule.
public static IErlModule getModule(final IEditorInput editorInput) throws CoreException {
if (editorInput instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) editorInput;
final IFile file = input.getFile();
final IErlModel model = ErlangEngine.getInstance().getModel();
IErlModule module = model.findModule(file);
if (module != null) {
return module;
}
final IPath path = file.getLocation();
Charset encoding;
try {
encoding = Charset.forName(file.getCharset());
} catch (Exception e) {
encoding = Charsets.UTF_8;
}
module = model.getModuleFromFile(model, file.getName(), path, encoding);
module.setResource(file);
return module;
}
if (editorInput instanceof ErlangExternalEditorInput) {
final ErlangExternalEditorInput erlangExternalEditorInput = (ErlangExternalEditorInput) editorInput;
return erlangExternalEditorInput.getModule();
}
final String path = ErlModelUtils.getPathForInput(editorInput);
if (path == null) {
return null;
}
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule module = ErlangEngine.getInstance().getModelFindService().findModule(model, null, null, path, IErlElementLocator.Scope.ALL_PROJECTS);
if (module != null) {
return module;
}
final Charset encoding = ErlModelUtils.getEncodingForInput(editorInput);
final IPath p = new Path(path);
return ErlangEngine.getInstance().getModel().getModuleFromFile(null, p.lastSegment(), p, encoding);
}
Aggregations