use of org.openide.filesystems.FileObject in project Universal-G-Code-Sender by winder.
the class GcodeParser method parse.
@Override
public void parse(Snapshot snapshot, Task task, SourceModificationEvent sourceModificationEvent) {
this.snapshot = snapshot;
FileObject fileObject = snapshot.getSource().getFileObject();
List<ErrorParser> errorParserList = new ArrayList<>();
errorParserList.add(new FeedRateMissingErrorParser(fileObject));
errorParserList.add(new InvalidGrblCommandErrorParser(fileObject));
errorParserList.add(new MovementInMachineCoordinatesErrorParser(fileObject));
errorParserList.add(new InvalidG2CommandErrorParser(fileObject));
TokenSequence<?> tokenSequence = snapshot.getTokenHierarchy().tokenSequence();
tokenSequence.moveStart();
// The snapshot starts on line 1
int line = 1;
while (tokenSequence.moveNext()) {
Token<?> token = tokenSequence.token();
if (GcodeTokenId.END_OF_LINE.equals(token.id())) {
line++;
}
final int currentLine = line;
errorParserList.forEach(errorParser -> errorParser.handleToken(token, currentLine));
}
this.errors = errorParserList.stream().flatMap(ep -> ep.getErrors().stream()).collect(Collectors.toList());
}
Aggregations