NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode Class Reference
Inheritance diagram for Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode:
Collaboration diagram for Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode:

Public Member Functions

 MenuItemSyntaxNode (string name, int line)
 
- Public Member Functions inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >
void Add (ISyntaxNode node)
 
void Assemble (ISyntaxNode node)
 
Compile ()
 
void CompileNode ()
 
IEnumerator< ISyntaxNodeGetEnumerator ()
 
void Resolve (SymbolTable table)
 
void Validate (SymbolTable table)
 

Protected Member Functions

override MenuItemConfiguration InternalCompile ()
 
override void InternalResolve (SymbolTable table)
 
override void ValidateMandatories ()
 Override to validates the mandatory types in this syntax node. More...
 
override void ValidateReferences (SymbolTable table)
 
override void ValidateTypes ()
 Override to validates the types in this syntax node. More...
 
- Protected Member Functions inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >
 SyntaxNode (Symbol symbol, string name, int line, bool requirePath=false)
 
void AddError (string message)
 
void AddReferenceNameError (ISyntaxNode node, string keyword, string name)
 
void AddReferenceTypeError (ISyntaxNode node, string keyword, string section, string name)
 
void CheckAllIsPresent (IEnumerable< Symbol > list)
 
void CheckIsUnique (IEnumerable< Symbol > list)
 
Uri CheckLink (string link, string keyword)
 
void CheckOneIsPresent (IEnumerable< Symbol > list)
 
void CheckOnlyOneIsPresent (IEnumerable< Symbol > list)
 
void CheckTypeIs< TU > (Symbol symbol)
 
void CheckTypeIs< TU, TV > (Symbol symbol)
 
virtual void InternalResolve (SymbolTable table)
 Override to resolve references to other syntax nodes from this syntax node. More...
 
virtual void ValidateReferences (SymbolTable table)
 Override to validates the references in this syntax node. More...
 

Private Attributes

ISyntaxNode linkable
 
Uri location
 
MenuItemType type
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >
ConfigurationNode CompiledNode
 
IEnumerable< string > Errors
 
bool HasErrors
 
- Properties inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >
int Line [get]
 
string Name [get]
 
List< ISyntaxNodeNodes [get]
 
bool RequirePath [get]
 
Symbol Symbol [get]
 

Detailed Description

Definition at line 32 of file MenuItemSyntaxNode.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.MenuItemSyntaxNode ( string  name,
int  line 
)
inline

Definition at line 34 of file MenuItemSyntaxNode.cs.

References Ntp.Analyzer.Config.Table.KeywordItem.

35  : base(Symbol.KeywordItem, name, line)
36  {
37  type = MenuItemType.Unknown;
38  }

Member Function Documentation

override MenuItemConfiguration Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.InternalCompile ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >.

Definition at line 45 of file MenuItemSyntaxNode.cs.

References Ntp.Analyzer.Config.Syntax.ISyntaxNode.CompiledNode, Ntp.Analyzer.Config.Syntax.ISyntaxNode.CompileNode(), and Ntp.Analyzer.Config.Node.Navigation.Name.

46  {
47  var caption = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordCaption) as StringSettingNode;
48  var dropdown = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordDropdown) as StringSettingNode;
49  var submenu = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordMenu) as MenuSyntaxNode;
50 
51  // NOTICE: Consider another method to archive the same result
52  ILinkable compiledLinkable = null;
53  if (linkable != null)
54  {
56  compiledLinkable = linkable.CompiledNode as ILinkable;
57  }
58 
59  switch (type)
60  {
61  case MenuItemType.Spacer:
63  case MenuItemType.Header:
64  return new HeaderMenuItemConfiguration(Name, caption?.Value);
65  case MenuItemType.Name:
66  return new HeadMenuItemConfiguration(Name, caption?.Value, location);
67  case MenuItemType.Link:
68  return new LinkMenuItemConfiguration(Name, caption?.Value, location);
69  case MenuItemType.Page:
70  return new PageMenuItemConfiguration(Name, caption?.Value, compiledLinkable);
71  case MenuItemType.Dropdown:
72  return new DropdownItemConfiguration(Name, dropdown?.Value, submenu?.Compile());
73  case MenuItemType.Unknown:
74  return null;
75  default:
76  return null;
77  }
78  }

Here is the call graph for this function:

override void Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.InternalResolve ( SymbolTable  table)
inlineprotected

Definition at line 80 of file MenuItemSyntaxNode.cs.

References Ntp.Analyzer.Config.Syntax.Option.MenuItemTypeNode.ItemType, and Ntp.Analyzer.Config.Table.SymbolTable.Lookup().

81  {
82  if (type == MenuItemType.Unknown)
83  {
84  var typeNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordType) as MenuItemTypeNode;
85  if (typeNode != null)
86  type = typeNode.ItemType;
87  }
88 
89  if (type == MenuItemType.Page)
90  {
91  var pageName = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordPage) as StringSettingNode;
92  if (pageName == null)
93  return;
94 
95  linkable = table.Lookup(pageName.Value);
96  }
97  }
ISyntaxNode Lookup(string name)
Definition: SymbolTable.cs:41

Here is the call graph for this function:

override void Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.ValidateMandatories ( )
inlineprotectedvirtual

Override to validates the mandatory types in this syntax node.

When overriding this method do not call the base method.

Reimplemented from Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >.

Definition at line 99 of file MenuItemSyntaxNode.cs.

100  {
101  CheckIsUnique(new List<Symbol>
102  {
103  Symbol.KeywordPage,
104  Symbol.KeywordCaption,
105  Symbol.KeywordLink,
106  Symbol.KeywordDropdown,
107  Symbol.KeywordType,
108  Symbol.KeywordContent
109  });
110 
111  if (Nodes.Count(n => n.Symbol == Symbol.KeywordDropdown) > 0)
112  {
113  type = MenuItemType.Dropdown;
114  }
115  else if (Nodes.Count(n => n.Symbol == Symbol.KeywordPage) > 0)
116  {
117  type = MenuItemType.Page;
118  }
119  else if (Nodes.Count(n => n.Symbol == Symbol.KeywordLink) > 0)
120  {
121  type = MenuItemType.Link;
122  }
123  else
124  {
125  CheckAllIsPresent(new List<Symbol> {Symbol.KeywordType});
126  }
127  }
override void Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.ValidateReferences ( SymbolTable  table)
inlineprotected

Definition at line 129 of file MenuItemSyntaxNode.cs.

References Ntp.Analyzer.Config.Table.Keyword.Find(), Ntp.Analyzer.Config.Table.SymbolTable.Lookup(), and Ntp.Analyzer.Config.Table.Keyword.Name.

130  {
131  var pageName = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordPage) as StringSettingNode;
132  if (pageName != null)
133  {
134  string keyword = Keyword.Find(Symbol.KeywordItem).Name;
135  var reference = table.Lookup(pageName.Value);
136  if (reference == null)
137  {
138  AddReferenceNameError(pageName, keyword, pageName.Value);
139  }
140  }
141 
142  var link = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordLink) as StringSettingNode;
143  if (link == null)
144  return;
145 
146  var linkKeyword = Keyword.Find(Symbol.KeywordLink).Name;
147  location = CheckLink(link.Value, linkKeyword);
148  }
static Keyword Find(Symbol symbol)
Definition: Keyword.cs:216
void AddReferenceNameError(ISyntaxNode node, string keyword, string name)
Definition: SyntaxNode.cs:428
ISyntaxNode Lookup(string name)
Definition: SymbolTable.cs:41

Here is the call graph for this function:

override void Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.ValidateTypes ( )
inlineprotectedvirtual

Override to validates the types in this syntax node.

When overriding this method do not call the base method.

Reimplemented from Ntp.Analyzer.Config.Syntax.SyntaxNode< MenuItemConfiguration >.

Definition at line 150 of file MenuItemSyntaxNode.cs.

151  {
152  CheckTypeIs<StringSettingNode>(Symbol.KeywordPage);
153  CheckTypeIs<StringSettingNode>(Symbol.KeywordCaption);
154  CheckTypeIs<StringSettingNode>(Symbol.KeywordLink);
155  CheckTypeIs<StringSettingNode>(Symbol.KeywordDropdown);
156  CheckTypeIs<MenuItemTypeNode>(Symbol.KeywordType);
157  }

Member Data Documentation

ISyntaxNode Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.linkable
private

Definition at line 40 of file MenuItemSyntaxNode.cs.

Uri Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.location
private

Definition at line 42 of file MenuItemSyntaxNode.cs.

MenuItemType Ntp.Analyzer.Config.Syntax.MenuItemSyntaxNode.type
private

Definition at line 43 of file MenuItemSyntaxNode.cs.


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