QuerySpecification createQuery(IModelElement element) throws ModelException {
    DLTKSearchScopeFactory factory = DLTKSearchScopeFactory.getInstance();
    ScriptEditor editor = getEditor();

    IDLTKSearchScope scope;
    String description;
    boolean isInsideInterpreterEnvironment = true;
    if (editor != null) {
      scope =
          factory.createProjectSearchScope(editor.getEditorInput(), isInsideInterpreterEnvironment);
      description =
          factory.getProjectScopeDescription(
              editor.getEditorInput(), isInsideInterpreterEnvironment);
    } else {
      scope =
          factory.createProjectSearchScope(
              element.getScriptProject(), isInsideInterpreterEnvironment);
      description =
          factory.getProjectScopeDescription(
              element.getScriptProject(), isInsideInterpreterEnvironment);
    }
    return new ElementQuerySpecification(element, getLimitTo(), scope, description);
  }