41#include "wasphit/HITInterpreter.h"
42#include "waspcore/utils.h"
43#include "waspplot/CustomPlotSerialization.h"
52 : _moose_app(moose_app),
53 _connection(
std::make_shared<wasp::lsp::IOStreamConnection>(this)),
54 _formatting_tab_size(0),
55 _dist_plot_num_points(200),
56 _dist_plot_quantile_bound(1e-3)
66 enableExtension(
"plotting");
67 enableExtension(
"watcherRegistration");
78 std::string parse_file_path = document_path;
79 pcrecpp::RE(
"(.*://)(.*)").Replace(
"\\2", &parse_file_path);
84 const auto diagnostic = [
this, &diagnosticsList, &pass](
const std::string & message,
86 const int start_column,
87 const std::optional<int> end_line = {},
88 const std::optional<int> end_column = {})
90 diagnosticsList.push_back(wasp::DataObject());
91 auto & diagnostic = *diagnosticsList.back().to_object();
92 pass &= wasp::lsp::buildDiagnosticObject(diagnostic,
96 end_line ? *end_line : start_line,
97 end_column ? *end_column : start_column,
105 const auto zero_line_diagnostic = [&diagnostic](
const std::string & message)
106 { diagnostic(message, 0, 0); };
109 const auto hit_node_diagnostic = [&zero_line_diagnostic, &diagnostic, &parse_file_path](
110 const hit::Node *
const node,
const std::string & message)
113 if (!node || node->isRoot() || node->filename() != parse_file_path || !node->line() ||
115 zero_line_diagnostic(message);
118 diagnostic(message, node->line() - 1, node->column() - 1);
122 const auto hit_error_message_diagnostic =
123 [&diagnostic, &zero_line_diagnostic, &parse_file_path](
const hit::ErrorMessage & err)
126 if (err.filename && *err.filename == parse_file_path)
129 if (err.lineinfo && err.lineinfo->start_line && err.lineinfo->start_column &&
130 err.lineinfo->end_line && err.lineinfo->end_column)
132 diagnostic(err.message,
133 err.lineinfo->start_line - 1,
134 err.lineinfo->start_column - 1,
135 err.lineinfo->end_line - 1,
136 err.lineinfo->end_column - 1);
142 zero_line_diagnostic(err.prefixed_message);
148 const auto try_catch = [&hit_error_message_diagnostic,
149 &hit_node_diagnostic,
150 &zero_line_diagnostic](
const auto & action) ->
bool
162 for (
const auto & error_message : err.error_messages)
163 hit_error_message_diagnostic(error_message);
169 hit_node_diagnostic(err.getNode(), err.what());
172 catch (std::exception & err)
174 zero_line_diagnostic(err.what());
184 if (command_line->hasArgument(
"--language-server"))
185 command_line->removeArgument(
"--language-server");
186 command_line->addArgument(
"--check-input");
187 command_line->addArgument(
"--error-unused");
188 command_line->addArgument(
"--error");
189 command_line->addArgument(
"--color=off");
190 command_line->addArgument(
"--disable-perf-graph-live");
191 command_line->parse();
194 auto parser = std::make_shared<Parser>(parse_file_path, document_text);
195 mooseAssert(parser->getInputFileNames()[0] == parse_file_path,
"Should be consistent");
197 parser->setCommandLineParams(command_line->buildHitParams());
198 parser->setThrowOnError(
true);
201 const bool parse_success = try_catch([&parser]() { parser->parse(); });
205 if (
auto parser_root_ptr = parser->queryRoot();
206 parser_root_ptr && !parser_root_ptr->getNodeView().is_null())
208 auto it_inserted_pair =
_check_state.emplace(document_path, parser);
209 mooseAssert(it_inserted_pair.second,
"Should not already exist");
210 state = &it_inserted_pair.first->second;
222 std::unique_ptr<MooseApp> app =
nullptr;
223 const auto do_build_app = [
this, &parse_file_path, &diagnostic, &parser, &command_line, &app]()
226 const std::string & app_type = parser->getAppType();
232 int error_line_beg = 0, error_char_beg = 0, error_line_end = 0, error_char_end = 0;
233 if (
auto app_type_field = parser->getRoot().find(
"Application/type");
234 app_type_field && app_type_field->filename() == parse_file_path)
236 auto app_type_value = app_type_field->getNodeView().first_child_by_name(
"value");
237 if (!app_type_value.is_null())
239 error_line_beg = app_type_value.line() - 1;
240 error_char_beg = app_type_value.column() - 1;
241 error_line_end = app_type_value.last_line() - 1;
242 error_char_end = app_type_value.last_column();
247 std::vector<std::string> app_types;
249 app_types.push_back(apps_iter.first);
250 const auto message =
"'" + app_type +
"' is not a registered application type. Registered" +
251 " application types are [" + MooseUtils::join(app_types,
", ") +
"].";
254 diagnostic(message, error_line_beg, error_char_beg, error_line_end, error_char_end);
260 app_params.
set<std::shared_ptr<Parser>>(
"_parser") = parser;
261 app_params.
set<std::shared_ptr<CommandLine>>(
"_command_line") = std::move(command_line);
267 if (!try_catch(do_build_app))
278 state->app = std::move(app);
280 if (!try_catch(do_run_app))
297 auto & root = *root_ptr;
300 if (!client_watcher_support)
304 wasp::HITNodeView view_root = root.getNodeView();
305 std::set<std::string> include_paths, filename_vals, resource_uris;
308 view_root.node_pool()->descendant_include_paths(include_paths);
309 for (
const auto & include_path : include_paths)
311 auto normalized = std::filesystem::path(include_path).lexically_normal().string();
313 resource_uris.insert(wasp::lsp::prefixUriScheme(normalized));
318 for (
const auto & filename_val : filename_vals)
320 auto input_path = wasp::lsp::removeUriScheme(document_path);
321 auto input_base = std::filesystem::path(input_path).parent_path();
322 auto fname_path = std::filesystem::path(filename_val);
323 auto fname_absl = fname_path.is_absolute() ? fname_path : (input_base / fname_path);
324 auto normalized = fname_absl.lexically_normal().string();
326 resource_uris.insert(wasp::lsp::prefixUriScheme(normalized));
330 setResourcesForBase(document_path, resource_uris);
337 static const std::set<std::string> filename_types = {
338 "FileName",
"FileNameNoExtension",
"MeshFileName",
"MatrixFileName"};
341 for (
const auto & child : parent)
343 if (child.type() == wasp::OBJECT)
346 wasp::HITNodeView object_node = child;
347 const std::string object_path = object_node.path();
348 wasp::HITNodeView type_node = object_node.first_child_by_name(
"type");
349 const std::string object_type =
350 type_node.is_null() ?
"" : wasp::strip_quotes(hit::extractValue(type_node.data()));
354 std::set<std::string> obj_act_tasks;
358 for (
const auto & child : object_node)
360 if (child.type() == wasp::KEYED_VALUE || child.type() == wasp::ARRAY)
363 wasp::HITNodeView param_node = child;
364 std::string param_name = param_node.name();
370 std::string dirty_type = valid_params.
type(param_name);
372 pcrecpp::RE(
".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace(
"\\1", &clean_type);
375 if (filename_types.count(clean_type))
376 for (
const auto & child : param_node)
377 if (child.type() == wasp::VALUE)
378 filename_vals.insert(child.to_string());
391 bool & is_incomplete,
399 return addSubblocksToList(completionItems,
"/", line, character, line, character,
"",
false);
400 auto & root = *root_ptr;
403 auto is_request_in_open_block = [](wasp::HITNodeView request_context)
405 return request_context.type() == wasp::OBJECT || request_context.type() == wasp::DOCUMENT_ROOT;
407 auto is_request_on_param_decl = [](wasp::HITNodeView request_context)
409 return request_context.type() == wasp::DECL && request_context.has_parent() &&
410 (request_context.parent().type() == wasp::KEYED_VALUE ||
411 request_context.parent().type() == wasp::ARRAY);
413 auto is_request_on_block_decl = [](wasp::HITNodeView request_context)
415 return request_context.type() == wasp::DECL && request_context.has_parent() &&
416 request_context.parent().type() == wasp::OBJECT;
420 wasp::HITNodeView view_root = root.getNodeView();
421 wasp::HITNodeView request_context;
424 if (line + 1 < (
int)view_root.last_line() ||
425 (line + 1 == (
int)view_root.last_line() && character <= (
int)view_root.last_column()))
426 request_context = wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
432 wasp::findNodeUnderLineColumn(view_root, view_root.last_line(), view_root.last_column());
435 wasp::HITNodeView object_context = request_context;
436 while (object_context.type() != wasp::OBJECT && object_context.has_parent())
437 object_context = object_context.parent();
438 if (request_context.type() == wasp::OBJECT_TERM && object_context.has_parent())
439 object_context = object_context.parent();
440 request_context = object_context;
444 if (is_request_in_open_block(request_context))
446 wasp::HITNodeView backup_context = request_context;
447 for (
int backup_char = character; backup_context == request_context && --backup_char > 0;)
448 backup_context = wasp::findNodeUnderLineColumn(request_context, line + 1, backup_char + 1);
449 if (backup_context.type() == wasp::ASSIGN || backup_context.type() == wasp::OVERRIDE_ASSIGN)
450 request_context = backup_context;
454 int replace_line_beg = line;
455 int replace_char_beg = character;
456 int replace_line_end = line;
457 int replace_char_end = character;
458 std::string filtering_prefix;
459 if (request_context.type() == wasp::DECL || request_context.type() == wasp::VALUE)
462 replace_line_beg = request_context.line() - 1;
463 replace_char_beg = request_context.column() - 1;
464 replace_line_end = request_context.last_line() - 1;
465 replace_char_end = request_context.last_column();
466 filtering_prefix = request_context.data();
469 if (is_request_on_block_decl(request_context) && filtering_prefix.empty())
477 const auto & parent_name = request_context.has_parent() ? request_context.parent().name() :
"";
480 wasp::HITNodeView object_context = request_context;
481 while (object_context.type() != wasp::OBJECT && object_context.has_parent())
482 object_context = object_context.parent();
483 if (is_request_on_block_decl(request_context))
484 object_context = object_context.parent();
485 const std::string & object_path = object_context.path();
486 wasp::HITNodeView type_node = object_context.first_child_by_name(
"type");
487 const std::string & object_type =
488 type_node.is_null() ?
"" : wasp::strip_quotes(hit::extractValue(type_node.data()));
491 std::set<std::string> existing_params, existing_subblocks;
498 std::set<std::string> obj_act_tasks;
506 if (is_request_in_open_block(request_context) || is_request_on_param_decl(request_context))
517 if (is_request_in_open_block(request_context) || is_request_on_param_decl(request_context) ||
518 is_request_on_block_decl(request_context))
526 is_request_on_block_decl(request_context));
529 if ((request_context.type() == wasp::VALUE || request_context.type() == wasp::ASSIGN ||
530 request_context.type() == wasp::OVERRIDE_ASSIGN) &&
544 is_incomplete = !pass;
551 std::set<std::string> & existing_params,
552 std::set<std::string> & existing_subblocks)
555 for (
auto itr = parent_node.begin(); itr != parent_node.end(); itr.next())
557 auto child_node = itr.get();
560 if (child_node.type() == wasp::KEYED_VALUE || child_node.type() == wasp::ARRAY)
561 existing_params.insert(child_node.name());
562 else if (child_node.type() == wasp::OBJECT)
563 existing_subblocks.insert(child_node.name());
569 const std::string & object_path,
570 const std::string & object_type,
571 std::set<std::string> & obj_act_tasks)
581 const std::string & object_path,
582 std::set<std::string> & obj_act_tasks)
589 std::string registered_syntax = syntax.
isAssociated(object_path, &is_parent);
595 auto action_range = syntax.
getActions(registered_syntax);
598 for (
auto action_iter = action_range.first; action_iter != action_range.second; action_iter++)
600 const std::string & action_name = action_iter->second._action;
608 if (action_params.
get<
bool>(
"isObjectAction"))
610 std::set<std::string> tasks_by_actions = action_factory.
getTasksByAction(action_name);
611 obj_act_tasks.insert(tasks_by_actions.begin(), tasks_by_actions.end());
615 action_params.
remove(
"isObjectAction");
619 valid_params += action_params;
626 std::string object_type,
627 const std::set<std::string> & obj_act_tasks)
633 if (object_type.empty() && valid_params.
have_parameter<std::string>(
"type") &&
634 !valid_params.
get<std::string>(
"type").empty())
636 object_type = valid_params.
get<std::string>(
"type");
651 const std::string & moose_base = object_params.
getBase();
653 for (
const auto & obj_act_task : obj_act_tasks)
658 valid_params += object_params;
666 if (valid_params.
have_parameter<std::vector<std::string>>(
"_object_params_set_by_action"))
668 auto names = valid_params.
get<std::vector<std::string>>(
"_object_params_set_by_action");
669 for (
const auto & name : names)
673 valid_params.
remove(
"_object_params_set_by_action");
680 const std::set<std::string> & existing_params,
681 int replace_line_beg,
682 int replace_char_beg,
683 int replace_line_end,
684 int replace_char_end,
685 const std::string & filtering_prefix)
690 for (
const auto & valid_params_iter : valid_params)
692 const std::string & param_name = valid_params_iter.first;
694 bool is_private = valid_params.
isPrivate(param_name);
697 if (deprecated || is_private || existing_params.count(param_name))
701 if (param_name.rfind(filtering_prefix, 0) != 0)
705 std::string dirty_type = valid_params.
type(param_name);
708 std::string doc_string = valid_params.
getDocString(param_name);
712 bool is_array = basic_type.compare(0, 6,
"Array:") == 0;
715 pcrecpp::RE(
"(Array:)*(.*)").GlobalReplace(
"\\2", &basic_type);
718 pcrecpp::RE(
".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace(
"\\1", &clean_type);
724 std::string default_value;
736 std::ostringstream oss;
738 default_value = oss.str();
742 if (basic_type ==
"Boolean" && default_value ==
"1")
743 default_value =
"true";
744 else if (basic_type ==
"Boolean" && default_value ==
"0")
745 default_value =
"false";
748 std::string array_quote = is_array && !default_value.empty() ?
"'" :
"";
752 std::string insert_text;
753 if (client_snippet_support && !default_value.empty())
755 text_format = wasp::lsp::m_text_format_snippet;
756 insert_text = param_name +
" = " + array_quote +
"${1:" + default_value +
"}" + array_quote;
760 text_format = wasp::lsp::m_text_format_plaintext;
761 insert_text = param_name +
" = " + array_quote + default_value + array_quote;
766 completionItems.push_back(wasp::DataObject());
767 wasp::DataObject * item = completionItems.back().to_object();
768 pass &= wasp::lsp::buildCompletionObject(*item,
789 const std::string & object_path,
790 int replace_line_beg,
791 int replace_char_beg,
792 int replace_line_end,
793 int replace_char_end,
794 const std::string & filtering_prefix,
795 bool request_on_block_decl)
800 std::set<std::string> syntax_paths_processed;
804 if (metadata.syntax_to_subblocks.empty())
808 std::string syntax_path =
"/" + syntax_path_iter.first;
811 if (!syntax_paths_processed.insert(syntax_path).second)
815 for (std::size_t last_sep; (last_sep = syntax_path.find_last_of(
"/")) != std::string::npos;)
817 std::string subblock_name = syntax_path.substr(last_sep + 1);
818 syntax_path = syntax_path.substr(0, last_sep);
819 metadata.syntax_to_subblocks[syntax_path].insert(subblock_name);
825 auto registered_syntax = syntax.
isAssociated(object_path,
nullptr, metadata.syntax_to_subblocks);
830 if (!registered_syntax.empty() || object_path ==
"/")
833 int text_format = client_snippet_support ? wasp::lsp::m_text_format_snippet
834 : wasp::lsp::m_text_format_plaintext;
836 for (
const auto & subblock_name : metadata.syntax_to_subblocks[registered_syntax])
839 if (subblock_name !=
"*" && subblock_name.rfind(filtering_prefix, 0) != 0)
842 std::string doc_string;
843 std::string insert_text;
847 const std::string full_block_path = object_path +
"/" + subblock_name;
851 if (subblock_name ==
"*")
853 doc_string =
"custom user named block";
854 insert_text = (request_on_block_decl ?
"" :
"[") +
855 std::string(client_snippet_support ?
"${1:" :
"") +
856 (filtering_prefix.size() ? filtering_prefix :
"block_name") +
857 (client_snippet_support ?
"}" :
"") +
"]" + req_params +
"\n " +
858 (client_snippet_support ?
"$0" :
"") +
"\n[]";
859 complete_kind = wasp::lsp::m_comp_kind_variable;
863 doc_string =
"application named block";
864 insert_text = (request_on_block_decl ?
"" :
"[") + subblock_name +
"]" + req_params +
865 "\n " + (client_snippet_support ?
"$0" :
"") +
"\n[]";
866 complete_kind = wasp::lsp::m_comp_kind_struct;
870 completionItems.push_back(wasp::DataObject());
871 wasp::DataObject * item = completionItems.back().to_object();
872 pass &= wasp::lsp::buildCompletionObject(*item,
895 const std::set<std::string> & existing_params,
896 const std::set<std::string> & existing_subblocks,
897 const std::string & param_name,
898 const std::set<std::string> & obj_act_tasks,
899 const std::string & object_path,
900 int replace_line_beg,
901 int replace_char_beg,
902 int replace_line_end,
903 int replace_char_end)
909 std::string dirty_type = valid_params.
type(param_name);
914 pcrecpp::RE(
"(Array:)*(.*)").GlobalReplace(
"\\2", &basic_type);
917 pcrecpp::RE(
".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace(
"\\1", &clean_type);
923 std::map<std::string, std::string> options_and_descs;
926 if (param_name ==
"active" || param_name ==
"inactive")
927 for (
const auto & subblock_name : existing_subblocks)
928 options_and_descs[subblock_name] =
"subblock name";
931 else if (basic_type ==
"Boolean")
933 options_and_descs[
"true"];
934 options_and_descs[
"false"];
944 else if (valid_params.
have_parameter<std::vector<MooseEnum>>(param_name))
945 getEnumsAndDocs(valid_params.
get<std::vector<MooseEnum>>(param_name)[0], options_and_descs);
948 else if (object_path ==
"/Application" && param_name ==
"type")
952 const std::string & app_name = apps_iter.first;
953 const InputParameters & app_params = apps_iter.second->buildParameters();
956 options_and_descs[app_name] = app_description;
961 else if (param_name ==
"type")
966 const std::string & object_name = objects_iter.first;
967 const InputParameters & object_params = objects_iter.second->buildParameters();
971 req_params += req_params.size() ?
"\n" + std::string(client_snippet_support ?
"$0" :
"") :
"";
976 const std::string & moose_base = object_params.
getBase();
979 for (
const auto & obj_act_task : obj_act_tasks)
985 options_and_descs[object_name + req_params] = type_description;
996 if (metadata.type_to_input_paths.empty())
1000 const std::string & type = associated_types_iter.second;
1001 const std::string & path = associated_types_iter.first;
1002 metadata.type_to_input_paths[type].insert(path);
1007 const auto & input_path_iter = metadata.type_to_input_paths.find(clean_type);
1009 if (input_path_iter != metadata.type_to_input_paths.end())
1011 wasp::HITNodeView view_root =
getRoot().getNodeView();
1014 for (
const auto & input_path : input_path_iter->second)
1017 wasp::SIRENInterpreter<> selector;
1018 if (!selector.parseString(input_path))
1020 wasp::SIRENResultSet<wasp::HITNodeView> results;
1021 std::size_t
count = selector.evaluate(view_root, results);
1024 for (std::size_t i = 0; i <
count; i++)
1025 if (results.adapted(i).type() == wasp::OBJECT)
1026 options_and_descs[results.adapted(i).name()] =
"from /" + input_path;
1037 int text_format = client_snippet_support ? wasp::lsp::m_text_format_snippet
1038 : wasp::lsp::m_text_format_plaintext;
1043 for (
const auto & option_and_desc : options_and_descs)
1045 const std::string & insert_text = option_and_desc.first;
1046 const std::string & option_name = insert_text.substr(0, insert_text.find(
'\n'));
1047 const std::string & description = option_and_desc.second;
1050 completionItems.push_back(wasp::DataObject());
1051 wasp::DataObject * item = completionItems.back().to_object();
1052 pass &= wasp::lsp::buildCompletionObject(*item,
1071template <
typename MooseEnumType>
1074 std::map<std::string, std::string> & options_and_descs)
1077 const auto & enum_docs = moose_enum_param.getItemDocumentation();
1080 for (
const auto & item : moose_enum_param.items())
1081 options_and_descs[item.name()] = enum_docs.count(item) ? enum_docs.at(item) :
"";
1086 std::map<std::string, std::string> & options_and_descs)
1094 std::shared_ptr<FEProblemBase> & problem = app_ptr->actionWarehouse().problemBase();
1098 if (param_type ==
"NonlinearVariableName")
1100 for (
const auto i : make_range(problem->numNonlinearSystems()))
1101 for (
const auto & nls_var_name : problem->getNonlinearSystemBase(i).getVariableNames())
1102 options_and_descs[nls_var_name] =
"from NonlinearSystem VariableWarehouse";
1104 else if (param_type ==
"AuxVariableName")
1106 for (
const auto & aux_var_name : problem->getAuxiliarySystem().getVariableNames())
1107 options_and_descs[aux_var_name] =
"from AuxiliarySystem VariableWarehouse";
1109 else if (param_type ==
"VariableName")
1111 for (
const auto i : make_range(problem->numNonlinearSystems()))
1112 for (
const auto & nls_var_name : problem->getNonlinearSystemBase(i).getVariableNames())
1113 options_and_descs[nls_var_name] =
"from NonlinearSystem VariableWarehouse";
1114 for (
const auto & aux_var_name : problem->getAuxiliarySystem().getVariableNames())
1115 options_and_descs[aux_var_name] =
"from AuxiliarySystem VariableWarehouse";
1117 else if (param_type ==
"MaterialPropertyName")
1119 const auto & mat_prop_registry = problem->getMaterialPropertyRegistry();
1120 const std::vector<std::string> mat_prop_names(mat_prop_registry.idsToNamesBegin(),
1121 mat_prop_registry.idsToNamesEnd());
1122 for (
const auto & mat_prop_name : mat_prop_names)
1123 options_and_descs[mat_prop_name] =
"from MaterialPropertyRegistry";
1125 else if (param_type ==
"MaterialName")
1127 for (
const auto & material : problem->getMaterialWarehouse().getObjects())
1128 options_and_descs[material->name()] =
"from MaterialWarehouse";
1130 else if (param_type ==
"FunctionName")
1132 for (
const auto & function : problem->getFunctionWarehouse().getObjects())
1133 options_and_descs[function->name()] =
"from FunctionWarehouse";
1135 else if (param_type ==
"OutputName")
1137 for (
const auto & output_name : app_ptr->getOutputWarehouse().getOutputNames<
Output>())
1138 options_and_descs[output_name] =
"from OutputWarehouse";
1139 for (
const auto & reserved_name : app_ptr->getOutputWarehouse().getReservedNames())
1140 options_and_descs[reserved_name] =
"from reserved names in OutputWarehouse";
1142 else if (param_type ==
"UserObjectName")
1144 std::vector<UserObject *> user_objects;
1145 problem->theWarehouse()
1148 .condition<AttribThread>(0)
1149 .queryIntoUnsorted(user_objects);
1150 for (
const auto & user_object : user_objects)
1151 options_and_descs[user_object->name()] =
"from UserObjectWarehouse";
1166 auto & root = *root_ptr;
1169 wasp::HITNodeView view_root = root.getNodeView();
1170 wasp::HITNodeView request_context =
1171 wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
1174 if (request_context.type() != wasp::VALUE)
1178 std::string param_name = request_context.has_parent() ? request_context.parent().name() :
"";
1179 std::string val_string = request_context.last_as_string();
1182 if (param_name ==
"type" && factory.
isRegistered(val_string))
1188 if (!file_line_info.
isValid() ||
1193 auto location_uri = wasp::lsp::m_uri_prefix + file_line_info.
file();
1196 definitionLocations.push_back(wasp::DataObject());
1197 wasp::DataObject * location = definitionLocations.back().to_object();
1198 return wasp::lsp::buildLocationObject(*location,
1201 file_line_info.
line() - 1,
1203 file_line_info.
line() - 1,
1208 wasp::HITNodeView object_context = request_context;
1209 while (object_context.type() != wasp::OBJECT && object_context.has_parent())
1210 object_context = object_context.parent();
1211 const std::string & object_path = object_context.path();
1212 wasp::HITNodeView type_node = object_context.first_child_by_name(
"type");
1213 const std::string & object_type =
1214 type_node.is_null() ?
"" : wasp::strip_quotes(hit::extractValue(type_node.data()));
1220 std::set<std::string> obj_act_tasks;
1227 [](
const wasp::HITNodeView & l,
const wasp::HITNodeView & r)
1229 const std::string & l_file = l.node_pool()->stream_name();
1230 const std::string & r_file = r.node_pool()->stream_name();
1231 return (l_file < r_file || (l_file == r_file && l.line() < r.line()) ||
1232 (l_file == r_file && l.line() == r.line() && l.column() < r.column()));
1236 for (
const auto & valid_params_iter : valid_params)
1238 if (valid_params_iter.first == param_name)
1241 std::string dirty_type = valid_params.
type(param_name);
1243 pcrecpp::RE(
".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace(
"\\1", &clean_type);
1252 if (location_nodes.empty() && request_context.has_parent() &&
1253 request_context.parent().child_count_by_name(
"decl"))
1254 location_nodes.insert(request_context.parent().first_child_by_name(
"decl"));
1262 const std::string & clean_type,
1263 const std::string & val_string)
1269 if (metadata.type_to_input_paths.empty())
1273 const std::string & type = associated_types_iter.second;
1274 const std::string & path = associated_types_iter.first;
1275 metadata.type_to_input_paths[type].insert(path);
1280 const auto & input_path_iter = metadata.type_to_input_paths.find(clean_type);
1283 if (input_path_iter == metadata.type_to_input_paths.end())
1287 wasp::HITNodeView view_root =
getRoot().getNodeView();
1290 for (
const auto & input_path : input_path_iter->second)
1293 wasp::SIRENInterpreter<> selector;
1294 if (!selector.parseString(input_path))
1296 wasp::SIRENResultSet<wasp::HITNodeView> results;
1297 std::size_t
count = selector.evaluate(view_root, results);
1300 for (std::size_t i = 0; i <
count; i++)
1301 if (results.adapted(i).type() == wasp::OBJECT && results.adapted(i).name() == val_string &&
1302 results.adapted(i).child_count_by_name(
"decl"))
1303 location_nodes.insert(results.adapted(i).first_child_by_name(
"decl"));
1314 for (
const auto & location_nodes_iter : location_nodes)
1317 auto location_uri = wasp::lsp::m_uri_prefix + location_nodes_iter.node_pool()->stream_name();
1320 defsOrRefsLocations.push_back(wasp::DataObject());
1321 wasp::DataObject * location = defsOrRefsLocations.back().to_object();
1322 pass &= wasp::lsp::buildLocationObject(*location,
1325 location_nodes_iter.line() - 1,
1326 location_nodes_iter.column() - 1,
1327 location_nodes_iter.last_line() - 1,
1328 location_nodes_iter.last_column());
1344 auto & root = *root_ptr;
1347 wasp::HITNodeView view_root = root.getNodeView();
1348 wasp::HITNodeView request_context =
1349 wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
1352 if ((request_context.type() != wasp::DECL && request_context.type() != wasp::VALUE) ||
1353 !request_context.has_parent() ||
1354 (request_context.parent().type() != wasp::KEYED_VALUE &&
1355 request_context.parent().type() != wasp::ARRAY))
1359 std::string paramkey = request_context.parent().name();
1360 std::string paramval = request_context.last_as_string();
1363 wasp::HITNodeView object_context = request_context;
1364 while (object_context.type() != wasp::OBJECT && object_context.has_parent())
1365 object_context = object_context.parent();
1366 const std::string object_path = object_context.path();
1367 wasp::HITNodeView type_node = object_context.first_child_by_name(
"type");
1368 const std::string object_type =
1369 type_node.is_null() ?
"" : wasp::strip_quotes(hit::extractValue(type_node.data()));
1373 std::set<std::string> obj_act_tasks;
1377 if (request_context.type() == wasp::VALUE && paramkey ==
"type" &&
1386 else if (request_context.type() == wasp::VALUE && paramkey ==
"type" &&
1392 const std::string & moose_base = object_params.
getBase();
1393 for (
const auto & obj_act_task : obj_act_tasks)
1406 else if (request_context.type() == wasp::VALUE)
1408 std::map<std::string, std::string> options_and_descs;
1415 else if (valid_params.
have_parameter<std::vector<MooseEnum>>(paramkey))
1416 getEnumsAndDocs(valid_params.
get<std::vector<MooseEnum>>(paramkey)[0], options_and_descs);
1417 if (options_and_descs.count(paramval))
1419 display_text = options_and_descs.find(paramval)->second;
1425 else if (request_context.type() == wasp::DECL && valid_params.
getParametersList().count(paramkey))
1431 std::string doc_units = valid_params.
getDocUnit(paramkey);
1432 if (!doc_units.empty())
1433 display_text +=
"\n\nUnits: " + doc_units;
1439 if (!doc_range.empty())
1440 display_text +=
"\n\nRange: " + doc_range;
1451 bool include_declaration)
1459 auto & root = *root_ptr;
1462 wasp::HITNodeView view_root = root.getNodeView();
1463 wasp::HITNodeView request_context =
1464 wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
1467 if ((request_context.type() != wasp::DECL && request_context.type() != wasp::DOT_SLASH &&
1468 request_context.type() != wasp::LBRACKET && request_context.type() != wasp::RBRACKET) ||
1469 !request_context.has_parent() || request_context.parent().type() != wasp::OBJECT)
1473 const std::string & inp_path = request_context.parent().path();
1474 const std::string & inp_name = request_context.parent().name();
1478 if (metadata.input_path_to_types.empty())
1481 const std::string & path = associated_types_iter.first;
1482 const std::string & type = associated_types_iter.second;
1483 metadata.input_path_to_types[path].insert(type);
1488 auto registered_syntax = syntax.
isAssociated(inp_path, &is_parent, metadata.input_path_to_types);
1491 if (is_parent || !metadata.input_path_to_types.count(registered_syntax))
1495 const std::set<std::string> & target_types = metadata.input_path_to_types.at(registered_syntax);
1499 [](
const wasp::HITNodeView & l,
const wasp::HITNodeView & r)
1501 const std::string & l_file = l.node_pool()->stream_name();
1502 const std::string & r_file = r.node_pool()->stream_name();
1503 return (l_file < r_file || (l_file == r_file && l.line() < r.line()) ||
1504 (l_file == r_file && l.line() == r.line() && l.column() < r.column()));
1511 if (match_nodes.empty())
1515 if (include_declaration && request_context.parent().child_count_by_name(
"decl"))
1516 match_nodes.insert(request_context.parent().first_child_by_name(
"decl"));
1524 wasp::HITNodeView view_parent,
1525 const std::string & target_value,
1526 const std::set<std::string> & target_types)
1529 for (
const auto & view_child : view_parent)
1532 if (view_child.type() == wasp::VALUE && view_child.to_string() == target_value)
1535 wasp::HITNodeView object_context = view_child;
1536 while (object_context.type() != wasp::OBJECT && object_context.has_parent())
1537 object_context = object_context.parent();
1538 const std::string object_path = object_context.path();
1539 wasp::HITNodeView type_node = object_context.first_child_by_name(
"type");
1540 const std::string object_type =
1541 type_node.is_null() ?
"" : wasp::strip_quotes(hit::extractValue(type_node.data()));
1545 std::set<std::string> obj_act_tasks;
1549 std::string param_name = view_child.has_parent() ? view_child.parent().name() :
"";
1552 std::string dirty_type = valid_params.
type(param_name);
1554 pcrecpp::RE(
".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace(
"\\1", &clean_type);
1557 if (target_types.count(clean_type))
1558 match_nodes.insert(view_child);
1562 if (!view_child.is_leaf())
1573 std::string parse_file_path = document_path;
1574 pcrecpp::RE(
"(.*://)(.*)").Replace(
"\\2", &parse_file_path);
1577 std::stringstream input_errors, input_stream(getDocumentText());
1578 wasp::DefaultHITInterpreter interpreter(input_errors);
1581 if (!interpreter.parseStream(input_stream, parse_file_path))
1585 if (interpreter.root().is_null())
1589 wasp::HITNodeView view_root = interpreter.root();
1590 int document_start_line = view_root.line() - 1;
1591 int document_start_char = view_root.column() - 1;
1592 int document_last_line = view_root.last_line() - 1;
1593 int document_last_char = view_root.last_column();
1597 std::size_t starting_line = view_root.line() - 1;
1598 std::string document_format =
formatDocument(view_root, starting_line, 0);
1601 document_format.erase(0, 1);
1604 formattingTextEdits.push_back(wasp::DataObject());
1605 wasp::DataObject * item = formattingTextEdits.back().to_object();
1606 bool pass = wasp::lsp::buildTextEditObject(*item,
1608 document_start_line,
1609 document_start_char,
1623 auto collapse_spaces = [](std::string string_copy)
1625 pcrecpp::RE(
"\\s+").Replace(
" ", &string_copy);
1630 std::string format_string;
1633 for (
const auto i : make_range(parent.child_count()))
1636 wasp::HITNodeView child = parent.child_at(i);
1639 auto decl = child.child_count_by_name(
"decl") ? child.first_child_by_name(
"decl").data() :
"";
1642 std::string blank = child.line() > prev_line + 1 ?
"\n" :
"";
1645 if (child.type() == wasp::FILE)
1646 format_string += blank + newline_indent +
MooseUtils::trim(collapse_spaces(child.data()));
1649 else if (child.type() == wasp::COMMENT)
1650 format_string += (child.line() == prev_line ?
" " : blank + newline_indent) +
1654 else if (child.type() == wasp::OBJECT && decl.empty())
1658 else if (child.type() == wasp::OBJECT)
1659 format_string += blank + newline_indent +
"[" + decl +
"]" +
1660 formatDocument(child, prev_line, level + 1) + newline_indent +
"[]";
1663 else if (child.type() == wasp::KEYED_VALUE || child.type() == wasp::ARRAY)
1665 const std::string assign = wasp::is_override(child) ? child.child_at(1).data() :
"=";
1666 const std::string prefix = newline_indent + decl +
" " + assign +
" ";
1668 const std::string render_val = hit::extractValue(child.data());
1669 std::size_t val_column = child.child_count() > 2 ? child.child_at(2).column() : 0;
1670 std::size_t prefix_len = prefix.size() - 1;
1672 format_string += blank + prefix + hit::formatValue(render_val, val_column, prefix_len);
1676 prev_line = child.last_line();
1680 return format_string;
1690 auto & root = *root_ptr;
1692 wasp::HITNodeView view_root = root.getNodeView();
1697 for (
const auto i : make_range(view_root.child_count()))
1700 wasp::HITNodeView view_child = view_root.child_at(i);
1703 std::string name = view_child.name();
1704 int line = view_child.line() - 1;
1705 int column = view_child.column() - 1;
1706 int last_line = view_child.last_line() - 1;
1707 int last_column = view_child.last_column();
1709 std::string detail =
1710 !view_child.first_child_by_name(
"type").is_null()
1711 ? wasp::strip_quotes(hit::extractValue(view_child.first_child_by_name(
"type").data()))
1715 documentSymbols.push_back(wasp::DataObject());
1716 wasp::DataObject * data_child = documentSymbols.back().to_object();
1717 pass &= wasp::lsp::buildDocumentSymbolObject(*data_child,
1719 (name.empty() ?
"void" : name),
1741 wasp::DataObject & data_parent)
1744 if (wasp::is_nested_file(view_parent))
1750 for (
const auto i : make_range(view_parent.child_count()))
1753 wasp::HITNodeView view_child = view_parent.child_at(i);
1756 std::string name = view_child.name();
1757 int line = view_child.line() - 1;
1758 int column = view_child.column() - 1;
1759 int last_line = view_child.last_line() - 1;
1760 int last_column = view_child.last_column();
1762 std::string detail =
1763 !view_child.first_child_by_name(
"type").is_null()
1764 ? wasp::strip_quotes(hit::extractValue(view_child.first_child_by_name(
"type").data()))
1768 wasp::DataObject & data_child = wasp::lsp::addDocumentSymbolChild(data_parent);
1769 pass &= wasp::lsp::buildDocumentSymbolObject(data_child,
1771 (name.empty() ?
"void" : name),
1793 const std::string & param_name,
1794 const std::string & clean_type,
1801 return wasp::lsp::m_comp_kind_event;
1802 else if (param_name ==
"active" || param_name ==
"inactive")
1803 return wasp::lsp::m_comp_kind_class;
1804 else if (clean_type ==
"bool")
1805 return wasp::lsp::m_comp_kind_interface;
1810 return is_param ? wasp::lsp::m_comp_kind_enum : wasp::lsp::m_comp_kind_enum_member;
1811 else if (param_name ==
"type")
1812 return wasp::lsp::m_comp_kind_type_param;
1813 else if (std::find_if(associated_types.begin(),
1814 associated_types.end(),
1815 [&](
const auto & entry)
1816 { return entry.second == clean_type; }) != associated_types.end())
1817 return wasp::lsp::m_comp_kind_reference;
1819 return is_param ? wasp::lsp::m_comp_kind_keyword : wasp::lsp::m_comp_kind_value;
1826 auto is_boolean = [](wasp::HITNodeView symbol_node)
1830 return (iss >> std::boolalpha >> convert && !iss.fail());
1832 auto is_number = [](wasp::HITNodeView symbol_node)
1835 std::istringstream iss(symbol_node.last_as_string());
1836 return (iss >> convert && iss.eof());
1840 if (symbol_node.type() == wasp::OBJECT)
1841 return wasp::lsp::m_symbol_kind_struct;
1842 else if (symbol_node.type() == wasp::FILE)
1843 return wasp::lsp::m_symbol_kind_file;
1844 else if (symbol_node.type() == wasp::ARRAY)
1845 return wasp::lsp::m_symbol_kind_array;
1846 else if (symbol_node.type() == wasp::KEYED_VALUE && symbol_node.name() == std::string(
"type"))
1847 return wasp::lsp::m_symbol_kind_type_param;
1848 else if (symbol_node.type() == wasp::KEYED_VALUE && is_boolean(symbol_node))
1849 return wasp::lsp::m_symbol_kind_boolean;
1850 else if (symbol_node.type() == wasp::KEYED_VALUE && is_number(symbol_node))
1851 return wasp::lsp::m_symbol_kind_number;
1852 else if (symbol_node.type() == wasp::KEYED_VALUE)
1853 return wasp::lsp::m_symbol_kind_key;
1854 else if (symbol_node.type() == wasp::VALUE)
1855 return wasp::lsp::m_symbol_kind_string;
1857 return wasp::lsp::m_symbol_kind_property;
1862 const std::string & subblock_type,
1863 const std::set<std::string> & existing_params,
1864 const std::string & indent_spaces)
1868 std::set<std::string> obj_act_tasks;
1872 std::string required_param_text;
1873 std::size_t param_index = 1;
1877 if (subblock_type.empty() && !subblock_path.empty() && subblock_path.back() ==
'*')
1880 for (
const auto & valid_params_iter : valid_params)
1883 const std::string & param_name = valid_params_iter.first;
1886 !existing_params.count(param_name))
1888 std::string tab_stop = client_snippet_support ?
"$" + std::to_string(param_index++) :
"";
1889 required_param_text +=
"\n" + indent_spaces + param_name +
" = " + tab_stop;
1893 return required_param_text;
1898 const std::string & extensionMethod,
1904 if (extensionMethod ==
"plotting")
1916 auto & root = *root_ptr;
1919 wasp::HITNodeView view_root = root.getNodeView();
1920 wasp::HITNodeView request_context =
1921 wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
1924 wasp::HITNodeView object_context = request_context;
1925 while (object_context.type() != wasp::OBJECT && object_context.has_parent())
1926 object_context = object_context.parent();
1927 const std::string & object_name = object_context.name();
1928 wasp::HITNodeView type_node = object_context.first_child_by_name(
"type");
1929 const std::string & object_type =
1930 type_node.is_null() ?
"" : wasp::strip_quotes(hit::extractValue(type_node.data()));
1938 std::shared_ptr<FEProblemBase> & problem = app_ptr->actionWarehouse().problemBase();
1943 if (problem->hasFunction(object_name))
1947 else if (problem->hasDistribution(object_name))
1956 const std::string & object_name,
1957 const std::string & object_type)
1965 if (pw_func->functionSize() == 0)
1969 std::vector<double> graph_keys, graph_vals;
1970 for (std::size_t i = 0; i < pw_func->functionSize(); i++)
1972 graph_keys.push_back(pw_func->domain(i));
1973 graph_vals.push_back(pw_func->range(i));
1977 std::string plot_title = object_name +
" " + object_type +
" Function";
1978 std::string x_axis_label =
"abscissa values";
1979 std::string y_axis_label =
"ordinate values";
1980 wasp::CustomPlot plot_object;
1981 buildLineGraphPlot(plot_object, plot_title, x_axis_label, y_axis_label, graph_keys, graph_vals);
1982 plotting_responses.push_back(wasp::serializeCustomPlot(plot_object));
1988 const std::string & object_name,
1989 const std::string & object_type)
2000 if (!std::isfinite(min_x) || !std::isfinite(max_x) || max_x <= min_x || !std::isfinite(del_x))
2011 graph_keys[i] = min_x + (i * del_x);
2012 pdf_values[i] = dist.
pdf(graph_keys[i]);
2013 cdf_values[i] = dist.
cdf(graph_keys[i]);
2016 if (!std::isfinite(pdf_values[i]) || !std::isfinite(cdf_values[i]))
2021 auto add_dist_to_plot = [&](
const std::string & dist_type,
const std::vector<double> & graph_vals)
2023 std::string plot_title = object_name +
" " + object_type +
" " + dist_type +
" Distribution";
2024 std::string x_axis_label =
"x values";
2025 std::string y_axis_label = dist_type +
" values";
2026 wasp::CustomPlot plot_object;
2027 buildLineGraphPlot(plot_object, plot_title, x_axis_label, y_axis_label, graph_keys, graph_vals);
2028 plotting_responses.push_back(wasp::serializeCustomPlot(plot_object));
2032 add_dist_to_plot(
"PDF", pdf_values);
2035 add_dist_to_plot(
"CDF", cdf_values);
2040 const std::string & plot_title,
2041 const std::string & x_axis_label,
2042 const std::string & y_axis_label,
2043 const std::vector<double> & graph_keys,
2044 const std::vector<double> & graph_vals)
2047 double min_key = *std::min_element(graph_keys.begin(), graph_keys.end());
2048 double max_key = *std::max_element(graph_keys.begin(), graph_keys.end());
2049 double min_val = *std::min_element(graph_vals.begin(), graph_vals.end());
2050 double max_val = *std::max_element(graph_vals.begin(), graph_vals.end());
2053 double pad_factor = 0.05;
2054 double pad_x_axis = (max_key - min_key) * pad_factor;
2055 double pad_y_axis = (max_val - min_val) * pad_factor;
2056 if (pad_y_axis == 0)
2057 pad_y_axis = pad_factor;
2058 min_key -= pad_x_axis;
2059 max_key += pad_x_axis;
2060 min_val -= pad_y_axis;
2061 max_val += pad_y_axis;
2064 plot_object.title().text(plot_title);
2065 plot_object.title().font().pointsize(18);
2066 plot_object.title().visible(
true);
2067 plot_object.legend().visible(
false);
2070 plot_object.x1Axis().label(x_axis_label);
2071 plot_object.x1Axis().rangeMin(min_key);
2072 plot_object.x1Axis().rangeMax(max_key);
2073 plot_object.x1Axis().scaleType(wasp::CustomPlot::stLinear);
2074 plot_object.x1Axis().labelType(wasp::CustomPlot::ltNumber);
2075 plot_object.x1Axis().labelFont().pointsize(18);
2076 plot_object.x1Axis().tickLabelFont().pointsize(16);
2079 plot_object.y1Axis().label(y_axis_label);
2080 plot_object.y1Axis().rangeMin(min_val);
2081 plot_object.y1Axis().rangeMax(max_val);
2082 plot_object.y1Axis().scaleType(wasp::CustomPlot::stLinear);
2083 plot_object.y1Axis().labelType(wasp::CustomPlot::ltNumber);
2084 plot_object.y1Axis().labelFont().pointsize(18);
2085 plot_object.y1Axis().tickLabelFont().pointsize(16);
2088 auto line_graph = std::make_shared<wasp::CustomPlot::Graph>();
2089 line_graph->keys() = graph_keys;
2090 line_graph->values() = graph_vals;
2091 line_graph->scatterShape(wasp::CustomPlot::ssDisc);
2092 plot_object.series().push_back(line_graph);
2102 mooseAssert(&app_ptr->parser() == parser_ptr,
"App should have this parser");
2104 if (
const auto root_ptr = parser_ptr->queryRoot())
2105 if (!root_ptr->getNodeView().is_null())
2115 return it ==
_check_state.end() ? nullptr : &it->second;
2128 return state ? state->parser.get() :
nullptr;
2134 return const_cast<Parser *
>(std::as_const(*this).queryCheckParser());
2141 return state->app.get();
2148 return const_cast<MooseApp *
>(std::as_const(*this).queryCheckApp());
2156 auto & app = *app_ptr;
2158 mooseAssert(&app.parser() ==
queryCheckParser(),
"Parser should be the app's parser");
2161 mooseError(
"MooseServer::getCheckApp(): App not available");
2183 mooseError(
"MooseServer::getRoot(): Root not available");
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void ErrorVector unsigned int
Specialized factory for generic Action System objects.
std::set< std::string > getTasksByAction(const std::string &action) const
InputParameters getValidParams(const std::string &name)
bool isRegistered(const std::string &app_name) const
Returns a Boolean indicating whether an application type has been registered.
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
const auto & registeredObjects() const
Returns a reference to the map from names to AppFactoryBuildInfo pointers.
static std::unique_ptr< MooseApp > create(const std::string &app_type, const std::vector< std::string > &cli_args={})
Create an app with no input and command line arguments.
static const std::string main_app_name
The name for the "main" moose application.
static AppFactory & instance()
Get the instance of the AppFactory.
All Distributions should inherit from this class.
virtual Real pdf(const Real &x) const =0
Compute the probability with given probability distribution function (PDF) at x.
virtual Real quantile(const Real &y) const =0
Compute the inverse CDF (quantile function) value for given variable value y.
virtual Real cdf(const Real &x) const =0
Compute the cumulative probability with given cumulative probability distribution (CDF) at x.
A MultiMooseEnum object to hold "execute_on" flags.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual Distribution & getDistribution(const std::string &name)
virtual Function & getFunction(const std::string &name, const THREAD_ID tid=0)
Generic factory class for build all sorts of objects.
bool isRegistered(const std::string &obj_name) const
Returns a Boolean indicating whether an object type has been registered.
const auto & registeredObjects() const
Returns a reference to the map from names to RegistryEntryBase pointers.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
FileLineInfo getLineInfo(const std::string &name) const
Gets file and line information where an object was initially registered.
Holds file and line information.
static std::string basicCppType(const std::string &cpp_type)
static std::string buildOutputString(const std::iterator_traits< InputParameters::iterator >::value_type &p)
Base class for MOOSE-based applications.
Syntax & syntax()
Returns a writable reference to the syntax object.
ActionFactory & getActionFactory()
Retrieve a writable reference to the ActionFactory associated with this App.
virtual void run()
Run the application.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
const std::shared_ptr< libMesh::Parallel::Communicator > getCommunicator() const
std::shared_ptr< CommandLine > commandLine() const
Get the command line.
const std::string & type() const
Get the type of this class.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Exception to be thrown whenever we have _throw_on_error set and a mooseError() is emitted.
bool gatherPlottingResponses(wasp::DataArray &plotting_responses, int line, int character)
Build CustomPlot extension responses when method name is plotting.
MooseApp & getCheckApp()
Public interface for writable check app reference with error checks.
void getInputLookupDefinitionNodes(SortedLocationNodes &location_nodes, const std::string &clean_type, const std::string &val_string)
Get set of nodes from associated path lookups matching value string.
int getDocumentSymbolKind(wasp::HITNodeView symbol_node)
Get document symbol kind value that client may use for outline icon.
std::set< wasp::HITNodeView, std::function< bool(const wasp::HITNodeView &, const wasp::HITNodeView &)> > SortedLocationNodes
SortedLocationNodes - type alias for set of nodes sorted by location.
void addObjectsFromWarehouses(const std::string ¶m_type, std::map< std::string, std::string > &options_and_descs)
Supplement completion list with objects in warehouses if applicable.
bool addSubblocksToList(wasp::DataArray &completionItems, const std::string &object_path, int replace_line_beg, int replace_char_beg, int replace_line_end, int replace_char_end, const std::string &filtering_prefix, bool request_on_block_decl)
Add subblocks to completion list for request path, line, and column.
bool parseDocumentForDiagnostics(wasp::DataArray &diagnosticsList)
Parse document for diagnostics - specific to this server implemention.
void buildFuncPlotResponse(wasp::DataArray &plotting_responses, FEProblemBase &problem, const std::string &object_name, const std::string &object_type)
Gather function data, build CustomPlot object, and add to responses.
std::size_t _dist_plot_num_points
_dist_plot_num_points - distribution plot sampling resolution
void getExistingInput(wasp::HITNodeView parent_node, std::set< std::string > &existing_params, std::set< std::string > &existing_subblocks)
Get names of parameters and subblocks specified in given input node.
void getActionParameters(InputParameters &valid_params, const std::string &object_path, std::set< std::string > &obj_act_tasks)
Get all action parameters using requested object path to collection.
const CheckState * queryCheckState() const
void getEnumsAndDocs(MooseEnumType &moose_enum_param, std::map< std::string, std::string > &options_and_descs)
Fill map of all options and descriptions if parameter is moose enum.
std::map< std::string, SyntaxMetadata > _app_type_to_syntax_metadata
_app_type_to_syntax_metadata - syntax metadata per app type map
bool gatherDocumentReferencesLocations(wasp::DataArray &referencesLocations, int line, int character, bool include_declaration)
Gather references locations - specific to this server implemention.
bool addParametersToList(wasp::DataArray &completionItems, const InputParameters &valid_params, const std::set< std::string > &existing_params, int replace_line_beg, int replace_char_beg, int replace_line_end, int replace_char_end, const std::string &filtering_prefix)
Add parameters that were previously gathered to list for completion.
void buildDistPlotResponses(wasp::DataArray &plotting_responses, FEProblemBase &problem, const std::string &object_name, const std::string &object_type)
Compute PDF and CDF, build CustomPlot objects, and add to responses.
bool gatherDocumentDefinitionLocations(wasp::DataArray &definitionLocations, int line, int character)
Gather definition locations - specific to this server implemention.
std::size_t _formatting_tab_size
_formatting_tab_size - number of indent spaces for formatting
MooseApp & _moose_app
_moose_app - reference to parent application that owns this server
std::map< std::string, CheckState > _check_state
_check_state - map from document paths to state (parser, app, text)
void getObjectParameters(InputParameters &valid_params, std::string object_type, const std::set< std::string > &obj_act_tasks)
Get all object parameters using requested object path to collection.
bool traverseParseTreeAndFillSymbols(wasp::HITNodeView view_parent, wasp::DataObject &data_parent)
Recursively fill document symbols from the given node.
const hit::Node & getRoot() const
bool addValuesToList(wasp::DataArray &completionItems, const InputParameters &valid_params, const std::set< std::string > &existing_params, const std::set< std::string > &existing_subblocks, const std::string ¶m_name, const std::set< std::string > &obj_act_tasks, const std::string &object_path, int replace_line_beg, int replace_char_beg, int replace_line_end, int replace_char_end)
Add parameter values to completion list for request line and column.
std::string formatDocument(wasp::HITNodeView parent, std::size_t &prev_line, std::size_t level)
Recursively walk down whole nodeview tree while formatting document.
void addResourcesForDocument()
Add paths from includes and FileName parameters for client to watch.
std::string getRequiredParamsText(const std::string &subblock_path, const std::string &subblock_type, const std::set< std::string > &existing_params, const std::string &indent_spaces)
Get required parameter completion text list for given subblock path.
void buildLineGraphPlot(wasp::CustomPlot &plot_object, const std::string &plot_title, const std::string &x_axis_label, const std::string &y_axis_label, const std::vector< double > &graph_keys, const std::vector< double > &graph_vals)
Build CustomPlot graph with provided keys, values, and plot title.
void getNodesByValueAndTypes(SortedLocationNodes &match_nodes, wasp::HITNodeView view_parent, const std::string &target_value, const std::set< std::string > &target_types)
Recursively walk input to gather all nodes matching value and types.
MooseServer(MooseApp &moose_app)
int getCompletionItemKind(const InputParameters &valid_params, const std::string ¶m_name, const std::string &clean_type, bool is_param)
Get completion item kind value that client may use for icon in list.
void getFileNameTypeValues(std::set< std::string > &filename_vals, wasp::HITNodeView parent)
Recursively walk input to gather all FileName type parameter values.
bool gatherExtensionResponses(wasp::DataArray &extensionResponses, const std::string &extensionMethod, int line, int character)
Gather extension responses - specific to this server implemention.
const MooseApp * queryCheckApp() const
const Parser * queryCheckParser() const
bool gatherDocumentFormattingTextEdits(wasp::DataArray &formattingTextEdits, int tab_size, bool insert_spaces)
Gather formatting text edits - specific to this server implemention.
bool gatherDocumentCompletionItems(wasp::DataArray &completionItems, bool &is_incomplete, int line, int character)
Gather document completion items - specific to this server implemention.
bool addLocationNodesToList(wasp::DataArray &defsOrRefsLocations, const SortedLocationNodes &location_nodes)
Add set of nodes sorted by location to definition or reference list.
MooseApp & getRegistrationApp()
double _dist_plot_quantile_bound
_dist_plot_quantile_bound - epsilon to bound plot range tails
SyntaxMetadata & getSyntaxMetadata()
const hit::Node * queryRoot() const
bool getHoverDisplayText(std::string &display_text, int line, int character)
Get hover display text - logic specific to this server implemention.
void getAllValidParameters(InputParameters &valid_params, const std::string &object_path, const std::string &object_type, std::set< std::string > &obj_act_tasks)
Get all global parameters, action parameters, and object parameters.
bool gatherDocumentSymbols(wasp::DataArray &documentSymbols)
Gather document symbols - specific to this server implemention.
static InputParameters validParams()
Parameters that are processed directly by the Parser and are valid anywhere in the input.
Scoped helper for setting Moose::_throw_on_error during this scope.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
Based class for output objects.
Class for parsing input files.
Function base which provides a piecewise approximation to a specified (x,y) point data set.
Holding syntax for parsing input files.
std::pair< std::multimap< std::string, ActionInfo >::const_iterator, std::multimap< std::string, ActionInfo >::const_iterator > getActions(const std::string &syntax) const
Returns a pair of multimap iterators to all the ActionInfo objects associated with a given piece of s...
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
std::string isAssociated(const std::string &real_id, bool *is_parent, const std::map< std::string, std::set< std::string > > &alt_map={}) const
Method for determining whether a piece of syntax is associated with an Action an optional syntax map ...
bool verifyMooseObjectTask(const std::string &base, const std::string &task) const
Returns a Boolean indicating whether a task is associated with on of the MOOSE pluggable systems (BAS...
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
void remove(std::string_view)
std::string toLower(std::string name)
Convert supplied string to lower case.
void escape(std::string &str)
std::string trim(const std::string &str, const std::string &white_space=" \t\n\v\f\r")
Standard scripting language trim function.
std::string prettyCppType(const std::string &cpp_type)
bool checkFileReadable(const std::string &filename, bool check_line_endings, bool throw_on_unreadable, bool check_for_git_lfs_pointer)
Helper for storing the state for a single document.