https://mooseframework.inl.gov
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MooseServer Class Reference

#include <MooseServer.h>

Inheritance diagram for MooseServer:
[legend]

Public Member Functions

 MooseServer (MooseApp &moose_app)
 
virtual ~MooseServer ()=default
 
std::shared_ptr< wasp::lsp::Connection > getConnection ()
 Get read / write connection - specific to this server implemention. More...
 

Private Types

using SortedLocationNodes = std::set< wasp::HITNodeView, std::function< bool(const wasp::HITNodeView &, const wasp::HITNodeView &)> >
 SortedLocationNodes - type alias for set of nodes sorted by location. More...
 

Private Member Functions

bool parseDocumentForDiagnostics (wasp::DataArray &diagnosticsList)
 Parse document for diagnostics - specific to this server implemention. More...
 
bool updateDocumentTextChanges (const std::string &replacement_text, int start_line, int start_character, int end_line, int end_character, int range_length)
 Update document text changes - specific to this server implemention. More...
 
bool gatherDocumentCompletionItems (wasp::DataArray &completionItems, bool &is_incomplete, int line, int character)
 Gather document completion items - specific to this server implemention. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 &param_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. More...
 
template<typename MooseEnumType >
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. More...
 
bool gatherDocumentDefinitionLocations (wasp::DataArray &definitionLocations, int line, int character)
 Gather definition locations - specific to this server implemention. More...
 
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. More...
 
bool addLocationNodesToList (wasp::DataArray &defsOrRefsLocations, const SortedLocationNodes &location_nodes)
 Add set of nodes sorted by location to definition or reference list. More...
 
bool getHoverDisplayText (std::string &display_text, int line, int character)
 Get hover display text - logic specific to this server implemention. More...
 
bool gatherDocumentReferencesLocations (wasp::DataArray &referencesLocations, int line, int character, bool include_declaration)
 Gather references locations - specific to this server implemention. More...
 
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. More...
 
bool gatherDocumentFormattingTextEdits (wasp::DataArray &formattingTextEdits, int tab_size, bool insert_spaces)
 Gather formatting text edits - specific to this server implemention. More...
 
std::string formatDocument (wasp::HITNodeView parent, std::size_t &prev_line, std::size_t level)
 Recursively walk down whole nodeview tree while formatting document. More...
 
bool gatherDocumentSymbols (wasp::DataArray &documentSymbols)
 Gather document symbols - specific to this server implemention. More...
 
bool traverseParseTreeAndFillSymbols (wasp::HITNodeView view_parent, wasp::DataObject &data_parent)
 Recursively fill document symbols from the given node. More...
 
int getCompletionItemKind (const InputParameters &valid_params, const std::string &param_name, const std::string &clean_type, bool is_param)
 Get completion item kind value that client may use for icon in list. More...
 
int getDocumentSymbolKind (wasp::HITNodeView symbol_node)
 Get document symbol kind value that client may use for outline icon. More...
 
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. More...
 
bool connectionRead (wasp::DataObject &object)
 Read from connection into object - specific to this server's connection. More...
 
bool connectionWrite (wasp::DataObject &object)
 Write object json to connection - specific to this server's connection. More...
 
bool rootIsValid () const
 
hit::Node & getRoot ()
 
std::shared_ptr< MooseAppgetCheckApp () const
 
const std::string & getDocumentText () const
 

Private Attributes

MooseApp_moose_app
 _moose_app - reference to parent application that owns this server More...
 
std::map< std::string, std::shared_ptr< MooseApp > > _check_apps
 _check_apps - map from document paths to input check applications More...
 
std::map< std::string, std::string > _path_to_text
 _path_to_text - map of document paths to current text strings More...
 
std::shared_ptr< wasp::lsp::IOStreamConnection > _connection
 _connection - shared pointer to this server's read / write iostream More...
 
std::map< std::string, std::set< std::string > > _syntax_to_subblocks
 _syntax_to_subblocks - map of syntax paths to valid subblocks More...
 
std::map< std::string, std::set< std::string > > _type_to_input_paths
 _type_to_input_paths - map of parameter types to lookup paths More...
 
std::map< std::string, std::set< std::string > > _input_path_to_types
 _type_to_input_paths - map of lookup paths to parameter types More...
 
std::size_t _formatting_tab_size
 _formatting_tab_size - number of indent spaces for formatting More...
 

Detailed Description

Definition at line 28 of file MooseServer.h.

Member Typedef Documentation

◆ SortedLocationNodes

using MooseServer::SortedLocationNodes = std::set<wasp::HITNodeView, std::function<bool(const wasp::HITNodeView &, const wasp::HITNodeView &)> >
private

SortedLocationNodes - type alias for set of nodes sorted by location.

Definition at line 47 of file MooseServer.h.

Constructor & Destructor Documentation

◆ MooseServer()

MooseServer::MooseServer ( MooseApp moose_app)

Definition at line 34 of file MooseServer.C.

35  : _moose_app(moose_app),
36  _connection(std::make_shared<wasp::lsp::IOStreamConnection>(this)),
38 {
39  // set server capabilities to receive full input text when changed
40  server_capabilities[wasp::lsp::m_text_doc_sync] = wasp::DataObject();
41  server_capabilities[wasp::lsp::m_text_doc_sync][wasp::lsp::m_open_close] = true;
42  server_capabilities[wasp::lsp::m_text_doc_sync][wasp::lsp::m_change] = wasp::lsp::m_change_full;
43 
44  // notify completion, symbol, formatting, definition capabilities support
45  server_capabilities[wasp::lsp::m_completion_provider] = wasp::DataObject();
46  server_capabilities[wasp::lsp::m_completion_provider][wasp::lsp::m_resolve_provider] = false;
47  server_capabilities[wasp::lsp::m_doc_symbol_provider] = true;
48  server_capabilities[wasp::lsp::m_doc_format_provider] = true;
49  server_capabilities[wasp::lsp::m_definition_provider] = true;
50  server_capabilities[wasp::lsp::m_references_provider] = true;
51  server_capabilities[wasp::lsp::m_hover_provider] = true;
52 }
std::shared_ptr< wasp::lsp::IOStreamConnection > _connection
_connection - shared pointer to this server&#39;s read / write iostream
Definition: MooseServer.h:391
MooseApp & _moose_app
_moose_app - reference to parent application that owns this server
Definition: MooseServer.h:376
std::size_t _formatting_tab_size
_formatting_tab_size - number of indent spaces for formatting
Definition: MooseServer.h:411

◆ ~MooseServer()

virtual MooseServer::~MooseServer ( )
virtualdefault

Member Function Documentation

◆ addLocationNodesToList()

bool MooseServer::addLocationNodesToList ( wasp::DataArray &  defsOrRefsLocations,
const SortedLocationNodes location_nodes 
)
private

Add set of nodes sorted by location to definition or reference list.

Parameters
defsOrRefsLocations- data array of locations objects to fill
location_nodes- set of nodes that have locations to be added
Returns
- true if filling of location objects completed successfully

Definition at line 989 of file MooseServer.C.

Referenced by gatherDocumentDefinitionLocations(), and gatherDocumentReferencesLocations().

991 {
992  bool pass = true;
993 
994  // walk over set of sorted nodes provided to add and build locations list
995  for (const auto & location_nodes_iter : location_nodes)
996  {
997  // add file scheme prefix onto front of file path to build location uri
998  auto location_uri = wasp::lsp::m_uri_prefix + location_nodes_iter.node_pool()->stream_name();
999 
1000  // add file uri with zero based line and column range to locations list
1001  defsOrRefsLocations.push_back(wasp::DataObject());
1002  wasp::DataObject * location = defsOrRefsLocations.back().to_object();
1003  pass &= wasp::lsp::buildLocationObject(*location,
1004  errors,
1005  location_uri,
1006  location_nodes_iter.line() - 1,
1007  location_nodes_iter.column() - 1,
1008  location_nodes_iter.last_line() - 1,
1009  location_nodes_iter.last_column());
1010  }
1011 
1012  return pass;
1013 }

◆ addParametersToList()

bool MooseServer::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 
)
private

Add parameters that were previously gathered to list for completion.

Parameters
completionItems- list of completion objects to be filled out
valid_params- all valid parameters to add to completion list
existing_params- set of parameters already existing in input
replace_line_beg- start line of autocompletion replace range
replace_char_beg- start column of autocomplete replace range
replace_line_end- end line of autocomplete replacement range
replace_char_end- end column of autocompletion replace range
filtering_prefix- beginning text to filter list if not empty
Returns
- true if filling of completion items completed successfully

Definition at line 459 of file MooseServer.C.

Referenced by gatherDocumentCompletionItems().

467 {
468  bool pass = true;
469 
470  // walk over collection of all valid parameters and build completion list
471  for (const auto & valid_params_iter : valid_params)
472  {
473  const std::string & param_name = valid_params_iter.first;
474  bool deprecated = valid_params.isParamDeprecated(param_name);
475  bool is_private = valid_params.isPrivate(param_name);
476 
477  // filter out parameters that are deprecated, private, or already exist
478  if (deprecated || is_private || existing_params.count(param_name))
479  continue;
480 
481  // filter out parameters that do not begin with prefix if one was given
482  if (param_name.rfind(filtering_prefix, 0) != 0)
483  continue;
484 
485  // process parameter description and type to use in input default value
486  std::string dirty_type = valid_params.type(param_name);
487  std::string clean_type = MooseUtils::prettyCppType(dirty_type);
488  std::string basic_type = JsonSyntaxTree::basicCppType(clean_type);
489  std::string doc_string = valid_params.getDocString(param_name);
490  MooseUtils::escape(doc_string);
491 
492  // use basic type to decide if parameter is array and quotes are needed
493  bool is_array = basic_type.compare(0, 6, "Array:") == 0;
494 
495  // remove any array prefixes from basic type string and leave base type
496  pcrecpp::RE("(Array:)*(.*)").GlobalReplace("\\2", &basic_type);
497 
498  // prepare clean cpp type string to be used for key to find input paths
499  pcrecpp::RE(".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace("\\1", &clean_type);
500 
501  // decide completion item kind that client may use to display list icon
502  int complete_kind = getCompletionItemKind(valid_params, param_name, clean_type, true);
503 
504  // default value for completion to be built using parameter information
505  std::string default_value;
506 
507  // first if parameter default is set then use it to build default value
508  if (valid_params.isParamValid(param_name))
509  {
510  default_value = JsonSyntaxTree::buildOutputString(valid_params_iter);
511  default_value = MooseUtils::trim(default_value);
512  }
513 
514  // otherwise if parameter has coupled default then use as default value
515  else if (valid_params.hasDefaultCoupledValue(param_name))
516  {
517  std::ostringstream oss;
518  oss << valid_params.defaultCoupledValue(param_name);
519  default_value = oss.str();
520  }
521 
522  // switch 1 to true or 0 to false if boolean parameter as default value
523  if (basic_type == "Boolean" && default_value == "1")
524  default_value = "true";
525  else if (basic_type == "Boolean" && default_value == "0")
526  default_value = "false";
527 
528  // wrap default value with single quotes if it exists and type is array
529  std::string array_quote = is_array && !default_value.empty() ? "'" : "";
530 
531  // choose format of insertion text based on if client supports snippets
532  int text_format;
533  std::string insert_text;
534  if (client_snippet_support && !default_value.empty())
535  {
536  text_format = wasp::lsp::m_text_format_snippet;
537  insert_text = param_name + " = " + array_quote + "${1:" + default_value + "}" + array_quote;
538  }
539  else
540  {
541  text_format = wasp::lsp::m_text_format_plaintext;
542  insert_text = param_name + " = " + array_quote + default_value + array_quote;
543  }
544  // finally build full insertion from parameter name, quote, and default
545 
546  // add parameter label, insert text, and description to completion list
547  completionItems.push_back(wasp::DataObject());
548  wasp::DataObject * item = completionItems.back().to_object();
549  pass &= wasp::lsp::buildCompletionObject(*item,
550  errors,
551  param_name,
552  replace_line_beg,
553  replace_char_beg,
554  replace_line_end,
555  replace_char_end,
556  insert_text,
557  complete_kind,
558  "",
559  doc_string,
560  false,
561  false,
562  text_format);
563  }
564 
565  return pass;
566 }
static std::string buildOutputString(const std::iterator_traits< InputParameters::iterator >::value_type &p)
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
static std::string basicCppType(const std::string &cpp_type)
Utilities for making sense of c++ types.
int getCompletionItemKind(const InputParameters &valid_params, const std::string &param_name, const std::string &clean_type, bool is_param)
Get completion item kind value that client may use for icon in list.
Definition: MooseServer.C:1426
void escape(std::string &str)
This function will escape all of the standard C++ escape characters so that they can be printed...
Definition: MooseUtils.C:203
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1246

◆ addSubblocksToList()

bool MooseServer::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 
)
private

Add subblocks to completion list for request path, line, and column.

Parameters
completionItems- list of completion objects to be filled out
object_path- full node path where autocomplete was requested
replace_line_beg- start line of autocompletion replace range
replace_char_beg- start column of autocomplete replace range
replace_line_end- end line of autocomplete replacement range
replace_char_end- end column of autocompletion replace range
filtering_prefix- beginning text to filter list if not empty
Returns
- true if filling of completion items completed successfully

Definition at line 569 of file MooseServer.C.

Referenced by gatherDocumentCompletionItems().

577 {
578  Syntax & syntax = getCheckApp()->syntax();
579 
580  // set used to prevent reprocessing syntax paths for more than one action
581  std::set<std::string> syntax_paths_processed;
582 
583  // build map of all syntax paths to names for subblocks and save to reuse
584  if (_syntax_to_subblocks.empty())
585  {
586  for (const auto & syntax_path_iter : syntax.getAssociatedActions())
587  {
588  std::string syntax_path = "/" + syntax_path_iter.first;
589 
590  // skip current syntax path if already processed for different action
591  if (!syntax_paths_processed.insert(syntax_path).second)
592  continue;
593 
594  // walk backward through syntax path adding subblock names to parents
595  for (std::size_t last_sep; (last_sep = syntax_path.find_last_of("/")) != std::string::npos;)
596  {
597  std::string subblock_name = syntax_path.substr(last_sep + 1);
598  syntax_path = syntax_path.substr(0, last_sep);
599  _syntax_to_subblocks[syntax_path].insert(subblock_name);
600  }
601  }
602  }
603 
604  // get registered syntax from object path using map of paths to subblocks
605  std::string registered_syntax = syntax.isAssociated(object_path, nullptr, _syntax_to_subblocks);
606 
607  bool pass = true;
608 
609  // walk over subblock names if found or at root and build completion list
610  if (!registered_syntax.empty() || object_path == "/")
611  {
612  // choose format of insertion text based on if client supports snippets
613  int text_format = client_snippet_support ? wasp::lsp::m_text_format_snippet
614  : wasp::lsp::m_text_format_plaintext;
615 
616  for (const auto & subblock_name : _syntax_to_subblocks[registered_syntax])
617  {
618  // filter subblock if it does not begin with prefix and one was given
619  if (subblock_name != "*" && subblock_name.rfind(filtering_prefix, 0) != 0)
620  continue;
621 
622  std::string doc_string;
623  std::string insert_text;
624  int complete_kind;
625 
626  // build required parameter list for each block to use in insert text
627  const std::string full_block_path = object_path + "/" + subblock_name;
628  const std::string req_params = getRequiredParamsText(full_block_path, "", {}, " ");
629 
630  // customize description and insert text for star and named subblocks
631  if (subblock_name == "*")
632  {
633  doc_string = "custom user named block";
634  insert_text = (request_on_block_decl ? "" : "[") +
635  (filtering_prefix.size() ? filtering_prefix : "block_name") + "]" +
636  req_params + "\n " + (client_snippet_support ? "$0" : "") + "\n[]";
637  complete_kind = wasp::lsp::m_comp_kind_variable;
638  }
639  else
640  {
641  doc_string = "application named block";
642  insert_text = (request_on_block_decl ? "" : "[") + subblock_name + "]" + req_params +
643  "\n " + (client_snippet_support ? "$0" : "") + "\n[]";
644  complete_kind = wasp::lsp::m_comp_kind_struct;
645  }
646 
647  // add subblock name, insert text, and description to completion list
648  completionItems.push_back(wasp::DataObject());
649  wasp::DataObject * item = completionItems.back().to_object();
650  pass &= wasp::lsp::buildCompletionObject(*item,
651  errors,
652  subblock_name,
653  replace_line_beg,
654  replace_char_beg,
655  replace_line_end,
656  replace_char_end,
657  insert_text,
658  complete_kind,
659  "",
660  doc_string,
661  false,
662  false,
663  text_format);
664  }
665  }
666 
667  return pass;
668 }
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
Definition: Syntax.C:374
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.
Definition: MooseServer.C:1495
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 ...
Definition: Syntax.C:251
Holding syntax for parsing input files.
Definition: Syntax.h:21
std::map< std::string, std::set< std::string > > _syntax_to_subblocks
_syntax_to_subblocks - map of syntax paths to valid subblocks
Definition: MooseServer.h:396

◆ addValuesToList()

bool MooseServer::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 &  param_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 
)
private

Add parameter values to completion list for request line and column.

Parameters
completionItems- list of completion objects to be filled out
valid_params- all valid parameters used for value completion
existing_params- set of parameters already existing in input
existing_subblocks- active and inactive subblock name values
param_name- name of input parameter for value autocompletion
obj_act_tasks- tasks to verify object type with valid syntax
object_path- full node path where autocomplete was requested
replace_line_beg- start line of autocompletion replace range
replace_char_beg- start column of autocomplete replace range
replace_line_end- end line of autocomplete replacement range
replace_char_end- end column of autocompletion replace range
Returns
- true if filling of completion items completed successfully

Definition at line 671 of file MooseServer.C.

Referenced by gatherDocumentCompletionItems().

682 {
683  Syntax & syntax = getCheckApp()->syntax();
684  Factory & factory = getCheckApp()->getFactory();
685 
686  // get clean type for path associations and basic type for boolean values
687  std::string dirty_type = valid_params.type(param_name);
688  std::string clean_type = MooseUtils::prettyCppType(dirty_type);
689  std::string basic_type = JsonSyntaxTree::basicCppType(clean_type);
690 
691  // remove any array prefixes from basic type string and replace with base
692  pcrecpp::RE("(Array:)*(.*)").GlobalReplace("\\2", &basic_type);
693 
694  // prepare clean cpp type string to be used for a key to find input paths
695  pcrecpp::RE(".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace("\\1", &clean_type);
696 
697  // decide completion item kind that client may use to display a list icon
698  int complete_kind = getCompletionItemKind(valid_params, param_name, clean_type, false);
699 
700  // map used to gather options and descriptions for value completion items
701  std::map<std::string, std::string> options_and_descs;
702 
703  // first if parameter name is active or inactive then use input subblocks
704  if (param_name == "active" || param_name == "inactive")
705  for (const auto & subblock_name : existing_subblocks)
706  options_and_descs[subblock_name] = "subblock name";
707 
708  // otherwise if parameter type is boolean then use true and false strings
709  else if (basic_type == "Boolean")
710  {
711  options_and_descs["true"];
712  options_and_descs["false"];
713  }
714 
715  // otherwise if parameter type is one of the enums then use valid options
716  else if (valid_params.have_parameter<MooseEnum>(param_name))
717  getEnumsAndDocs(valid_params.get<MooseEnum>(param_name), options_and_descs);
718  else if (valid_params.have_parameter<MultiMooseEnum>(param_name))
719  getEnumsAndDocs(valid_params.get<MultiMooseEnum>(param_name), options_and_descs);
720  else if (valid_params.have_parameter<ExecFlagEnum>(param_name))
721  getEnumsAndDocs(valid_params.get<ExecFlagEnum>(param_name), options_and_descs);
722  else if (valid_params.have_parameter<std::vector<MooseEnum>>(param_name))
723  getEnumsAndDocs(valid_params.get<std::vector<MooseEnum>>(param_name)[0], options_and_descs);
724 
725  // otherwise if parameter name is type then use all verified object names
726  else if (param_name == "type")
727  {
728  // walk over entire set of objects that have been registered in factory
729  for (const auto & objects_iter : factory.registeredObjects())
730  {
731  const std::string & object_name = objects_iter.first;
732  const InputParameters & object_params = objects_iter.second->buildParameters();
733 
734  // build required parameter list for each block to use in insert text
735  std::string req_params = getRequiredParamsText(object_path, object_name, existing_params, "");
736  req_params += !req_params.empty() ? "\n" : "";
737 
738  // check if object has registered base parameter that can be verified
739  if (!object_params.have_parameter<std::string>("_moose_base"))
740  continue;
741  const std::string & moose_base = object_params.get<std::string>("_moose_base");
742 
743  // walk over gathered MooseObjectAction tasks and add if base matches
744  for (const auto & obj_act_task : obj_act_tasks)
745  {
746  if (!syntax.verifyMooseObjectTask(moose_base, obj_act_task))
747  continue;
748  std::string type_description = object_params.getClassDescription();
749  MooseUtils::escape(type_description);
750  options_and_descs[object_name + req_params] = type_description;
751  break;
752  }
753  }
754  }
755 
756  // otherwise if parameter type has any associated syntax then use lookups
757  else
758  {
759  // build map of parameter types to input lookup paths and save to reuse
760  if (_type_to_input_paths.empty())
761  {
762  for (const auto & associated_types_iter : syntax.getAssociatedTypes())
763  {
764  const std::string & type = associated_types_iter.second;
765  const std::string & path = associated_types_iter.first;
766  _type_to_input_paths[type].insert(path);
767  }
768  }
769 
770  // check for input lookup paths that are associated with parameter type
771  const auto & input_path_iter = _type_to_input_paths.find(clean_type);
772 
773  if (input_path_iter != _type_to_input_paths.end())
774  {
775  wasp::HITNodeView view_root = getRoot().getNodeView();
776 
777  // walk over all syntax paths that are associated with parameter type
778  for (const auto & input_path : input_path_iter->second)
779  {
780  // use wasp siren to gather all input values at current lookup path
781  wasp::SIRENInterpreter<> selector;
782  if (!selector.parseString(input_path))
783  continue;
784  wasp::SIRENResultSet<wasp::HITNodeView> results;
785  std::size_t count = selector.evaluate(view_root, results);
786 
787  // walk over results and add each input value found at current path
788  for (std::size_t i = 0; i < count; i++)
789  if (results.adapted(i).type() == wasp::OBJECT)
790  options_and_descs[results.adapted(i).name()] = "from /" + input_path;
791  }
792  }
793  }
794 
795  bool pass = true;
796 
797  // walk over pairs of options with descriptions and build completion list
798  for (const auto & option_and_desc : options_and_descs)
799  {
800  const std::string & insert_text = option_and_desc.first;
801  const std::string & option_name = insert_text.substr(0, insert_text.find('\n'));
802  const std::string & description = option_and_desc.second;
803 
804  // add option name, insertion range, and description to completion list
805  completionItems.push_back(wasp::DataObject());
806  wasp::DataObject * item = completionItems.back().to_object();
807  pass &= wasp::lsp::buildCompletionObject(*item,
808  errors,
809  option_name,
810  replace_line_beg,
811  replace_char_beg,
812  replace_line_end,
813  replace_char_end,
814  insert_text,
815  complete_kind,
816  "",
817  description,
818  false,
819  false,
820  wasp::lsp::m_text_format_plaintext);
821  }
822 
823  return pass;
824 }
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.C:368
std::map< std::string, std::set< std::string > > _type_to_input_paths
_type_to_input_paths - map of parameter types to lookup paths
Definition: MooseServer.h:401
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
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.
Definition: MooseServer.C:1495
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
hit::Node & getRoot()
Definition: MooseServer.C:1528
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
const auto & registeredObjects() const
Returns a reference to the map from names to RegistryEntryBase pointers.
Definition: Factory.h:147
static std::string basicCppType(const std::string &cpp_type)
Utilities for making sense of c++ types.
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
Holding syntax for parsing input files.
Definition: Syntax.h:21
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...
Definition: Syntax.C:334
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
std::string getClassDescription() const
Returns the class description.
int getCompletionItemKind(const InputParameters &valid_params, const std::string &param_name, const std::string &clean_type, bool is_param)
Get completion item kind value that client may use for icon in list.
Definition: MooseServer.C:1426
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.
Definition: MooseServer.C:828
void escape(std::string &str)
This function will escape all of the standard C++ escape characters so that they can be printed...
Definition: MooseUtils.C:203
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1246

◆ connectionRead()

bool MooseServer::connectionRead ( wasp::DataObject &  object)
inlineprivate

Read from connection into object - specific to this server's connection.

Parameters
object- reference to object to be read into
Returns
- true if the read from the connection completed successfully

Definition at line 342 of file MooseServer.h.

342 { return _connection->read(object, errors); }
std::shared_ptr< wasp::lsp::IOStreamConnection > _connection
_connection - shared pointer to this server&#39;s read / write iostream
Definition: MooseServer.h:391

◆ connectionWrite()

bool MooseServer::connectionWrite ( wasp::DataObject &  object)
inlineprivate

Write object json to connection - specific to this server's connection.

Parameters
object- reference to object with contents to write to connection
Returns
- true if the write to the connection completed successfully

Definition at line 349 of file MooseServer.h.

349 { return _connection->write(object, errors); }
std::shared_ptr< wasp::lsp::IOStreamConnection > _connection
_connection - shared pointer to this server&#39;s read / write iostream
Definition: MooseServer.h:391

◆ formatDocument()

std::string MooseServer::formatDocument ( wasp::HITNodeView  parent,
std::size_t &  prev_line,
std::size_t  level 
)
private

Recursively walk down whole nodeview tree while formatting document.

Parameters
parent- nodeview for recursive tree traversal starting point
prev_line- line of last print for blanks and inline comments
level- current level in document tree to use for indentation
Returns
- formatted string that gets appended to each recursive call

Definition at line 1261 of file MooseServer.C.

Referenced by gatherDocumentFormattingTextEdits().

1262 {
1263  // build string of newline and indentation spaces from level and tab size
1264  std::string newline_indent = "\n" + std::string(level * _formatting_tab_size, ' ');
1265 
1266  // lambda to format include data by replacing consecutive spaces with one
1267  auto collapse_spaces = [](std::string string_copy)
1268  {
1269  pcrecpp::RE("\\s+").Replace(" ", &string_copy);
1270  return string_copy;
1271  };
1272 
1273  // formatted string that will be built recursively by appending each call
1274  std::string format_string;
1275 
1276  // walk over all children of this node context and build formatted string
1277  for (const auto i : make_range(parent.child_count()))
1278  {
1279  // walk must be index based to catch file include and skip its children
1280  wasp::HITNodeView child = parent.child_at(i);
1281 
1282  // add blank line if necessary after previous line and before this line
1283  std::string blank = child.line() > prev_line + 1 ? "\n" : "";
1284 
1285  // format include directive with indentation and collapse extra spacing
1286  if (child.type() == wasp::FILE)
1287  format_string += blank + newline_indent + MooseUtils::trim(collapse_spaces(child.data()));
1288 
1289  // format normal comment with indentation and inline comment with space
1290  else if (child.type() == wasp::COMMENT)
1291  format_string += (child.line() == prev_line ? " " : blank + newline_indent) +
1292  MooseUtils::trim(child.data());
1293 
1294  // format object recursively with indentation and without legacy syntax
1295  else if (child.type() == wasp::OBJECT)
1296  format_string += blank + newline_indent + "[" + child.name() + "]" +
1297  formatDocument(child, prev_line, level + 1) + newline_indent + "[]";
1298 
1299  // format keyed value with indentation and calling reusable hit methods
1300  else if (child.type() == wasp::KEYED_VALUE || child.type() == wasp::ARRAY)
1301  {
1302  const std::string prefix = newline_indent + child.name() + " = ";
1303 
1304  const std::string render_val = hit::extractValue(child.data());
1305  std::size_t val_column = child.child_count() > 2 ? child.child_at(2).column() : 0;
1306  std::size_t prefix_len = prefix.size() - 1;
1307 
1308  format_string += blank + prefix + hit::formatValue(render_val, val_column, prefix_len);
1309  }
1310 
1311  // set previous line reference used for blank lines and inline comments
1312  prev_line = child.last_line();
1313  }
1314 
1315  // remove leading newline if this is level zero returning entire document
1316  return level != 0 ? format_string : format_string.substr(1);
1317 }
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
IntRange< T > make_range(T beg, T end)
std::size_t _formatting_tab_size
_formatting_tab_size - number of indent spaces for formatting
Definition: MooseServer.h:411
std::string formatDocument(wasp::HITNodeView parent, std::size_t &prev_line, std::size_t level)
Recursively walk down whole nodeview tree while formatting document.
Definition: MooseServer.C:1261

◆ gatherDocumentCompletionItems()

bool MooseServer::gatherDocumentCompletionItems ( wasp::DataArray &  completionItems,
bool &  is_incomplete,
int  line,
int  character 
)
private

Gather document completion items - specific to this server implemention.

Parameters
completionItems- data array of completion item objects to fill
is_incomplete- flag indicating if the completions are complete
line- line to be used for completions gathering logic
character- column to be used for completions gathering logic
Returns
- true if the gathering of items completed successfully

Definition at line 175 of file MooseServer.C.

179 {
180  // add only root level blocks to completion list when parser root is null
181  if (!rootIsValid())
182  return addSubblocksToList(completionItems, "/", line, character, line, character, "", false);
183 
184  // lambdas that will be used for checking completion request context type
185  auto is_request_in_open_block = [](wasp::HITNodeView request_context) {
186  return request_context.type() == wasp::OBJECT || request_context.type() == wasp::DOCUMENT_ROOT;
187  };
188  auto is_request_on_param_decl = [](wasp::HITNodeView request_context)
189  {
190  return request_context.type() == wasp::DECL && request_context.has_parent() &&
191  (request_context.parent().type() == wasp::KEYED_VALUE ||
192  request_context.parent().type() == wasp::ARRAY);
193  };
194  auto is_request_on_block_decl = [](wasp::HITNodeView request_context)
195  {
196  return request_context.type() == wasp::DECL && request_context.has_parent() &&
197  request_context.parent().type() == wasp::OBJECT;
198  };
199 
200  // get document tree root used to find node under request line and column
201  wasp::HITNodeView view_root = getRoot().getNodeView();
202  wasp::HITNodeView request_context;
203 
204  // find node under request location if it is not past all defined content
205  if (line + 1 < (int)view_root.last_line() ||
206  (line + 1 == (int)view_root.last_line() && character <= (int)view_root.last_column()))
207  request_context = wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
208 
209  // otherwise find last node in document with last line and column of tree
210  else
211  {
212  request_context =
213  wasp::findNodeUnderLineColumn(view_root, view_root.last_line(), view_root.last_column());
214 
215  // change context to be parent block or grandparent if block terminator
216  wasp::HITNodeView object_context = request_context;
217  while (object_context.type() != wasp::OBJECT && object_context.has_parent())
218  object_context = object_context.parent();
219  if (request_context.type() == wasp::OBJECT_TERM && object_context.has_parent())
220  object_context = object_context.parent();
221  request_context = object_context;
222  }
223 
224  // change context to equal sign if it is preceding node and in open block
225  if (is_request_in_open_block(request_context))
226  {
227  wasp::HITNodeView backup_context = request_context;
228  for (int backup_char = character; backup_context == request_context && --backup_char > 0;)
229  backup_context = wasp::findNodeUnderLineColumn(request_context, line + 1, backup_char + 1);
230  if (backup_context.type() == wasp::ASSIGN || backup_context.type() == wasp::OVERRIDE_ASSIGN)
231  request_context = backup_context;
232  }
233 
234  // use request context type to set up replacement range and prefix filter
235  int replace_line_beg = line;
236  int replace_char_beg = character;
237  int replace_line_end = line;
238  int replace_char_end = character;
239  std::string filtering_prefix;
240  if (request_context.type() == wasp::DECL || request_context.type() == wasp::VALUE)
241  {
242  // completion on existing block name, parameter name, or value replaces
243  replace_line_beg = request_context.line() - 1;
244  replace_char_beg = request_context.column() - 1;
245  replace_line_end = request_context.last_line() - 1;
246  replace_char_end = request_context.last_column();
247  filtering_prefix = request_context.data();
248 
249  // empty block name columns are same as bracket so bump replace columns
250  if (is_request_on_block_decl(request_context) && filtering_prefix.empty())
251  {
252  replace_char_beg++;
253  replace_char_end++;
254  }
255  }
256 
257  // get name of request context direct parent node so it can be used later
258  const auto & parent_name = request_context.has_parent() ? request_context.parent().name() : "";
259 
260  // get object context and value of type parameter for request if provided
261  wasp::HITNodeView object_context = request_context;
262  while (object_context.type() != wasp::OBJECT && object_context.has_parent())
263  object_context = object_context.parent();
264  if (is_request_on_block_decl(request_context))
265  object_context = object_context.parent();
266  const std::string & object_path = object_context.path();
267  wasp::HITNodeView type_node = object_context.first_child_by_name("type");
268  const std::string & object_type =
269  type_node.is_null() ? "" : wasp::strip_quotes(hit::extractValue(type_node.data()));
270 
271  // get set of all parameter and subblock names already specified in input
272  std::set<std::string> existing_params, existing_subblocks;
273  getExistingInput(object_context, existing_params, existing_subblocks);
274 
275  // set used to gather all parameters valid from object context of request
276  InputParameters valid_params = emptyInputParameters();
277 
278  // set used to gather MooseObjectAction tasks to verify object parameters
279  std::set<std::string> obj_act_tasks;
280 
281  // get set of global parameters, action parameters, and object parameters
282  getAllValidParameters(valid_params, object_path, object_type, obj_act_tasks);
283 
284  bool pass = true;
285 
286  // add gathered parameters to completion list with input range and prefix
287  if (is_request_in_open_block(request_context) || is_request_on_param_decl(request_context))
288  pass &= addParametersToList(completionItems,
289  valid_params,
290  existing_params,
291  replace_line_beg,
292  replace_char_beg,
293  replace_line_end,
294  replace_char_end,
295  filtering_prefix);
296 
297  // add all valid subblocks to completion list with input range and prefix
298  if (is_request_in_open_block(request_context) || is_request_on_param_decl(request_context) ||
299  is_request_on_block_decl(request_context))
300  pass &= addSubblocksToList(completionItems,
301  object_path,
302  replace_line_beg,
303  replace_char_beg,
304  replace_line_end,
305  replace_char_end,
306  filtering_prefix,
307  is_request_on_block_decl(request_context));
308 
309  // add valid parameter value options to completion list using input range
310  if ((request_context.type() == wasp::VALUE || request_context.type() == wasp::ASSIGN ||
311  request_context.type() == wasp::OVERRIDE_ASSIGN) &&
312  valid_params.getParametersList().count(parent_name))
313  pass &= addValuesToList(completionItems,
314  valid_params,
315  existing_params,
316  existing_subblocks,
317  parent_name,
318  obj_act_tasks,
319  object_path,
320  replace_line_beg,
321  replace_char_beg,
322  replace_line_end,
323  replace_char_end);
324 
325  is_incomplete = !pass;
326 
327  return pass;
328 }
std::set< std::string > getParametersList() 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 &param_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.
Definition: MooseServer.C:671
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.
Definition: MooseServer.C:459
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
bool rootIsValid() const
Definition: MooseServer.C:1521
hit::Node & getRoot()
Definition: MooseServer.C:1528
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.
Definition: MooseServer.C:349
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.
Definition: MooseServer.C:569
void ErrorVector unsigned int
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.
Definition: MooseServer.C:331

◆ gatherDocumentDefinitionLocations()

bool MooseServer::gatherDocumentDefinitionLocations ( wasp::DataArray &  definitionLocations,
int  line,
int  character 
)
private

Gather definition locations - specific to this server implemention.

Parameters
definitionLocations- data array of locations objects to fill
line- line to be used for locations gathering logic
character- column to be used for locations gathering logic
Returns
- true if the gathering of locations completed successfully

Definition at line 840 of file MooseServer.C.

843 {
844  Factory & factory = getCheckApp()->getFactory();
845 
846  // return without any definition locations added when parser root is null
847  if (!rootIsValid())
848  return true;
849 
850  // find hit node for zero based request line and column number from input
851  wasp::HITNodeView view_root = getRoot().getNodeView();
852  wasp::HITNodeView request_context =
853  wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
854 
855  // return without any definition locations added when node not value type
856  if (request_context.type() != wasp::VALUE)
857  return true;
858 
859  // get name of parameter node parent of value and value string from input
860  std::string param_name = request_context.has_parent() ? request_context.parent().name() : "";
861  std::string val_string = request_context.last_as_string();
862 
863  // add source code location if type parameter with registered object name
864  if (param_name == "type" && factory.isRegistered(val_string))
865  {
866  // get file path and line number of source code registering object type
867  FileLineInfo file_line_info = factory.getLineInfo(val_string);
868 
869  // return without any definition locations added if file cannot be read
870  if (!file_line_info.isValid() ||
871  !MooseUtils::checkFileReadable(file_line_info.file(), false, false, false))
872  return true;
873 
874  // add file scheme prefix to front of file path to build definition uri
875  auto location_uri = wasp::lsp::m_uri_prefix + file_line_info.file();
876 
877  // add file uri and zero based line and column range to definition list
878  definitionLocations.push_back(wasp::DataObject());
879  wasp::DataObject * location = definitionLocations.back().to_object();
880  return wasp::lsp::buildLocationObject(*location,
881  errors,
882  location_uri,
883  file_line_info.line() - 1,
884  0,
885  file_line_info.line() - 1,
886  1000);
887  }
888 
889  // get object context and value of type parameter for request if provided
890  wasp::HITNodeView object_context = request_context;
891  while (object_context.type() != wasp::OBJECT && object_context.has_parent())
892  object_context = object_context.parent();
893  const std::string & object_path = object_context.path();
894  wasp::HITNodeView type_node = object_context.first_child_by_name("type");
895  const std::string & object_type =
896  type_node.is_null() ? "" : wasp::strip_quotes(hit::extractValue(type_node.data()));
897 
898  // set used to gather all parameters valid from object context of request
899  InputParameters valid_params = emptyInputParameters();
900 
901  // set used to gather MooseObjectAction tasks to verify object parameters
902  std::set<std::string> obj_act_tasks;
903 
904  // get set of global parameters, action parameters, and object parameters
905  getAllValidParameters(valid_params, object_path, object_type, obj_act_tasks);
906 
907  // set used to gather nodes from input lookups custom sorted by locations
908  SortedLocationNodes location_nodes(
909  [](const wasp::HITNodeView & l, const wasp::HITNodeView & r)
910  {
911  const std::string & l_file = l.node_pool()->stream_name();
912  const std::string & r_file = r.node_pool()->stream_name();
913  return (l_file < r_file || (l_file == r_file && l.line() < r.line()) ||
914  (l_file == r_file && l.line() == r.line() && l.column() < r.column()));
915  });
916 
917  // gather all lookup path nodes matching value if parameter name is valid
918  for (const auto & valid_params_iter : valid_params)
919  {
920  if (valid_params_iter.first == param_name)
921  {
922  // get cpp type and prepare string for use as key finding input paths
923  std::string dirty_type = valid_params.type(param_name);
924  std::string clean_type = MooseUtils::prettyCppType(dirty_type);
925  pcrecpp::RE(".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace("\\1", &clean_type);
926 
927  // get set of nodes from associated path lookups matching input value
928  getInputLookupDefinitionNodes(location_nodes, clean_type, val_string);
929  break;
930  }
931  }
932 
933  // add parameter declarator to set if none were gathered by input lookups
934  if (location_nodes.empty() && request_context.has_parent() &&
935  request_context.parent().child_count_by_name("decl"))
936  location_nodes.insert(request_context.parent().first_child_by_name("decl"));
937 
938  // add locations to definition list using lookups or parameter declarator
939  return addLocationNodesToList(definitionLocations, location_nodes);
940 }
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
bool isRegistered(const std::string &obj_name) const
Returns a Boolean indicating whether an object type has been registered.
Definition: Factory.h:152
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.
Definition: MooseServer.C:943
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
int line() const
Definition: FileLineInfo.C:23
FileLineInfo getLineInfo(const std::string &name) const
Gets file and line information where an object was initially registered.
Definition: Factory.C:260
InputParameters emptyInputParameters()
std::set< wasp::HITNodeView, std::function< bool(const wasp::HITNodeView &, const wasp::HITNodeView &)> > SortedLocationNodes
SortedLocationNodes - type alias for set of nodes sorted by location.
Definition: MooseServer.h:47
bool rootIsValid() const
Definition: MooseServer.C:1521
hit::Node & getRoot()
Definition: MooseServer.C:1528
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:250
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.
Definition: MooseServer.C:349
Holds file and line information.
Definition: FileLineInfo.h:18
std::string file() const
Definition: FileLineInfo.C:29
bool isValid() const
Definition: FileLineInfo.C:17
bool addLocationNodesToList(wasp::DataArray &defsOrRefsLocations, const SortedLocationNodes &location_nodes)
Add set of nodes sorted by location to definition or reference list.
Definition: MooseServer.C:989
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1246

◆ gatherDocumentFormattingTextEdits()

bool MooseServer::gatherDocumentFormattingTextEdits ( wasp::DataArray &  formattingTextEdits,
int  tab_size,
bool  insert_spaces 
)
private

Gather formatting text edits - specific to this server implemention.

Parameters
formattingTextEdits- data array of text edit objects to fill
tab_size- value of the size of a tab in spaces for formatting
insert_spaces- flag indicating whether to use spaces for tabs
Returns
- true if the gathering of text edits completed successfully

Definition at line 1215 of file MooseServer.C.

1218 {
1219  // strip scheme prefix from document uri if it exists for parse file path
1220  std::string parse_file_path = document_path;
1221  pcrecpp::RE("(.*://)(.*)").Replace("\\2", &parse_file_path);
1222 
1223  // input check expanded any brace expressions in cached tree so reprocess
1224  std::stringstream input_errors, input_stream(getDocumentText());
1225  wasp::DefaultHITInterpreter interpreter(input_errors);
1226 
1227  // return without adding any formatting text edits if input parsing fails
1228  if (!interpreter.parseStream(input_stream, parse_file_path))
1229  return true;
1230 
1231  // return without adding any formatting text edits if parser root is null
1232  if (interpreter.root().is_null())
1233  return true;
1234 
1235  // get input root node line and column range to represent entire document
1236  wasp::HITNodeView view_root = interpreter.root();
1237  int document_start_line = view_root.line() - 1;
1238  int document_start_char = view_root.column() - 1;
1239  int document_last_line = view_root.last_line() - 1;
1240  int document_last_char = view_root.last_column();
1241 
1242  // set number of spaces for indentation and build formatted document text
1243  _formatting_tab_size = tab_size;
1244  std::size_t starting_line = view_root.line() - 1;
1245  std::string document_format = formatDocument(view_root, starting_line, 0);
1246 
1247  // add formatted text with whole line and column range to formatting list
1248  formattingTextEdits.push_back(wasp::DataObject());
1249  wasp::DataObject * item = formattingTextEdits.back().to_object();
1250  bool pass = wasp::lsp::buildTextEditObject(*item,
1251  errors,
1252  document_start_line,
1253  document_start_char,
1254  document_last_line,
1255  document_last_char,
1256  document_format);
1257  return pass;
1258 }
const std::string & getDocumentText() const
Definition: MooseServer.C:1542
std::size_t _formatting_tab_size
_formatting_tab_size - number of indent spaces for formatting
Definition: MooseServer.h:411
std::string formatDocument(wasp::HITNodeView parent, std::size_t &prev_line, std::size_t level)
Recursively walk down whole nodeview tree while formatting document.
Definition: MooseServer.C:1261

◆ gatherDocumentReferencesLocations()

bool MooseServer::gatherDocumentReferencesLocations ( wasp::DataArray &  referencesLocations,
int  line,
int  character,
bool  include_declaration 
)
private

Gather references locations - specific to this server implemention.

Parameters
referencesLocations- data array of locations objects to fill
line- line to be used for locations gathering logic
character- column to be used for locations gathering logic
include_declaration- flag indicating declaration inclusion
Returns
- true if the gathering of locations completed successfully

Definition at line 1098 of file MooseServer.C.

1102 {
1103  Syntax & syntax = getCheckApp()->syntax();
1104 
1105  // return without adding any reference locations when parser root is null
1106  if (!rootIsValid())
1107  return true;
1108 
1109  // find hit node for zero based request line and column number from input
1110  wasp::HITNodeView view_root = getRoot().getNodeView();
1111  wasp::HITNodeView request_context =
1112  wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
1113 
1114  // return without adding any references when request not block declarator
1115  if ((request_context.type() != wasp::DECL && request_context.type() != wasp::DOT_SLASH &&
1116  request_context.type() != wasp::LBRACKET && request_context.type() != wasp::RBRACKET) ||
1117  !request_context.has_parent() || request_context.parent().type() != wasp::OBJECT)
1118  return true;
1119 
1120  // get input path and block name of declarator located at request context
1121  const std::string & block_path = request_context.parent().path();
1122  const std::string & block_name = request_context.parent().name();
1123 
1124  // build map from input lookup paths to parameter types and save to reuse
1125  if (_input_path_to_types.empty())
1126  for (const auto & associated_types_iter : syntax.getAssociatedTypes())
1127  {
1128  const std::string & path = associated_types_iter.first;
1129  const std::string & type = associated_types_iter.second;
1130  _input_path_to_types[path].insert(type);
1131  }
1132 
1133  // get registered syntax from block path with map of input paths to types
1134  bool is_parent;
1135  std::string registered_syntax = syntax.isAssociated(block_path, &is_parent, _input_path_to_types);
1136 
1137  // return without adding any references if syntax has no types associated
1138  if (is_parent || !_input_path_to_types.count(registered_syntax))
1139  return true;
1140 
1141  // get set of parameter types which are associated with registered syntax
1142  const std::set<std::string> & target_types = _input_path_to_types.at(registered_syntax);
1143 
1144  // set used to gather nodes collected by value custom sorted by locations
1145  SortedLocationNodes match_nodes(
1146  [](const wasp::HITNodeView & l, const wasp::HITNodeView & r)
1147  {
1148  const std::string & l_file = l.node_pool()->stream_name();
1149  const std::string & r_file = r.node_pool()->stream_name();
1150  return (l_file < r_file || (l_file == r_file && l.line() < r.line()) ||
1151  (l_file == r_file && l.line() == r.line() && l.column() < r.column()));
1152  });
1153 
1154  // walk input recursively and gather all nodes that match value and types
1155  getNodesByValueAndTypes(match_nodes, view_root, block_name, target_types);
1156 
1157  // return without adding any references if no nodes match value and types
1158  if (match_nodes.empty())
1159  return true;
1160 
1161  // add request context node to set if declaration inclusion was specified
1162  if (include_declaration && request_context.parent().child_count_by_name("decl"))
1163  match_nodes.insert(request_context.parent().first_child_by_name("decl"));
1164 
1165  // add locations to references list with nodes that match value and types
1166  return addLocationNodesToList(referencesLocations, match_nodes);
1167 }
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.C:368
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
std::map< std::string, std::set< std::string > > _input_path_to_types
_type_to_input_paths - map of lookup paths to parameter types
Definition: MooseServer.h:406
std::set< wasp::HITNodeView, std::function< bool(const wasp::HITNodeView &, const wasp::HITNodeView &)> > SortedLocationNodes
SortedLocationNodes - type alias for set of nodes sorted by location.
Definition: MooseServer.h:47
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.
Definition: MooseServer.C:1170
bool rootIsValid() const
Definition: MooseServer.C:1521
hit::Node & getRoot()
Definition: MooseServer.C:1528
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 ...
Definition: Syntax.C:251
Holding syntax for parsing input files.
Definition: Syntax.h:21
bool addLocationNodesToList(wasp::DataArray &defsOrRefsLocations, const SortedLocationNodes &location_nodes)
Add set of nodes sorted by location to definition or reference list.
Definition: MooseServer.C:989

◆ gatherDocumentSymbols()

bool MooseServer::gatherDocumentSymbols ( wasp::DataArray &  documentSymbols)
private

Gather document symbols - specific to this server implemention.

Parameters
documentSymbols- data array of symbols data objects to fill
Returns
- true if the gathering of symbols completed successfully

Definition at line 1320 of file MooseServer.C.

1321 {
1322  // return prior to starting document symbol tree when parser root is null
1323  if (!rootIsValid())
1324  return true;
1325 
1326  wasp::HITNodeView view_root = getRoot().getNodeView();
1327 
1328  bool pass = true;
1329 
1330  // walk over all children of root node context and build document symbols
1331  for (const auto i : make_range(view_root.child_count()))
1332  {
1333  // walk must be index based to catch file include and skip its children
1334  wasp::HITNodeView view_child = view_root.child_at(i);
1335 
1336  // set up name, zero based line and column range, kind, and detail info
1337  std::string name = view_child.name();
1338  int line = view_child.line() - 1;
1339  int column = view_child.column() - 1;
1340  int last_line = view_child.last_line() - 1;
1341  int last_column = view_child.last_column();
1342  int symbol_kind = getDocumentSymbolKind(view_child);
1343  std::string detail =
1344  !view_child.first_child_by_name("type").is_null()
1345  ? wasp::strip_quotes(hit::extractValue(view_child.first_child_by_name("type").data()))
1346  : "";
1347 
1348  // build document symbol object from node child info and push to array
1349  documentSymbols.push_back(wasp::DataObject());
1350  wasp::DataObject * data_child = documentSymbols.back().to_object();
1351  pass &= wasp::lsp::buildDocumentSymbolObject(*data_child,
1352  errors,
1353  (name.empty() ? "void" : name),
1354  detail,
1355  symbol_kind,
1356  false,
1357  line,
1358  column,
1359  last_line,
1360  last_column,
1361  line,
1362  column,
1363  last_line,
1364  last_column);
1365 
1366  // call method to recursively fill document symbols for each node child
1367  pass &= traverseParseTreeAndFillSymbols(view_child, *data_child);
1368  }
1369 
1370  return pass;
1371 }
std::string name(const ElemQuality q)
int getDocumentSymbolKind(wasp::HITNodeView symbol_node)
Get document symbol kind value that client may use for outline icon.
Definition: MooseServer.C:1457
bool rootIsValid() const
Definition: MooseServer.C:1521
hit::Node & getRoot()
Definition: MooseServer.C:1528
bool traverseParseTreeAndFillSymbols(wasp::HITNodeView view_parent, wasp::DataObject &data_parent)
Recursively fill document symbols from the given node.
Definition: MooseServer.C:1374
IntRange< T > make_range(T beg, T end)

◆ getActionParameters()

void MooseServer::getActionParameters ( InputParameters valid_params,
const std::string &  object_path,
std::set< std::string > &  obj_act_tasks 
)
private

Get all action parameters using requested object path to collection.

Parameters
valid_params- collection for filling action input parameters
object_path- full node path where autocomplete was requested
obj_act_tasks- set for adding in all MooseObjectAction tasks

Definition at line 361 of file MooseServer.C.

Referenced by getAllValidParameters().

364 {
365  Syntax & syntax = getCheckApp()->syntax();
366  ActionFactory & action_factory = getCheckApp()->getActionFactory();
367 
368  // get registered syntax path identifier using actual object context path
369  bool is_parent;
370  std::string registered_syntax = syntax.isAssociated(object_path, &is_parent);
371 
372  // use is_parent to skip action parameters when not explicitly registered
373  if (!is_parent)
374  {
375  // get action objects associated with registered syntax path identifier
376  auto action_range = syntax.getActions(registered_syntax);
377 
378  // traverse action objects for syntax to gather valid action parameters
379  for (auto action_iter = action_range.first; action_iter != action_range.second; action_iter++)
380  {
381  const std::string & action_name = action_iter->second._action;
382 
383  // use action name to get set of valid parameters from action factory
384  InputParameters action_params = action_factory.getValidParams(action_name);
385 
386  // gather all MooseObjectAction tasks for verifying object parameters
387  if (action_params.have_parameter<bool>("isObjectAction"))
388  {
389  if (action_params.get<bool>("isObjectAction"))
390  {
391  std::set<std::string> tasks_by_actions = action_factory.getTasksByAction(action_name);
392  obj_act_tasks.insert(tasks_by_actions.begin(), tasks_by_actions.end());
393  }
394 
395  // filter parameter from completion list as it is not used in input
396  action_params.remove("isObjectAction");
397  }
398 
399  // add parameters from action to full valid collection being gathered
400  valid_params += action_params;
401  }
402  }
403 }
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...
Definition: Syntax.C:328
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:92
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
std::set< std::string > getTasksByAction(const std::string &action) const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void remove(std::string_view)
Specialized factory for generic Action System objects.
Definition: ActionFactory.h:50
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 ...
Definition: Syntax.C:251
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
Holding syntax for parsing input files.
Definition: Syntax.h:21

◆ getAllValidParameters()

void MooseServer::getAllValidParameters ( InputParameters valid_params,
const std::string &  object_path,
const std::string &  object_type,
std::set< std::string > &  obj_act_tasks 
)
private

Get all global parameters, action parameters, and object parameters.

Parameters
valid_params- collection to fill with valid input parameters
object_path- full node path where autocomplete was requested
object_type- type of object where autocomplete was requested
obj_act_tasks- set for adding in all MooseObjectAction tasks

Definition at line 349 of file MooseServer.C.

Referenced by gatherDocumentCompletionItems(), gatherDocumentDefinitionLocations(), getHoverDisplayText(), getNodesByValueAndTypes(), and getRequiredParamsText().

353 {
354  // gather global parameters then action parameters then object parameters
355  valid_params += Moose::Builder::validParams();
356  getActionParameters(valid_params, object_path, obj_act_tasks);
357  getObjectParameters(valid_params, object_type, obj_act_tasks);
358 }
static InputParameters validParams()
Parameters that are processed directly by the Parser and are valid anywhere in the input...
Definition: Builder.C:141
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.
Definition: MooseServer.C:406
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.
Definition: MooseServer.C:361

◆ getCheckApp()

std::shared_ptr< MooseApp > MooseServer::getCheckApp ( ) const
private
Returns
Input check application for document path from current operation

Definition at line 1535 of file MooseServer.C.

Referenced by addSubblocksToList(), addValuesToList(), gatherDocumentDefinitionLocations(), gatherDocumentReferencesLocations(), getActionParameters(), getCompletionItemKind(), getHoverDisplayText(), getInputLookupDefinitionNodes(), getObjectParameters(), getRoot(), parseDocumentForDiagnostics(), and rootIsValid().

1536 {
1537  mooseAssert(_check_apps.count(document_path), "No check app for path");
1538  return _check_apps.at(document_path);
1539 }
std::map< std::string, std::shared_ptr< MooseApp > > _check_apps
_check_apps - map from document paths to input check applications
Definition: MooseServer.h:381

◆ getCompletionItemKind()

int MooseServer::getCompletionItemKind ( const InputParameters valid_params,
const std::string &  param_name,
const std::string &  clean_type,
bool  is_param 
)
private

Get completion item kind value that client may use for icon in list.

Parameters
valid_params- valid parameters used for completion item kind
param_name- name of input parameter for completion item kind
clean_type- type to decide if reference completion item kind
is_param- boolean denoting if kind is for parameter or value
Returns
- enumerated kind value that client may use for icon in list

Definition at line 1426 of file MooseServer.C.

Referenced by addParametersToList(), and addValuesToList().

1430 {
1431  // set up completion item kind value that client may use for icon in list
1432  auto associated_types = getCheckApp()->syntax().getAssociatedTypes();
1433  if (is_param && valid_params.isParamRequired(param_name) &&
1434  !valid_params.isParamValid(param_name))
1435  return wasp::lsp::m_comp_kind_event;
1436  else if (param_name == "active" || param_name == "inactive")
1437  return wasp::lsp::m_comp_kind_class;
1438  else if (clean_type == "bool")
1439  return wasp::lsp::m_comp_kind_interface;
1440  else if (valid_params.have_parameter<MooseEnum>(param_name) ||
1441  valid_params.have_parameter<MultiMooseEnum>(param_name) ||
1442  valid_params.have_parameter<ExecFlagEnum>(param_name) ||
1443  valid_params.have_parameter<std::vector<MooseEnum>>(param_name))
1444  return is_param ? wasp::lsp::m_comp_kind_enum : wasp::lsp::m_comp_kind_enum_member;
1445  else if (param_name == "type")
1446  return wasp::lsp::m_comp_kind_type_param;
1447  else if (std::find_if(associated_types.begin(),
1448  associated_types.end(),
1449  [&](const auto & entry)
1450  { return entry.second == clean_type; }) != associated_types.end())
1451  return wasp::lsp::m_comp_kind_reference;
1452  else
1453  return is_param ? wasp::lsp::m_comp_kind_keyword : wasp::lsp::m_comp_kind_value;
1454 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
bool isParamRequired(const std::string &name) const
Returns a boolean indicating whether the specified parameter is required or not.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

◆ getConnection()

std::shared_ptr<wasp::lsp::Connection> MooseServer::getConnection ( )
inline

Get read / write connection - specific to this server implemention.

Returns
- shared pointer to the server's read / write connection

Definition at line 39 of file MooseServer.h.

39 { return _connection; }
std::shared_ptr< wasp::lsp::IOStreamConnection > _connection
_connection - shared pointer to this server&#39;s read / write iostream
Definition: MooseServer.h:391

◆ getDocumentSymbolKind()

int MooseServer::getDocumentSymbolKind ( wasp::HITNodeView  symbol_node)
private

Get document symbol kind value that client may use for outline icon.

Parameters
symbol_node- node that will be added to symbol tree for kind
Returns
- enumerated kind value that client may use for outline icon

Definition at line 1457 of file MooseServer.C.

Referenced by gatherDocumentSymbols(), and traverseParseTreeAndFillSymbols().

1458 {
1459  // lambdas that check if parameter is a boolean or number for symbol kind
1460  auto is_boolean = [](wasp::HITNodeView symbol_node)
1461  {
1462  bool convert;
1463  std::istringstream iss(MooseUtils::toLower(symbol_node.last_as_string()));
1464  return (iss >> std::boolalpha >> convert && !iss.fail());
1465  };
1466  auto is_number = [](wasp::HITNodeView symbol_node)
1467  {
1468  double convert;
1469  std::istringstream iss(symbol_node.last_as_string());
1470  return (iss >> convert && iss.eof());
1471  };
1472 
1473  // set up document symbol kind value that client may use for outline icon
1474  if (symbol_node.type() == wasp::OBJECT)
1475  return wasp::lsp::m_symbol_kind_struct;
1476  else if (symbol_node.type() == wasp::FILE)
1477  return wasp::lsp::m_symbol_kind_file;
1478  else if (symbol_node.type() == wasp::ARRAY)
1479  return wasp::lsp::m_symbol_kind_array;
1480  else if (symbol_node.type() == wasp::KEYED_VALUE && symbol_node.name() == std::string("type"))
1481  return wasp::lsp::m_symbol_kind_type_param;
1482  else if (symbol_node.type() == wasp::KEYED_VALUE && is_boolean(symbol_node))
1483  return wasp::lsp::m_symbol_kind_boolean;
1484  else if (symbol_node.type() == wasp::KEYED_VALUE && is_number(symbol_node))
1485  return wasp::lsp::m_symbol_kind_number;
1486  else if (symbol_node.type() == wasp::KEYED_VALUE)
1487  return wasp::lsp::m_symbol_kind_key;
1488  else if (symbol_node.type() == wasp::VALUE)
1489  return wasp::lsp::m_symbol_kind_string;
1490  else
1491  return wasp::lsp::m_symbol_kind_property;
1492 }
T convert(const std::string &str, bool throw_on_failure=false)
convert takes a string representation of a number type and converts it to the number.
Definition: MooseUtils.h:840
std::string toLower(const std::string &name)
Convert supplied string to lower case.

◆ getDocumentText()

const std::string & MooseServer::getDocumentText ( ) const
private
Returns
up to date text string associated with current document path

Definition at line 1542 of file MooseServer.C.

Referenced by gatherDocumentFormattingTextEdits().

1543 {
1544  mooseAssert(_path_to_text.count(document_path), "No text for path");
1545  return _path_to_text.at(document_path);
1546 }
std::map< std::string, std::string > _path_to_text
_path_to_text - map of document paths to current text strings
Definition: MooseServer.h:386

◆ getEnumsAndDocs()

template<typename MooseEnumType >
void MooseServer::getEnumsAndDocs ( MooseEnumType &  moose_enum_param,
std::map< std::string, std::string > &  options_and_descs 
)
private

Fill map of all options and descriptions if parameter is moose enum.

Parameters
moose_enum_param- parameter to get documentation and options
options_and_descs- map to fill with options and descriptions

Definition at line 828 of file MooseServer.C.

Referenced by addValuesToList(), and getHoverDisplayText().

830 {
831  // get map that contains any documentation strings provided for each item
832  const auto & enum_docs = moose_enum_param.getItemDocumentation();
833 
834  // walk over enums filling map with options and any provided descriptions
835  for (const auto & item : moose_enum_param.items())
836  options_and_descs[item.name()] = enum_docs.count(item) ? enum_docs.at(item) : "";
837 }

◆ getExistingInput()

void MooseServer::getExistingInput ( wasp::HITNodeView  parent_node,
std::set< std::string > &  existing_params,
std::set< std::string > &  existing_subblocks 
)
private

Get names of parameters and subblocks specified in given input node.

Parameters
parent_node- object node context under which to gather input
existing_params- set to fill with parameter names from input
existing_subblocks- set to fill with subblock names in input

Definition at line 331 of file MooseServer.C.

Referenced by gatherDocumentCompletionItems().

334 {
335  // gather names of all parameters and subblocks provided in input context
336  for (auto itr = parent_node.begin(); itr != parent_node.end(); itr.next())
337  {
338  auto child_node = itr.get();
339 
340  // add key value or array type as parameter and object type as subblock
341  if (child_node.type() == wasp::KEYED_VALUE || child_node.type() == wasp::ARRAY)
342  existing_params.insert(child_node.name());
343  else if (child_node.type() == wasp::OBJECT)
344  existing_subblocks.insert(child_node.name());
345  }
346 }

◆ getHoverDisplayText()

bool MooseServer::getHoverDisplayText ( std::string &  display_text,
int  line,
int  character 
)
private

Get hover display text - logic specific to this server implemention.

Parameters
display_text- string reference to add hover text for display
line- zero-based line to use for finding node and hover text
character- zero-based column for finding node and hover text
Returns
- true if display text was added or left empty without error

Definition at line 1016 of file MooseServer.C.

1017 {
1018  Factory & factory = getCheckApp()->getFactory();
1019  Syntax & syntax = getCheckApp()->syntax();
1020 
1021  // return and leave display text as empty string when parser root is null
1022  if (!rootIsValid())
1023  return true;
1024 
1025  // find hit node for zero based request line and column number from input
1026  wasp::HITNodeView view_root = getRoot().getNodeView();
1027  wasp::HITNodeView request_context =
1028  wasp::findNodeUnderLineColumn(view_root, line + 1, character + 1);
1029 
1030  // return and leave display text as empty string when not on key or value
1031  if ((request_context.type() != wasp::DECL && request_context.type() != wasp::VALUE) ||
1032  !request_context.has_parent() ||
1033  (request_context.parent().type() != wasp::KEYED_VALUE &&
1034  request_context.parent().type() != wasp::ARRAY))
1035  return true;
1036 
1037  // get name of parameter node and value string that is specified in input
1038  std::string paramkey = request_context.parent().name();
1039  std::string paramval = request_context.last_as_string();
1040 
1041  // get object context path and object type value for request if it exists
1042  wasp::HITNodeView object_context = request_context;
1043  while (object_context.type() != wasp::OBJECT && object_context.has_parent())
1044  object_context = object_context.parent();
1045  const std::string object_path = object_context.path();
1046  wasp::HITNodeView type_node = object_context.first_child_by_name("type");
1047  const std::string object_type =
1048  type_node.is_null() ? "" : wasp::strip_quotes(hit::extractValue(type_node.data()));
1049 
1050  // gather global, action, and object parameters in request object context
1051  InputParameters valid_params = emptyInputParameters();
1052  std::set<std::string> obj_act_tasks;
1053  getAllValidParameters(valid_params, object_path, object_type, obj_act_tasks);
1054 
1055  // use class description as display text when request is valid type value
1056  if (request_context.type() == wasp::VALUE && paramkey == "type" && factory.isRegistered(paramval))
1057  {
1058  const InputParameters & object_params = factory.getValidParams(paramval);
1059  if (object_params.have_parameter<std::string>("_moose_base"))
1060  {
1061  const std::string moose_base = object_params.get<std::string>("_moose_base");
1062  for (const auto & obj_act_task : obj_act_tasks)
1063  {
1064  if (syntax.verifyMooseObjectTask(moose_base, obj_act_task))
1065  {
1066  display_text = object_params.getClassDescription();
1067  break;
1068  }
1069  }
1070  }
1071  }
1072 
1073  // use item documentation as display text when request is enum type value
1074  else if (request_context.type() == wasp::VALUE)
1075  {
1076  std::map<std::string, std::string> options_and_descs;
1077  if (valid_params.have_parameter<MooseEnum>(paramkey))
1078  getEnumsAndDocs(valid_params.get<MooseEnum>(paramkey), options_and_descs);
1079  else if (valid_params.have_parameter<MultiMooseEnum>(paramkey))
1080  getEnumsAndDocs(valid_params.get<MultiMooseEnum>(paramkey), options_and_descs);
1081  else if (valid_params.have_parameter<ExecFlagEnum>(paramkey))
1082  getEnumsAndDocs(valid_params.get<ExecFlagEnum>(paramkey), options_and_descs);
1083  else if (valid_params.have_parameter<std::vector<MooseEnum>>(paramkey))
1084  getEnumsAndDocs(valid_params.get<std::vector<MooseEnum>>(paramkey)[0], options_and_descs);
1085  if (options_and_descs.count(paramval))
1086  display_text = options_and_descs.find(paramval)->second;
1087  }
1088 
1089  // use parameter documentation as display text when request is valid name
1090  else if (request_context.type() == wasp::DECL && valid_params.getParametersList().count(paramkey))
1091  display_text = valid_params.getDocString(paramkey);
1092 
1093  MooseUtils::escape(display_text);
1094  return true;
1095 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
bool isRegistered(const std::string &obj_name) const
Returns a Boolean indicating whether an object type has been registered.
Definition: Factory.h:152
std::set< std::string > getParametersList() const
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition: Factory.C:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
bool rootIsValid() const
Definition: MooseServer.C:1521
std::string getDocString(const std::string &name) const
Returns the documentation string for the specified parameter name.
hit::Node & getRoot()
Definition: MooseServer.C:1528
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
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.
Definition: MooseServer.C:349
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
Holding syntax for parsing input files.
Definition: Syntax.h:21
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...
Definition: Syntax.C:334
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
std::string getClassDescription() const
Returns the class description.
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.
Definition: MooseServer.C:828
void escape(std::string &str)
This function will escape all of the standard C++ escape characters so that they can be printed...
Definition: MooseUtils.C:203

◆ getInputLookupDefinitionNodes()

void MooseServer::getInputLookupDefinitionNodes ( SortedLocationNodes location_nodes,
const std::string &  clean_type,
const std::string &  val_string 
)
private

Get set of nodes from associated path lookups matching value string.

Parameters
location_nodes- set to fill with lookup nodes matching value
clean_type- cpp type string used for key finding input paths
val_string- specified value used for gathering input lookups

Definition at line 943 of file MooseServer.C.

Referenced by gatherDocumentDefinitionLocations().

946 {
947  Syntax & syntax = getCheckApp()->syntax();
948 
949  // build map from parameter types to input lookup paths and save to reuse
950  if (_type_to_input_paths.empty())
951  {
952  for (const auto & associated_types_iter : syntax.getAssociatedTypes())
953  {
954  const std::string & type = associated_types_iter.second;
955  const std::string & path = associated_types_iter.first;
956  _type_to_input_paths[type].insert(path);
957  }
958  }
959 
960  // find set of input lookup paths that are associated with parameter type
961  const auto & input_path_iter = _type_to_input_paths.find(clean_type);
962 
963  // return without any definition locations added when no paths associated
964  if (input_path_iter == _type_to_input_paths.end())
965  return;
966 
967  // get root node from input to use in input lookups with associated paths
968  wasp::HITNodeView view_root = getRoot().getNodeView();
969 
970  // walk over all syntax paths that are associated with parameter type
971  for (const auto & input_path : input_path_iter->second)
972  {
973  // use wasp siren to gather all nodes from current lookup path in input
974  wasp::SIRENInterpreter<> selector;
975  if (!selector.parseString(input_path))
976  continue;
977  wasp::SIRENResultSet<wasp::HITNodeView> results;
978  std::size_t count = selector.evaluate(view_root, results);
979 
980  // walk over results and add nodes that have name matching value to set
981  for (std::size_t i = 0; i < count; i++)
982  if (results.adapted(i).type() == wasp::OBJECT && results.adapted(i).name() == val_string &&
983  results.adapted(i).child_count_by_name("decl"))
984  location_nodes.insert(results.adapted(i).first_child_by_name("decl"));
985  }
986 }
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.C:368
std::map< std::string, std::set< std::string > > _type_to_input_paths
_type_to_input_paths - map of parameter types to lookup paths
Definition: MooseServer.h:401
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
hit::Node & getRoot()
Definition: MooseServer.C:1528
Holding syntax for parsing input files.
Definition: Syntax.h:21

◆ getNodesByValueAndTypes()

void MooseServer::getNodesByValueAndTypes ( SortedLocationNodes match_nodes,
wasp::HITNodeView  view_parent,
const std::string &  target_value,
const std::set< std::string > &  target_types 
)
private

Recursively walk input to gather all nodes matching value and types.

Parameters
match_nodes- set to fill with nodes matching value and types
view_parent- nodeview used to start recursive tree traversal
target_value-
target_types-

Definition at line 1170 of file MooseServer.C.

Referenced by gatherDocumentReferencesLocations().

1174 {
1175  // walk over children of context to gather nodes matching value and types
1176  for (const auto & view_child : view_parent)
1177  {
1178  // check for parameter type match if node is value matching target data
1179  if (view_child.type() == wasp::VALUE && view_child.to_string() == target_value)
1180  {
1181  // get object context path and object type value of node if it exists
1182  wasp::HITNodeView object_context = view_child;
1183  while (object_context.type() != wasp::OBJECT && object_context.has_parent())
1184  object_context = object_context.parent();
1185  const std::string object_path = object_context.path();
1186  wasp::HITNodeView type_node = object_context.first_child_by_name("type");
1187  const std::string object_type =
1188  type_node.is_null() ? "" : wasp::strip_quotes(hit::extractValue(type_node.data()));
1189 
1190  // gather global, action, and object parameters for context of object
1191  InputParameters valid_params = emptyInputParameters();
1192  std::set<std::string> obj_act_tasks;
1193  getAllValidParameters(valid_params, object_path, object_type, obj_act_tasks);
1194 
1195  // get name from parent of current value node which is parameter node
1196  std::string param_name = view_child.has_parent() ? view_child.parent().name() : "";
1197 
1198  // get type of parameter and prepare string to check target set match
1199  std::string dirty_type = valid_params.type(param_name);
1200  std::string clean_type = MooseUtils::prettyCppType(dirty_type);
1201  pcrecpp::RE(".+<([A-Za-z0-9_' ':]*)>.*").GlobalReplace("\\1", &clean_type);
1202 
1203  // add input node to collection if its type is also in set of targets
1204  if (target_types.count(clean_type))
1205  match_nodes.insert(view_child);
1206  }
1207 
1208  // recurse deeper into input to search for matches if node has children
1209  if (!view_child.is_leaf())
1210  getNodesByValueAndTypes(match_nodes, view_child, target_value, target_types);
1211  }
1212 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
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.
Definition: MooseServer.C:1170
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.
Definition: MooseServer.C:349
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
std::string prettyCppType(const std::string &cpp_type)
Definition: MooseUtils.C:1246

◆ getObjectParameters()

void MooseServer::getObjectParameters ( InputParameters valid_params,
std::string  object_type,
const std::set< std::string > &  obj_act_tasks 
)
private

Get all object parameters using requested object path to collection.

Parameters
valid_params- collection for filling object input parameters
object_type- type of object where autocomplete was requested
obj_act_tasks- tasks to verify object type with valid syntax

Definition at line 406 of file MooseServer.C.

Referenced by getAllValidParameters().

409 {
410  Syntax & syntax = getCheckApp()->syntax();
411  Factory & factory = getCheckApp()->getFactory();
412 
413  // use type parameter default if it exists and is not provided from input
414  if (object_type.empty() && valid_params.have_parameter<std::string>("type") &&
415  !valid_params.get<std::string>("type").empty())
416  {
417  object_type = valid_params.get<std::string>("type");
418 
419  // make type parameter not required in input since it has default value
420  valid_params.makeParamNotRequired("type");
421  }
422 
423  // check if object type has been registered to prevent unregistered error
424  if (factory.isRegistered(object_type))
425  {
426  // use object type to get set of valid parameters registered in factory
427  InputParameters object_params = factory.getValidParams(object_type);
428 
429  // check if object has base associated with any MooseObjectAction tasks
430  if (object_params.have_parameter<std::string>("_moose_base"))
431  {
432  const std::string & moose_base = object_params.get<std::string>("_moose_base");
433 
434  for (const auto & obj_act_task : obj_act_tasks)
435  {
436  if (syntax.verifyMooseObjectTask(moose_base, obj_act_task))
437  {
438  // add parameters from object to valid collection if base matches
439  valid_params += object_params;
440  break;
441  }
442  }
443  }
444  }
445 
446  // make parameters from list of those set by action not required in input
447  if (valid_params.have_parameter<std::vector<std::string>>("_object_params_set_by_action"))
448  {
449  auto names = valid_params.get<std::vector<std::string>>("_object_params_set_by_action");
450  for (const auto & name : names)
451  valid_params.makeParamNotRequired(name);
452 
453  // filter parameter from completion list since it is not used for input
454  valid_params.remove("_object_params_set_by_action");
455  }
456 }
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
bool isRegistered(const std::string &obj_name) const
Returns a Boolean indicating whether an object type has been registered.
Definition: Factory.h:152
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition: Factory.C:68
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void remove(std::string_view)
void makeParamNotRequired(const std::string &name)
Changes the parameter to not be required.
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
Holding syntax for parsing input files.
Definition: Syntax.h:21
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...
Definition: Syntax.C:334

◆ getRequiredParamsText()

std::string MooseServer::getRequiredParamsText ( const std::string &  subblock_path,
const std::string &  subblock_type,
const std::set< std::string > &  existing_params,
const std::string &  indent_spaces 
)
private

Get required parameter completion text list for given subblock path.

Parameters
subblock_path- subblock path for finding required parameters
subblock_type- subblock type for finding required parameters
existing_params- set of parameters already existing in input
indent_spaces- indentation to be added before each parameter
Returns
- list of required parameters to use in subblock insert text

Definition at line 1495 of file MooseServer.C.

Referenced by addSubblocksToList(), and addValuesToList().

1499 {
1500  // gather global, action, and object parameters in request object context
1501  InputParameters valid_params = emptyInputParameters();
1502  std::set<std::string> obj_act_tasks;
1503  getAllValidParameters(valid_params, subblock_path, subblock_type, obj_act_tasks);
1504 
1505  // walk over collection of all parameters and build text of ones required
1506  std::string required_param_text;
1507  for (const auto & valid_params_iter : valid_params)
1508  {
1509  // skip parameter if deprecated, private, defaulted, optional, existing
1510  const std::string & param_name = valid_params_iter.first;
1511  if (!valid_params.isParamDeprecated(param_name) && !valid_params.isPrivate(param_name) &&
1512  !valid_params.isParamValid(param_name) && valid_params.isParamRequired(param_name) &&
1513  !existing_params.count(param_name))
1514  required_param_text += "\n" + indent_spaces + param_name + " = ";
1515  }
1516 
1517  return required_param_text;
1518 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
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.
Definition: MooseServer.C:349

◆ getRoot()

hit::Node & MooseServer::getRoot ( )
private
Returns
The current root node

Definition at line 1528 of file MooseServer.C.

Referenced by addValuesToList(), gatherDocumentCompletionItems(), gatherDocumentDefinitionLocations(), gatherDocumentReferencesLocations(), gatherDocumentSymbols(), getHoverDisplayText(), and getInputLookupDefinitionNodes().

1529 {
1530  mooseAssert(rootIsValid(), "Not valid");
1531  return *getCheckApp()->builder().root();
1532 }
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
bool rootIsValid() const
Definition: MooseServer.C:1521

◆ parseDocumentForDiagnostics()

bool MooseServer::parseDocumentForDiagnostics ( wasp::DataArray &  diagnosticsList)
private

Parse document for diagnostics - specific to this server implemention.

Parameters
diagnosticsList- data array of diagnostics data objects to fill
Returns
- true if completed successfully - does not indicate parse fail

Definition at line 55 of file MooseServer.C.

56 {
57  // strip prefix from document uri if it exists to get parse file path
58  std::string parse_file_path = document_path;
59  pcrecpp::RE("(.*://)(.*)").Replace("\\2", &parse_file_path);
60 
61  // copy parent application parameters and modify to set up input check
62  InputParameters app_params = _moose_app.parameters();
63  app_params.set<std::shared_ptr<Parser>>("_parser") =
64  std::make_shared<Parser>(parse_file_path, document_text);
65 
66  auto command_line = std::make_unique<CommandLine>(_moose_app.commandLine()->getArguments());
67  if (command_line->hasArgument("--language-server"))
68  command_line->removeArgument("--language-server");
69  command_line->addArgument("--check-input");
70  command_line->addArgument("--error-unused");
71  command_line->addArgument("--error");
72  command_line->addArgument("--color=off");
73  command_line->addArgument("--disable-perf-graph-live");
74  command_line->parse();
75  app_params.set<std::shared_ptr<CommandLine>>("_command_line") = std::move(command_line);
76 
77  // create new application with parameters modified for input check run
79  _moose_app.type(), _moose_app.name(), app_params, _moose_app.getCommunicator()->get());
80 
81  // add updated document text to map associated with current document path
82  _path_to_text[document_path] = document_text;
83 
84  // enable exceptions to be thrown for errors and cache initial setting
85  bool cached_throw_on_error = Moose::_throw_on_error;
87 
88  bool pass = true;
89 
90  // run input check application converting caught errors to diagnostics
91  try
92  {
93  getCheckApp()->run();
94  }
95  catch (std::exception & err)
96  {
97  int line_number = 1;
98  int column_number = 1;
99 
100  std::istringstream caught_msg(err.what());
101 
102  // walk over caught message line by line adding each as a diagnostic
103  for (std::string error_line; std::getline(caught_msg, error_line);)
104  {
105  // check if this error line already has the input file path prefix
106  if (error_line.rfind(parse_file_path + ":", 0) == 0)
107  {
108  // strip input file path and colon prefix off of this error line
109  error_line.erase(0, parse_file_path.size() + 1);
110 
111  int match_line_number;
112  int match_column_number;
113  std::string match_error_line;
114 
115  // get line and column number from this error line if both exist
116  if (pcrecpp::RE("^(\\d+)\\.(\\d+)\\-?\\d*:\\s*(.*)$")
117  .FullMatch(error_line, &match_line_number, &match_column_number, &match_error_line))
118  {
119  line_number = match_line_number;
120  column_number = match_column_number;
121  error_line = match_error_line;
122  }
123 
124  // otherwise get line number off of this error line if it exists
125  else if (pcrecpp::RE("^(\\d+):\\s*(.*)$")
126  .FullMatch(error_line, &match_line_number, &match_error_line))
127  {
128  line_number = match_line_number;
129  column_number = 1;
130  error_line = match_error_line;
131  }
132  }
133 
134  // skip adding diagnostic when message is empty or only whitespace
135  if (error_line.find_first_not_of(" \t") == std::string::npos)
136  continue;
137 
138  // build zero based line and column diagnostic and add to the list
139  diagnosticsList.push_back(wasp::DataObject());
140  wasp::DataObject * diagnostic = diagnosticsList.back().to_object();
141  pass &= wasp::lsp::buildDiagnosticObject(*diagnostic,
142  errors,
143  line_number - 1,
144  column_number - 1,
145  line_number - 1,
146  column_number - 1,
147  1,
148  "moose_srv",
149  "check_inp",
150  error_line);
151  }
152  }
153 
154  // reset behavior of exceptions thrown for errors with initial setting
155  Moose::_throw_on_error = cached_throw_on_error;
156 
157  return pass;
158 }
OStreamProxy err
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535
std::shared_ptr< CommandLine > commandLine() const
Get the command line.
Definition: MooseApp.h:451
MooseAppPtr createShared(const std::string &app_type, const std::string &name, InputParameters parameters, MPI_Comm COMM_WORLD_IN)
Build an application object (must be registered)
Definition: AppFactory.C:127
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const InputParameters & parameters()
Get the parameters of the object.
Definition: MooseApp.h:150
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
static AppFactory & instance()
Get the instance of the AppFactory.
Definition: AppFactory.C:18
MooseApp & _moose_app
_moose_app - reference to parent application that owns this server
Definition: MooseServer.h:376
std::map< std::string, std::string > _path_to_text
_path_to_text - map of document paths to current text strings
Definition: MooseServer.h:386
bool _throw_on_error
Variable to turn on exceptions during mooseError(), should only be used within MOOSE unit tests or wh...
Definition: Moose.C:758
const std::shared_ptr< libMesh::Parallel::Communicator > getCommunicator() const
Definition: MooseApp.h:1063
std::map< std::string, std::shared_ptr< MooseApp > > _check_apps
_check_apps - map from document paths to input check applications
Definition: MooseServer.h:381

◆ rootIsValid()

bool MooseServer::rootIsValid ( ) const
private
Returns
Whether or not the root is valid

Will be true if the app is valid, the root is not nullptr, and the root node view is not null

Definition at line 1521 of file MooseServer.C.

Referenced by gatherDocumentCompletionItems(), gatherDocumentDefinitionLocations(), gatherDocumentReferencesLocations(), gatherDocumentSymbols(), getHoverDisplayText(), and getRoot().

1522 {
1523  return getCheckApp() && getCheckApp()->builder().root() &&
1524  !getCheckApp()->builder().root()->getNodeView().is_null();
1525 }
std::shared_ptr< MooseApp > getCheckApp() const
Definition: MooseServer.C:1535

◆ traverseParseTreeAndFillSymbols()

bool MooseServer::traverseParseTreeAndFillSymbols ( wasp::HITNodeView  view_parent,
wasp::DataObject &  data_parent 
)
private

Recursively fill document symbols from the given node.

Parameters
view_parent- nodeview used in recursive tree traversal
data_parent- data object with array of symbol children
Returns
- true if no problems with this level of the resursion

Definition at line 1374 of file MooseServer.C.

Referenced by gatherDocumentSymbols().

1376 {
1377  // return without adding any children if parent node is file include type
1378  if (wasp::is_nested_file(view_parent))
1379  return true;
1380 
1381  bool pass = true;
1382 
1383  // walk over all children of this node context and build document symbols
1384  for (const auto i : make_range(view_parent.child_count()))
1385  {
1386  // walk must be index based to catch file include and skip its children
1387  wasp::HITNodeView view_child = view_parent.child_at(i);
1388 
1389  // set up name, zero based line and column range, kind, and detail info
1390  std::string name = view_child.name();
1391  int line = view_child.line() - 1;
1392  int column = view_child.column() - 1;
1393  int last_line = view_child.last_line() - 1;
1394  int last_column = view_child.last_column();
1395  int symbol_kind = getDocumentSymbolKind(view_child);
1396  std::string detail =
1397  !view_child.first_child_by_name("type").is_null()
1398  ? wasp::strip_quotes(hit::extractValue(view_child.first_child_by_name("type").data()))
1399  : "";
1400 
1401  // build document symbol object from node child info and push to array
1402  wasp::DataObject & data_child = wasp::lsp::addDocumentSymbolChild(data_parent);
1403  pass &= wasp::lsp::buildDocumentSymbolObject(data_child,
1404  errors,
1405  (name.empty() ? "void" : name),
1406  detail,
1407  symbol_kind,
1408  false,
1409  line,
1410  column,
1411  last_line,
1412  last_column,
1413  line,
1414  column,
1415  last_line,
1416  last_column);
1417 
1418  // call method to recursively fill document symbols for each node child
1419  pass &= traverseParseTreeAndFillSymbols(view_child, data_child);
1420  }
1421 
1422  return pass;
1423 }
std::string name(const ElemQuality q)
int getDocumentSymbolKind(wasp::HITNodeView symbol_node)
Get document symbol kind value that client may use for outline icon.
Definition: MooseServer.C:1457
bool traverseParseTreeAndFillSymbols(wasp::HITNodeView view_parent, wasp::DataObject &data_parent)
Recursively fill document symbols from the given node.
Definition: MooseServer.C:1374
IntRange< T > make_range(T beg, T end)

◆ updateDocumentTextChanges()

bool MooseServer::updateDocumentTextChanges ( const std::string &  replacement_text,
int  start_line,
int  start_character,
int  end_line,
int  end_character,
int  range_length 
)
private

Update document text changes - specific to this server implemention.

Parameters
replacement_text- text to be replaced over the provided range
start_line- starting replace line number ( zero-based )
start_character- starting replace column number ( zero-based )
end_line- ending replace line number ( zero-based )
end_character- ending replace column number ( zero-based )
range_length- length of replace range - server specific
Returns
- true if the document text was updated successfully

Definition at line 161 of file MooseServer.C.

167 {
168  // replacement text swaps full document as indicated in server capabilities
169  document_text = replacement_text;
170 
171  return true;
172 }

Member Data Documentation

◆ _check_apps

std::map<std::string, std::shared_ptr<MooseApp> > MooseServer::_check_apps
private

_check_apps - map from document paths to input check applications

Definition at line 381 of file MooseServer.h.

Referenced by getCheckApp(), and parseDocumentForDiagnostics().

◆ _connection

std::shared_ptr<wasp::lsp::IOStreamConnection> MooseServer::_connection
private

_connection - shared pointer to this server's read / write iostream

Definition at line 391 of file MooseServer.h.

Referenced by connectionRead(), connectionWrite(), and getConnection().

◆ _formatting_tab_size

std::size_t MooseServer::_formatting_tab_size
private

_formatting_tab_size - number of indent spaces for formatting

Definition at line 411 of file MooseServer.h.

Referenced by formatDocument(), and gatherDocumentFormattingTextEdits().

◆ _input_path_to_types

std::map<std::string, std::set<std::string> > MooseServer::_input_path_to_types
private

_type_to_input_paths - map of lookup paths to parameter types

Definition at line 406 of file MooseServer.h.

Referenced by gatherDocumentReferencesLocations().

◆ _moose_app

MooseApp& MooseServer::_moose_app
private

_moose_app - reference to parent application that owns this server

Definition at line 376 of file MooseServer.h.

Referenced by parseDocumentForDiagnostics().

◆ _path_to_text

std::map<std::string, std::string> MooseServer::_path_to_text
private

_path_to_text - map of document paths to current text strings

Definition at line 386 of file MooseServer.h.

Referenced by getDocumentText(), and parseDocumentForDiagnostics().

◆ _syntax_to_subblocks

std::map<std::string, std::set<std::string> > MooseServer::_syntax_to_subblocks
private

_syntax_to_subblocks - map of syntax paths to valid subblocks

Definition at line 396 of file MooseServer.h.

Referenced by addSubblocksToList().

◆ _type_to_input_paths

std::map<std::string, std::set<std::string> > MooseServer::_type_to_input_paths
private

_type_to_input_paths - map of parameter types to lookup paths

Definition at line 401 of file MooseServer.h.

Referenced by addValuesToList(), and getInputLookupDefinitionNodes().


The documentation for this class was generated from the following files: