@Test public void test() throws Exception { SeChecksDispatcher seChecksDispatcher = new SeChecksDispatcher(ImmutableList.of(new TestSeCheck())); List<Issue> issues = seChecksDispatcher.scanFile(createContext(TestUtils.createTestInputFile("src/test/resources/se/se_dispatcher_test.js"))); assertThat(issues).hasSize(4); assertThat(((PreciseIssue) issues.get(0)).primaryLocation().message()).isEqualTo("Start of execution"); assertThat(((PreciseIssue) issues.get(1)).primaryLocation().message()).isEqualTo("before element"); assertThat(((PreciseIssue) issues.get(2)).primaryLocation().message()).isEqualTo("after element"); assertThat(((PreciseIssue) issues.get(3)).primaryLocation().message()).isEqualTo("End of execution"); }
@Override public List<Issue> scanFile(TreeVisitorContext context) { if (checks.isEmpty()) { return new ArrayList<>(); } for (SeCheck check : checks) { check.setContext(context); } super.scanFile(context); Builder<Issue> builder = ImmutableList.builder(); for (SeCheck check : checks) { builder.addAll(check.scanFile(getContext())); } return builder.build(); }
SeChecksDispatcher extends SubscriptionVisitorCheck { @Override public List<Issue> scanFile(TreeVisitorContext context) { if (checks.isEmpty()) { return new ArrayList<>(); } for (SeCheck check : checks) { check.setContext(context); } super.scanFile(context); Builder<Issue> builder = ImmutableList.builder(); for (SeCheck check : checks) { builder.addAll(check.scanFile(getContext())); } return builder.build(); } }
SeChecksDispatcher extends SubscriptionVisitorCheck { @Override public List<Issue> scanFile(TreeVisitorContext context) { if (checks.isEmpty()) { return new ArrayList<>(); } for (SeCheck check : checks) { check.setContext(context); } super.scanFile(context); Builder<Issue> builder = ImmutableList.builder(); for (SeCheck check : checks) { builder.addAll(check.scanFile(getContext())); } return builder.build(); } SeChecksDispatcher(List<SeCheck> checks); }
SeChecksDispatcher extends SubscriptionVisitorCheck { @Override public List<Issue> scanFile(TreeVisitorContext context) { if (checks.isEmpty()) { return new ArrayList<>(); } for (SeCheck check : checks) { check.setContext(context); } super.scanFile(context); Builder<Issue> builder = ImmutableList.builder(); for (SeCheck check : checks) { builder.addAll(check.scanFile(getContext())); } return builder.build(); } SeChecksDispatcher(List<SeCheck> checks); @Override Set<Kind> nodesToVisit(); @Override void visitNode(Tree tree); @Override void leaveNode(Tree tree); @Override List<Issue> scanFile(TreeVisitorContext context); }
SeChecksDispatcher extends SubscriptionVisitorCheck { @Override public List<Issue> scanFile(TreeVisitorContext context) { if (checks.isEmpty()) { return new ArrayList<>(); } for (SeCheck check : checks) { check.setContext(context); } super.scanFile(context); Builder<Issue> builder = ImmutableList.builder(); for (SeCheck check : checks) { builder.addAll(check.scanFile(getContext())); } return builder.build(); } SeChecksDispatcher(List<SeCheck> checks); @Override Set<Kind> nodesToVisit(); @Override void visitNode(Tree tree); @Override void leaveNode(Tree tree); @Override List<Issue> scanFile(TreeVisitorContext context);  }