use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class OpenEdocInExternalBrowserAction method run.
/*
* (non-Javadoc) Method declared on SelectionDispatchAction.
*/
@Override
public void run(final IStructuredSelection selection) {
if (input != null) {
final URL url = input.getDocumentationURL();
if (url != null) {
open(url);
}
return;
}
if (!canEnableFor(selection)) {
return;
}
final IErlElement element = (IErlElement) selection.getFirstElement();
run(element);
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangExternalsContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parentElement0) {
Object parentElement = parentElement0;
try {
if (parentElement instanceof IProject) {
final IProject project = (IProject) parentElement;
if (project.isOpen()) {
parentElement = ErlangEngine.getInstance().getModel().findProject(project);
}
}
if (parentElement instanceof IErlModule) {
return erlangFileContentProvider.getChildren(parentElement);
}
if (parentElement instanceof IParent) {
if (parentElement instanceof IOpenable) {
final IOpenable openable = (IOpenable) parentElement;
openable.open(null);
}
final IParent parent = (IParent) parentElement;
final Collection<IErlElement> children = parent.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER);
return children.toArray();
}
} catch (final ErlModelException e) {
}
return ErlangExternalsContentProvider.NO_CHILDREN;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangExternalsContentProvider method getParent.
@Override
public Object getParent(final Object element) {
if (element instanceof IErlElement) {
final IErlElement elt = (IErlElement) element;
IParent parent = elt.getParent();
final String filePath = elt.getFilePath();
if (parent == ErlangEngine.getInstance().getModel() && filePath != null) {
parent = elt.getParent();
}
if (parent instanceof IErlModule) {
final IErlModule mod = (IErlModule) parent;
final IResource resource = mod.getCorrespondingResource();
if (resource != null) {
return resource;
}
} else {
return parent;
}
}
return null;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangFileContentProvider method getChildren.
/**
* Return the model elements for a *.erl IFile or NO_CHILDREN for otherwise.
*/
@Override
public Object[] getChildren(final Object parentElement0) {
Object parentElement = parentElement0;
try {
if (parentElement instanceof IFile) {
parentElement = ErlangEngine.getInstance().getModel().findModule((IFile) parentElement);
}
if (parentElement instanceof IOpenable) {
final IOpenable openable = (IOpenable) parentElement;
openable.open(null);
}
if (parentElement instanceof IParent) {
final IParent parent = (IParent) parentElement;
final Collection<IErlElement> children = parent.getChildren();
return children.toArray();
}
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
return ErlangFileContentProvider.NO_CHILDREN;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class SearchUtil method getSearchPatternFromOpenResultAndLimitTo.
public static ErlangSearchPattern getSearchPatternFromOpenResultAndLimitTo(final IErlModule module, final int offset, final OpenResult res, final LimitTo limitTo, final boolean matchAnyFunctionDefinition) throws ErlModelException {
if (res == null) {
return null;
}
if (res.isLocalCall()) {
String moduleName;
if (module != null) {
moduleName = module.getModuleName();
if (offset != -1) {
final IErlElement e = module.getElementAt(offset);
if (new OpenUtils().isTypeDefOrRecordDef(e, res)) {
return new TypeRefPattern(moduleName, res.getFun(), limitTo);
}
}
} else {
moduleName = res.getName();
}
return new FunctionPattern(moduleName, res.getFun(), res.getArity(), limitTo, matchAnyFunctionDefinition, module, true);
}
String moduleName = res.getName();
if (moduleName == null) {
return null;
}
final String unquoted = StringUtils.unquote(moduleName);
if (res.isExternalCall()) {
if (module != null && offset != -1) {
final IErlElement e = module.getElementAt(offset);
if (e != null && (e.getKind() == ErlElementKind.TYPESPEC || e.getKind() == ErlElementKind.RECORD_DEF)) {
return new TypeRefPattern(moduleName, res.getFun(), limitTo);
}
}
String oldName;
moduleName = unquoted;
do {
oldName = moduleName;
moduleName = ErlangEngine.getInstance().getModelFindService().resolveMacroValue(moduleName, module);
} while (!moduleName.equals(oldName));
return new FunctionPattern(moduleName, res.getFun(), res.getArity(), limitTo, matchAnyFunctionDefinition, module, false);
} else if (res.isMacro()) {
return new MacroPattern(unquoted, limitTo);
} else if (res.isRecord()) {
return new RecordPattern(unquoted, limitTo);
} else if (res.isInclude()) {
return new IncludePattern(moduleName, limitTo);
} else if (res.isVariable()) {
if (module != null) {
if (offset != -1) {
final IErlElement e = module.getElementAt(offset);
if (e instanceof IErlFunctionClause) {
final IErlFunctionClause c = (IErlFunctionClause) e;
return new VariablePattern(c.getFunctionName(), c.getArity(), c.getHead(), res.getName(), limitTo, module);
}
}
}
} else if (res.isField()) {
return new RecordFieldPattern(res.getFun(), unquoted, limitTo);
}
return null;
}
Aggregations