use of org.erlide.engine.model.erlang.IErlAttribute in project erlide_eclipse by erlang.
the class ErlModule method getIncludeFiles.
@Override
public Collection<ErlangIncludeFile> getIncludeFiles() throws ErlModelException {
if (!isStructureKnown()) {
open(null);
}
final List<ErlangIncludeFile> r = Lists.newArrayList();
synchronized (getModelLock()) {
for (final IErlElement m : internalGetChildren()) {
if (m instanceof IErlAttribute) {
final IErlAttribute a = (IErlAttribute) m;
final OtpErlangObject v = a.getValue();
if (v instanceof OtpErlangString) {
final String s = ((OtpErlangString) v).stringValue();
if ("include".equals(a.getName())) {
r.add(new ErlangIncludeFile(false, s));
} else if ("include_lib".equals(a.getName())) {
r.add(new ErlangIncludeFile(true, s));
}
}
}
}
}
return r;
}
use of org.erlide.engine.model.erlang.IErlAttribute in project erlide_eclipse by erlang.
the class ErlParser method addOtherAttribute.
private IErlAttribute addOtherAttribute(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val, final OtpErlangObject extra, final String nameS) {
// user-defined attribute? or maybe if else endif...
// OtpErlangObject val1 = concreteTerm(val);
// if (val instanceof OtpErlangList) {
// final OtpErlangList list = (OtpErlangList) val;
// if (list.arity() == 0) {
// val1 = null;
// }
// }
// final ErlAttribute a = new ErlAttribute(parent, nameS, val1, null);
OtpErlangObject o = val;
if (o instanceof OtpErlangAtom) {
final OtpErlangAtom u = (OtpErlangAtom) o;
if ("u".equals(u.atomValue())) {
o = null;
}
}
final ErlAttribute a = new ErlAttribute(module, nameS, o, Util.stringValue(extra));
setPos(a, pos);
// a.setParseTree(val);
return a;
}
use of org.erlide.engine.model.erlang.IErlAttribute in project erlide_eclipse by erlang.
the class ErlangEditor method setSelection.
public void setSelection(final ISourceReference reference, final boolean moveCursor) {
if (getSelectionProvider() == null) {
return;
}
final ISelection selection = getSelectionProvider().getSelection();
if (selection instanceof TextSelection) {
final TextSelection textSelection = (TextSelection) selection;
if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0)) {
markInNavigationHistory();
}
}
if (reference != null) {
StyledText textWidget = null;
final ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null) {
return;
}
textWidget = sourceViewer.getTextWidget();
if (textWidget == null) {
return;
}
try {
ISourceRange range = null;
range = reference.getSourceRange();
if (range == null) {
return;
}
int offset = range.getOffset();
int length = range.getLength();
if (offset < 0 || length < 0) {
return;
}
setHighlightRange(offset, length, moveCursor);
if (!moveCursor) {
return;
}
offset = -1;
length = -1;
if (reference instanceof IErlMember) {
range = ((IErlMember) reference).getNameRange();
if (range != null) {
offset = range.getOffset();
length = range.getLength();
}
} else if (reference instanceof IErlAttribute) {
range = ((IErlAttribute) reference).getNameRange();
if (range != null) {
offset = range.getOffset();
length = range.getLength();
}
} else if (reference instanceof IErlFunctionClause) {
range = ((IErlFunctionClause) reference).getNameRange();
if (range != null) {
offset = range.getOffset();
length = range.getLength();
}
}
if (offset > -1 && length > 0) {
try {
textWidget.setRedraw(false);
sourceViewer.revealRange(offset, length);
sourceViewer.setSelectedRange(offset, length);
} finally {
textWidget.setRedraw(true);
}
markInNavigationHistory();
}
} catch (final IllegalArgumentException x) {
}
} else if (moveCursor) {
resetHighlightRange();
markInNavigationHistory();
}
}
Aggregations