use of org.erlide.engine.model.erlang.ISourceReference in project erlide_eclipse by erlang.
the class ErlangEditor method setSelection.
public void setSelection(final IErlElement element) {
if (element == null || element instanceof IErlModule) {
return;
}
if (element instanceof ISourceReference) {
final ISourceReference reference = (ISourceReference) element;
// set highlight range
setSelection(reference, true);
if (myOutlinePage != null) {
myOutlinePage.select(reference);
}
}
}
use of org.erlide.engine.model.erlang.ISourceReference in project erlide_eclipse by erlang.
the class ErlangEditor method computeHighlightRangeSourceReference.
protected ISourceReference computeHighlightRangeSourceReference() {
final ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null) {
return null;
}
final StyledText styledText = sourceViewer.getTextWidget();
if (styledText == null) {
return null;
}
int caret = 0;
if (sourceViewer instanceof ITextViewerExtension5) {
final ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
caret = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
} else {
final int offset = sourceViewer.getVisibleRegion().getOffset();
caret = offset + styledText.getCaretOffset();
}
final IErlElement element = getElementAt(caret, false);
if (!(element instanceof ISourceReference)) {
return null;
}
return (ISourceReference) element;
}
use of org.erlide.engine.model.erlang.ISourceReference in project erlide_eclipse by erlang.
the class ErlangEditor method selectionChanged.
protected void selectionChanged() {
if (getSelectionProvider() == null) {
return;
}
final ISourceReference element = computeHighlightRangeSourceReference();
if (isLinkedToOutlinePage()) {
synchronizeOutlinePage(element);
}
setSelection(element, false);
// updateStatusLine();
}
use of org.erlide.engine.model.erlang.ISourceReference in project erlide_eclipse by erlang.
the class ErlNode method createErlNode.
public static ErlNode createErlNode(final ErlNode parent, final IErlElement element, final IDocument doc) {
int start = 0;
int length = 0;
String name = element.toString();
if (element instanceof IErlModule) {
final IErlModule m = (IErlModule) element;
length = doc.getLength();
name = m.getModuleName();
} else if (element instanceof ISourceReference) {
final ISourceReference sourceReference = (ISourceReference) element;
final ISourceRange sr = sourceReference.getSourceRange();
start = sr.getOffset();
length = sr.getLength();
}
return new ErlNode(parent, element.getKind(), name, ErlangCompareUtilities.getErlElementID(element), doc, start, length);
}
use of org.erlide.engine.model.erlang.ISourceReference in project erlide_eclipse by erlang.
the class DefaultErlangFoldingStructureProvider method computeProjectionRanges.
// private boolean isInnerType(IType type) {
// return type.getDeclaringType() != null;
// }
/**
* Computes the projection ranges for a given <code>IErlElement</code>. More
* than one range may be returned if the element has a leading comment which
* gets folded separately. If there are no foldable regions,
* <code>null</code> is returned.
*
* @param element
* the erlang element that can be folded
* @return the regions to be folded, or <code>null</code> if there are none
*/
private IRegion computeProjectionRanges(final IErlElement element) {
if (element instanceof ISourceReference) {
final ISourceReference reference = (ISourceReference) element;
final ISourceRange range = reference.getSourceRange();
return new Region(range.getOffset(), range.getLength());
}
return null;
}
Aggregations