InputEditorUtil.getLineWithCursorPosition(input_);
// lookup function definition at this location
// delayed progress indicator
final GlobalProgressDelayer progress = new GlobalProgressDelayer(
globalDisplay_, 1000, "Searching for function definition...");
server_.getFunctionDefinition(
lineWithPos.getLine(),
lineWithPos.getPosition(),
new ServerRequestCallback<FunctionDefinition>() {
@Override
public void onResponseReceived(FunctionDefinition def)
{
// dismiss progress
progress.dismiss();
// if we got a hit
if (def.getFunctionName() != null)
{
// search locally if a function navigator was provided
if (navigableSourceEditor_ != null)
{
// try to search for the function locally
SourcePosition position =
navigableSourceEditor_.findFunctionPositionFromCursor(
def.getFunctionName());
if (position != null)
{
navigableSourceEditor_.navigateToPosition(position,
true);
return; // we're done
}
}
// if we didn't satisfy the request using a function
// navigator and we got a file back from the server then
// navigate to the file/loc
if (def.getFile() != null)
{
fileTypeRegistry_.editFile(def.getFile(),
def.getPosition());
}
// if we didn't get a file back see if we got a
// search path definition
else if (def.getSearchPathFunctionDefinition() != null)
{
eventBus_.fireEvent(new CodeBrowserNavigationEvent(
def.getSearchPathFunctionDefinition()));
}
}
}
@Override
public void onError(ServerError error)
{
progress.dismiss();
globalDisplay_.showErrorMessage("Error Searching for Function",
error.getUserMessage());
}
});