private Lookup getAppliedContext(String command, Lookup context) {
if (context == null) {
return commandStringLookup(command);
}
NbCommandString currentNbCommandStr = context.lookup(NbCommandString.class);
if (currentNbCommandStr == null) {
return new ProxyLookup(commandStringLookup(command), context);
}
NbCommandString nbCommandString = new NbCommandString(command);
if (nbCommandString.equals(currentNbCommandStr)) {
return context;
}
return new ProxyLookup(Lookups.singleton(nbCommandString), context);
}