def diagnostics(self): d = [] if not self.name: d.append( Diagnostic( Severity.ERROR, self.code_range, "Give a name to your pile like: <pile veryNicePile ...>")) elif not self.type: d.append( Diagnostic( Severity.ERROR, self.code_range, f"What type of things wil go on this pile? eg: <pile {self.name} type=int ...>" )) elif not self.capacity: d.append( Diagnostic( Severity.ERROR, self.code_range, f"A pile must have a enormity: <pile {self.name} enormity=20 />" )) elif isinstance(self.capacity, int) and self.capacity < len(self.items): d.append( Diagnostic( Severity.ERROR, self.code_range, f"How can {len(self.items)} items go on a pile with an enormity of {self.capacity}?!?!" )) return d
def __link__(self, file, link_element): path = os.path.abspath(link_element.code_range.dir + file) if path in self.linked: return self.linked.append(path) try: html = open(path).read() except FileNotFoundError: self.diagnostics.append( Diagnostic(Severity.WARNING, link_element.code_range, f"'{file}' not included, file was not found")) return except PermissionError: self.diagnostics.append( Diagnostic(Severity.WARNING, link_element.code_range, f"Cannot open '{file}', permission denied")) return lexer = Lexer(utils.file_dir(path), utils.filename(path)) self.html_parser.feed(lexer, html=html) link_element.children = lexer.elements self.diagnostics.extend(lexer.diagnostics)
def diagnostics(self): d = [] if not self.var_name: d.append( Diagnostic(Severity.ERROR, self.code_range, "No variable name defined")) if not self.type or self.type == "unknown": d.append( Diagnostic( Severity.ERROR, self.code_range, "Unknown variable type" "\nPlease provide a type in the type attribute " "like <var x=y type='int'/>")) return d
def diagnostics(self): d = [] if not self.var_name: d.append( Diagnostic( Severity.ERROR, self.code_range, f"No variable name given " f"(for example: <{self.tagname} varName>123</assign>)")) elif not self.val: d.append( Diagnostic( Severity.ERROR, self.code_range, f"Usage: <{self.tagname} {self.var_name}>something" f"</{self.tagname}>")) return d
def diagnostics(self): if not self.src(): return [ Diagnostic( Severity.ERROR, self.code_range, f"Found {self.tagname} element without {self.src_attr_name()} attribute" ) ] if not self.link_type(): return [ Diagnostic( Severity.WARNING, self.code_range, f"{self.tagname} elements without type attribute are ignored." ) ] return []
def diagnostics(self): d = super().diagnostics() if not self.x: d.append( Diagnostic(Severity.ERROR, self.code_range, "Maybe element found without x-attribute")) return d
def diagnostics(self): return [] if isinstance(self.parent, Expression) else [ Diagnostic( Severity.ERROR, self.code_range, "{} element found outside of expression element".format( self.tagname)) ]
def diagnostics(self): return [] if self.name else [ Diagnostic( Severity.ERROR, self.code_range, 'Use like: <pin-mode myLed="output"/> (or input)\n' 'Where "myLed" is the name of the pin that you must have defined with a <pin> tag' ) ]
def diagnostics(self): return [] if self.name else [ Diagnostic( Severity.ERROR, self.code_range, "Pls give a Pin-name to read.\n" "eg: <digital-read myButton/>\n" "where myButton is defined at the top of the file like:\n" "<pin myButton=\"D0\"/>") ]
def diagnostics(self): d = [] if not self.nr: d.append(Diagnostic( Severity.ERROR, self.code_range, f"Specify the number like: <{self.tagname} nr3 ..> OR <{self.tagname} nr=i ..>" )) elif not self.of: d.append(Diagnostic( Severity.ERROR, self.code_range, self.of_unspecified_err_msg() )) if not self.parent.is_value_wrapper and self.is_value: d.append(Diagnostic( Severity.WARNING, self.code_range, f"Result of <{self.tagname}> is ignored" )) return d
def diagnostics(self): d = [] if not self.name: d.append( Diagnostic( Severity.ERROR, self.code_range, 'Define a pin like: <pin myLed="D3"/>\n' "Where myLed is the pin-name and D3 means the third bit of PORTD" )) return d
def diagnostics(self): d = [] for el in self.children: if not isinstance(el, Param): continue if not el.name: d.append( Diagnostic(Severity.ERROR, el.code_range, "Param without name")) return d
def diagnostics(self): return ( super().diagnostics() if self.to or not self.of or not self.nr else [*super().diagnostics(), Diagnostic( Severity.ERROR, self.code_range, f"Pls say what the thing should be upgraded to.\n" "eg: <upgrade to>upgradeToThis</upgrade" )] )
def finish_parsing(self): """ Called when reading the HTML file is done. If there is still an open element (self.current_element != None) it means that there's an unclosed element somewhere in the file """ if self.current_element: self.diagnostics.append( Diagnostic( Severity.ERROR, self.current_element.code_range, f"Unclosed element <{self.current_element.tagname}>\n" f"Did you mean <{self.current_element.tagname} " f"...attributes... /> ?"))
def handle_closingtag(self, tagname, line, char, endchar): """ End of element found. self.current_element = self.current_element.parent """ if self.current_element and tagname == self.current_element.tagname: self.current_element.code_range.endline = line self.current_element.code_range.endchar = endchar self.current_element = self.current_element.parent elif self.current_element: self.diagnostics.append( Diagnostic( Severity.ERROR, CodeRange(self.dir, self.filename, line, char, line, endchar), f"Expected closing tag: </{self.current_element.tagname}>\n" f"Got: </{tagname}>")) else: self.diagnostics.append( Diagnostic( Severity.ERROR, CodeRange(self.dir, self.filename, line, char, line, endchar), f"Unexpected closing tag </{tagname}>"))
def handle_invalid_tag(self, line, char, endchar): self.diagnostics.append( Diagnostic( Severity.ERROR, CodeRange(self.dir, self.filename, line, char, line, endchar), f"Invalid tag"))
def diagnostics(self): return [] if self.type or not isinstance(self.parent, Def) else [ Diagnostic(Severity.ERROR, self.code_range, "Unkown param type") ]
def diagnostics(self): return [] if self.x else [ Diagnostic(Severity.ERROR, self.code_range, "Expression element without x attribute") ]
def diagnostics(self): return [] if self.data else [Diagnostic( Severity.ERROR, self.code_range, "Please provide bool name like: <lie>iAmSmart</lie>" )]
def diagnostics(self): return [] if self.name else [ Diagnostic(Severity.ERROR, self.code_range, "Use like: <digital-write myLed>cake</digital-write>") ]