use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangCompletionService method addFunctionsFromModule.
boolean addFunctionsFromModule(final int offset, final String prefix, final boolean arityOnly, final List<CompletionData> proposals, final IErlModule m) {
boolean result = false;
try {
m.open(null);
for (final IErlElement e : m.getChildren()) {
if (e instanceof IErlFunction) {
final IErlFunction f = (IErlFunction) e;
if (f.isExported()) {
addFunctionCompletion(offset, prefix, proposals, f, arityOnly);
result = true;
}
}
}
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
return result;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlParser method attachFunctionComments.
/**
* attach local function documentation with heuristics: if a comment is within 3 lines
* before function, or a sequence of comment, -spec, comment, then they should be
* added to function documentation
*
* If any typespec is available for the function (wherever it is located), then it
* should be attached too.
*
* @param module
*/
private void attachFunctionComments(final IErlModule module) {
// TODO rewrite in Erlang? would be so much less code...
try {
final Collection<IErlComment> comments = module.getComments();
final List<IErlElement> children = module.getChildren();
final List<IErlMember> all = Lists.newArrayListWithCapacity(children.size() + comments.size());
all.addAll(comments);
for (final IErlElement element : children) {
if (element instanceof IErlMember) {
all.add((IErlMember) element);
}
}
all.sort(new SourceOffsetComparator());
for (int i = 1; i < all.size(); i++) {
checkForComment(all, i);
}
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangLineBreakpointPropertyPage method createTypeSpecificLabels.
@Override
protected void createTypeSpecificLabels(final Composite parent) {
createLabel(parent, "Module:");
final String moduleName = getBreakpoint().getMarker().getResource().getName();
createText(parent, SWT.READ_ONLY, moduleName).setBackground(parent.getBackground());
// Line number
final ILineBreakpoint breakpoint = (ILineBreakpoint) getBreakpoint();
final StringBuilder lineNumber = new StringBuilder(4);
try {
final int lNumber = breakpoint.getLineNumber();
if (lNumber > 0) {
lineNumber.append(lNumber);
}
} catch (final CoreException ce) {
ErlLogger.error(ce);
}
if (lineNumber.length() > 0) {
createLabel(parent, "&Line Number:");
final String string = lineNumber.toString();
createText(parent, SWT.READ_ONLY, string).setBackground(parent.getBackground());
}
final IErlElement element = BreakpointUtils.getElement(breakpoint);
if (element == null) {
return;
}
createLabel(parent, "Function:");
createText(parent, SWT.READ_ONLY, element.toString()).setBackground(parent.getBackground());
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangLinkHelperAction method activateEditor.
@Override
public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) {
final Object element = selection.getFirstElement();
final IEditorPart part = EditorUtility.isOpenInEditor(element);
if (part != null) {
page.bringToTop(part);
if (element instanceof IErlElement) {
EditorUtility.revealInEditor(part, (IErlElement) element);
}
}
// if (selection == null || selection.isEmpty()) {
// return;
// }
//
// final Object firstElement = selection.getFirstElement();
//
// if (firstElement instanceof IErlElement) {
// final IErlElement e = (IErlElement) firstElement;
//
// }
// // if it is an erlang element, let's first get the actual object for
// // finding the editor
//
// // and now, if it is really a file...
// if (firstElement instanceof IFile) {
// final IEditorInput fileInput = new FileEditorInput(
// (IFile) firstElement);
// IEditorPart editor = null;
// if ((editor = page.findEditor(fileInput)) != null) {
// page.bringToTop(editor);
// }
// }
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlangFileLabelProvider method getImage.
@Override
public Image getImage(final Object element) {
if (element instanceof IErlElement) {
final IErlElement e = (IErlElement) element;
final ImageDescriptor desc = ErlangElementImageProvider.getErlImageDescriptor(e, ErlangElementImageProvider.SMALL_ICONS);
final Image img = ErlideUIPlugin.getImageDescriptorRegistry().get(desc);
return fProblemDecorator.decorateImage(img, e);
}
return null;
}
Aggregations