@Test public void invalid_command() { exceptionRule.expect(ParseException.class); exceptionRule.expectMessage(containsString("Cannot run program \"invalid-command\"")); GoConverter.Command command = mock(GoConverter.Command.class); when(command.getCommand()).thenReturn(Collections.singletonList("invalid-command")); GoConverter converter = new GoConverter(command); converter.parse("package main\nfunc foo() {}"); }
@Override public Tree parse(String content) { if (content.length() > MAX_SUPPORTED_SOURCE_FILE_SIZE) { throw new ParseException("The file size is too big and should be excluded," + " its size is " + content.length() + " (maximum allowed is " + MAX_SUPPORTED_SOURCE_FILE_SIZE + " bytes)"); } try { return JsonTree.fromJson(executeGoToJsonProcess(content)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ParseException("Go parser external process interrupted: " + e.getMessage(), null, e); } catch (IOException e) { throw new ParseException(e.getMessage(), null, e); } }
GoConverter implements ASTConverter { @Override public Tree parse(String content) { if (content.length() > MAX_SUPPORTED_SOURCE_FILE_SIZE) { throw new ParseException("The file size is too big and should be excluded," + " its size is " + content.length() + " (maximum allowed is " + MAX_SUPPORTED_SOURCE_FILE_SIZE + " bytes)"); } try { return JsonTree.fromJson(executeGoToJsonProcess(content)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ParseException("Go parser external process interrupted: " + e.getMessage(), null, e); } catch (IOException e) { throw new ParseException(e.getMessage(), null, e); } } }
GoConverter implements ASTConverter { @Override public Tree parse(String content) { if (content.length() > MAX_SUPPORTED_SOURCE_FILE_SIZE) { throw new ParseException("The file size is too big and should be excluded," + " its size is " + content.length() + " (maximum allowed is " + MAX_SUPPORTED_SOURCE_FILE_SIZE + " bytes)"); } try { return JsonTree.fromJson(executeGoToJsonProcess(content)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ParseException("Go parser external process interrupted: " + e.getMessage(), null, e); } catch (IOException e) { throw new ParseException(e.getMessage(), null, e); } } GoConverter(File workDir);   GoConverter(Command command); }
GoConverter implements ASTConverter { @Override public Tree parse(String content) { if (content.length() > MAX_SUPPORTED_SOURCE_FILE_SIZE) { throw new ParseException("The file size is too big and should be excluded," + " its size is " + content.length() + " (maximum allowed is " + MAX_SUPPORTED_SOURCE_FILE_SIZE + " bytes)"); } try { return JsonTree.fromJson(executeGoToJsonProcess(content)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ParseException("Go parser external process interrupted: " + e.getMessage(), null, e); } catch (IOException e) { throw new ParseException(e.getMessage(), null, e); } } GoConverter(File workDir);   GoConverter(Command command); @Override Tree parse(String content); }
GoConverter implements ASTConverter { @Override public Tree parse(String content) { if (content.length() > MAX_SUPPORTED_SOURCE_FILE_SIZE) { throw new ParseException("The file size is too big and should be excluded," + " its size is " + content.length() + " (maximum allowed is " + MAX_SUPPORTED_SOURCE_FILE_SIZE + " bytes)"); } try { return JsonTree.fromJson(executeGoToJsonProcess(content)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ParseException("Go parser external process interrupted: " + e.getMessage(), null, e); } catch (IOException e) { throw new ParseException(e.getMessage(), null, e); } } GoConverter(File workDir);   GoConverter(Command command); @Override Tree parse(String content);  }