@@ -349,63 +349,11 @@ ${option.description}
349349 return ;
350350 }
351351 const script = `
352- import configparser
353- import glob
354352import json
355353
356- from platformio import fs
357- from platformio.project import exception
358354from platformio.public import ProjectConfig
359355
360-
361- # remove this code for PIO Core 6.1.8+
362- class TmpProjectConfig(ProjectConfig):
363- def read(self, path, parse_extra=True):
364- if path in self._parsed:
365- return
366- self._parsed.append(path)
367- try:
368- self._parser.read(path, "utf-8")
369- except configparser.Error as exc:
370- raise exception.InvalidProjectConfError(path, str(exc)) from exc
371- if not parse_extra:
372- return
373- # load extra configs
374- for pattern in self.get("platformio", "extra_configs", []):
375- if pattern.startswith("~"):
376- pattern = fs.expanduser(pattern)
377- for item in glob.glob(pattern, recursive=True):
378- self.read(item)
379-
380-
381- errors = []
382- warnings = []
383-
384- try:
385- config = TmpProjectConfig()
386- config.validate(silent=True)
387- warnings = config.warnings
388- config.as_tuple()
389- except Exception as exc:
390- if exc.__cause__:
391- exc = exc.__cause__
392- item = {"type": exc.__class__.__name__, "message": str(exc)}
393- for attr in ("lineno", "source"):
394- if hasattr(exc, attr):
395- item[attr] = getattr(exc, attr)
396- errors.append(item)
397- if item["type"] == "ParsingError" and hasattr(exc, "errors"):
398- for lineno, line in getattr(exc, "errors"):
399- errors.append(
400- {
401- "type": item["type"],
402- "message": f"Parsing error: {line}",
403- "lineno": lineno,
404- "source": item["source"]
405- }
406- )
407-
408- print(json.dumps(dict(errors=errors, warnings=warnings)))
356+ print(json.dumps(ProjectConfig.lint()))
409357 ` ;
410358 this . diagnosticCollection . clear ( ) ;
411359 const projectDir = path . dirname ( uri . fsPath ) ;
0 commit comments