if (path != null) {
String filename = path.toOSString();
IDocument document = viewer.getDocument();
CodeContext codeContext = codeContexts.get(filename);
int linenumber = 0;
try {
// the following starts on line 0?, so we add 1 to the result
linenumber = document.getLineOfOffset(offset) + 1;
} catch (BadLocationException e1) {
Activator.logError(e1);
}
if (codeContext == null) {
try {
codeContext = CodeContext.getCodeContext(filename, document.get());
} catch (IOException | CommonException e) {
Activator.logError(e);
}
}
String prefix = lastWord(document, offset);
String indent = lastIndent(document, offset);
String line = document.get().split("\\r?\\n")[linenumber];
if (codeContext != null) {
List<Node> units = codeContext.getCompletionsForString(line, prefix, linenumber);
for (Node unit : units) {
IContextInformation info = new ContextInformation(unit.getDocumentation(),
unit.getDocumentation());