Context () { final HistoryElement context = myModel.getSelectedItem(); if (context == null || context.expression == null) { final Set<Namespace> cache = myNamespaceCache != null ? myNamespaceCache : Collections.emptySet(); return new Context(new HistoryElement(myDocument.getText(), Collections.emptySet(), cache), getMode()); } final Collection<Namespace> namespaces = myNamespaceCache != null ? merge(myNamespaceCache, context.namespaces, false) : context.namespaces; return new Context(new HistoryElement(context.expression, context.variables, namespaces), getMode()); }