WSF
wizard::AutoComplete Class Reference

#include <AutoComplete.hpp>

Collaboration diagram for wizard::AutoComplete:

Classes

struct  Results
struct  SyntaxResults
struct  Entry
struct  Query

Public Types

using Syntax = std::vector<std::string>
using SyntaxList = std::vector<Syntax>

Public Member Functions

 AutoComplete ()
void GetSuggestions (ParseResults &aParseData, TextSource &aSource, WsfParseNode *aNodePtr, const std::string &aText, size_t aInsertPosition, Results &aResults)
void GetSyntax (ParseResults &aParseData, TextSource &aSource, WsfParseNode *aNodePtr, const std::string &aText, size_t aInsertPosition, SyntaxResults &aResults)

Protected Types

enum  Operation { cAUTOCOMPLETE , cSYNTAX }

Protected Member Functions

SyntaxList CollectSyntax (Entry *aEntryTreePtr, bool aFirstWord=true)
SyntaxList JoinSyntax (const SyntaxList &aLhs, const SyntaxList &aRhs)
void GetIncludeSuggestions (const std::string &aText, TextSource &aSource, ParseResults &aParseData, Results &aResults)
bool FullyExpandWord (size_t aWordIndex) const
void DigestInput (const std::string &aText, size_t aInputPosition, size_t &aReplaceCharacters, size_t &aInsertPosition)
int ExpandTree (Entry &aEntry, const WsfParseType *aCurrentTypePtr, int aWordIndex, int aMaxWordIndex)
bool TextMatches (const std::string &aText, size_t aWordIndex)
bool TextMatches (const std::string &aText, const std::string &aQuery)
WsfParseNodeFindBlock (WsfParseNode *aNodePtr, int aInsertPosition)
bool ExpandRule (int aWordIndex, WsfParseRule *aReaderPtr, const WsfParseType *aCurrentTypePtr, Entry &aEntry, bool aExpandBlock=false)
void ExpandRefType (Entry &aEntry, const WsfParseType *aCurrentTypePtr, int aWordIndex)
void Prune (int aQueryWordIndex, Entry *&aEntry)
void CollectSuggestions (Entry *aRootEntry, size_t aWordIndex, std::vector< std::string > &aSuggestions, bool &aLastToken)
bool FindSuggestionTerminator (Entry *aEntryWord, std::string &aTerminatorToken)
WsfParseNodeFindNextBlock (WsfParseNode *aBlockPtr)
int CountSuggestions (Entry *aRootEntry)
const WsfParseTypeFindCurrentType (WsfParseNode *aNodePtr)

Protected Attributes

bool mExpanded
ParseResultsmParseResultsPtr
const WsfParseTypemCurrentTypeRef
bool mExpandTypeCommand
Query mCurrentQuery

Detailed Description

Computes suggestions for the auto-complete popup The algorithm is as follows: Given a starting containing block node B (may be null) and given a starting insert position P:

  1. Combine all words, W, from P to either start of line, or end of previously parsed node.
  2. Grab rule, R, used to create nodes for block B (or root rule if B is null)
  3. Recursively expand and prune the tree of rules beginning at R with all possible following words for words 1..N where N is the number of words in W. While pruning words that do not match W.
  4. Return the list of valid words for the last word in W.

This words in most cases, but there are a few problems:

  • Extending valid commands:

    processor <internal-link> (implicit mover command)
    processor <name> <type> ... end_processor (platform command)

    matches:

    processor myproc WSF_| ('processor myproc' matches the first rule, leaving us to autocomplete only on WSF_)
    end_time 1 m| ('end_time 1 m' matches a rule, leaving no way to autocomplete for 'minutes')

Member Typedef Documentation

◆ Syntax

using wizard::AutoComplete::Syntax = std::vector<std::string>

◆ SyntaxList

Member Enumeration Documentation

◆ Operation

Enumerator
cAUTOCOMPLETE 
cSYNTAX 

Constructor & Destructor Documentation

◆ AutoComplete()

wizard::AutoComplete::AutoComplete ( )

Member Function Documentation

◆ CollectSuggestions()

◆ CollectSyntax()

◆ CountSuggestions()

◆ DigestInput()

void wizard::AutoComplete::DigestInput ( const std::string & aText,
size_t aInputPosition,
size_t & aReplaceCharacters,
size_t & aInsertPosition )
protected

References cAUTOCOMPLETE, and mCurrentQuery.

Referenced by GetSuggestions(), and GetSyntax().

◆ ExpandRefType()

◆ ExpandRule()

bool wizard::AutoComplete::ExpandRule ( int aWordIndex,
WsfParseRule * aReaderPtr,
const WsfParseType * aCurrentTypePtr,
Entry & aEntry,
bool aExpandBlock = false )
protected

References wizard::AutoComplete::Entry::cALTERNATE, WsfParseRule::cALTERNATE, wizard::AutoComplete::Entry::cBLOCK_PLACEHOLDER, WsfParseRule::cDELIMITED, WsfParseNode::cERROR_INCOMPLETE, WsfParseRule::cINT, WsfParseRule::cIS_SINGLE_TOKEN, WsfParseNode::cLAZY_TYPE_REFERENCE_NODE, WsfParseNode::cLAZY_TYPENAME_NODE, WsfParseRule::cLINE_STRING, WsfParseRule::cLITERAL, WsfParseTypeInfoData::cLOAD_TYPE, WsfParseNode::cNAMED_NODE, WsfParseRule::cNAMED_RULE, wizard::AutoComplete::Entry::cNAMED_WORD, WsfParseRule::cQUOTED_STRING, WsfParseRule::cREAL, WsfParseRule::cRECURRENCE, WsfParseRule::cRULE_REFERENCE, wizard::AutoComplete::Entry::cSEQUENCE, WsfParseRule::cSEQUENCE, WsfParseRule::cSTRING, WsfParseRule::cSTRUCT, wizard::AutoComplete::Entry::cTYPE_CHANGE, WsfParseRule::cTYPE_COMMAND, WsfParseRule::cTYPE_LOAD, wizard::AutoComplete::Entry::cTYPE_REF_WORD, wizard::AutoComplete::Entry::cUNEXPANDED, WsfParseRule::cVALUE, ExpandRule(), WsfParseType::FindNestedSymbol(), WsfParseNamedRule::GetDefinition(), WsfParseTypeLoadRule::GetLoadType(), WsfParseTypeLoadRule::GetOperation(), WsfParseRule::GetReaderFlags(), WsfParseAlternate::GetReaders(), WsfParseType::GetRule(), WsfParseRuleReference::GetRulePtr(), WsfParseRule::GetSubordinateRule(), wizard::AutoComplete::Entry::mChildren, wizard::AutoComplete::Entry::mCommandWordIndex, wizard::AutoComplete::Entry::mComplete, wizard::AutoComplete::Entry::mCurrentTypeChangePtr, wizard::AutoComplete::Entry::mEntryType, mExpandTypeCommand, wizard::AutoComplete::Entry::mFlags, WsfParseStringRule::mFlags, WsfParseTypeLoadRule::mLoadType, WsfParseTypeName::mNestedLookup, WsfParseSequence::mNodeFlags, WsfParseStringRule::mNodeType, WsfParseTypeName::mOrdinal, wizard::AutoComplete::Entry::mParentCommandPtr, WsfParseTypeName::mPath, wizard::AutoComplete::Entry::mReaderPtr, wizard::AutoComplete::Entry::mRefType, wizard::AutoComplete::Entry::mRuleName, WsfParseLiteral::mText, wizard::AutoComplete::Entry::mWordCount, wizard::AutoComplete::Entry::mWordIsPattern, wizard::AutoComplete::Entry::mWordText, ok, WsfParseSequence::Sequence(), wizard::AutoComplete::Entry::Set(), wizard::AutoComplete::Entry::SetNameRef(), wizard::AutoComplete::Entry::SetTypeRef(), and WsfParseRule::Type().

Referenced by ExpandRule(), ExpandTree(), GetSuggestions(), and GetSyntax().

◆ ExpandTree()

◆ FindBlock()

WsfParseNode * wizard::AutoComplete::FindBlock ( WsfParseNode * aNodePtr,
int aInsertPosition )
protected

◆ FindCurrentType()

◆ FindNextBlock()

WsfParseNode * wizard::AutoComplete::FindNextBlock ( WsfParseNode * aBlockPtr)
protected

◆ FindSuggestionTerminator()

bool wizard::AutoComplete::FindSuggestionTerminator ( Entry * aEntryWord,
std::string & aTerminatorToken )
protected

Attempt to find a terminator for a command. For example, given the rule: platform <name> <type> <BLOCK> end_platform
Input: plat| Suggestion-> platform...end_platform

References WsfParseRule::cRECURRENCE, wizard::AutoComplete::Entry::mCommandWordIndex, WsfParseRecurrence::mEndKeyword, wizard::AutoComplete::Entry::mParentCommandPtr, WsfParseSequence::Sequence(), and WsfParseRule::Type().

Referenced by CollectSuggestions().

◆ FullyExpandWord()

bool wizard::AutoComplete::FullyExpandWord ( size_t aWordIndex) const
protected

References cAUTOCOMPLETE, and mCurrentQuery.

Referenced by ExpandTree().

◆ GetIncludeSuggestions()

void wizard::AutoComplete::GetIncludeSuggestions ( const std::string & aText,
TextSource & aSource,
ParseResults & aParseData,
Results & aResults )
protected

◆ GetSuggestions()

◆ GetSyntax()

◆ JoinSyntax()

wizard::AutoComplete::SyntaxList wizard::AutoComplete::JoinSyntax ( const SyntaxList & aLhs,
const SyntaxList & aRhs )
protected

Referenced by CollectSyntax().

◆ Prune()

◆ TextMatches() [1/2]

bool wizard::AutoComplete::TextMatches ( const std::string & aText,
const std::string & aQuery )
protected

◆ TextMatches() [2/2]

bool wizard::AutoComplete::TextMatches ( const std::string & aText,
size_t aWordIndex )
protected

References mCurrentQuery, and TextMatches().

Referenced by Prune(), and TextMatches().

Member Data Documentation

◆ mCurrentQuery

Query wizard::AutoComplete::mCurrentQuery
protected

◆ mCurrentTypeRef

const WsfParseType* wizard::AutoComplete::mCurrentTypeRef
protected

◆ mExpanded

bool wizard::AutoComplete::mExpanded
protected

◆ mExpandTypeCommand

bool wizard::AutoComplete::mExpandTypeCommand
protected

Referenced by AutoComplete(), and ExpandRule().

◆ mParseResultsPtr

ParseResults* wizard::AutoComplete::mParseResultsPtr
protected

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved