Пример #1
0
 public void ensureStartRuleExists(VirtualFile grammarFile) {
   PreviewState previewState =
       ANTLRv4PluginController.getInstance(project).getPreviewState(grammarFile);
   // if start rule no longer exists, reset display/state.
   if (previewState.g != ParsingUtils.BAD_PARSER_GRAMMAR && previewState.startRuleName != null) {
     Rule rule = previewState.g.getRule(previewState.startRuleName);
     if (rule == null) {
       previewState.startRuleName = null;
       inputPanel.resetStartRuleLabel();
     }
   }
 }
Пример #2
0
 public void updateParseTreeFromDoc(VirtualFile grammarFile) {
   ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(project);
   PreviewState previewState = controller.getPreviewState(grammarFile);
   LOG.info("updateParseTreeFromDoc " + grammarFile + " rule " + previewState.startRuleName);
   try {
     final String inputText = previewState.getEditor().getDocument().getText();
     ParsingResult results = controller.parseText(grammarFile, inputText);
     if (results != null) {
       updateTreeViewer(previewState, results);
     } else if (previewState.startRuleName == null) {
       indicateNoStartRuleInParseTreePane();
     } else {
       indicateInvalidGrammarInParseTreePane();
     }
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
 }