@Test public void process_abap_single_comment() throws IOException { String codePath = path + "code/ABAP/"; List<MarkerPair> expectedPairs = createMarkerPairsOf(6, 6, 8, 6); File file = new File(codePath + "single_line_star.abap"); List<MarkerPair> actualPairs = analyzerToTest.processFile(file); assertThat(actualPairs, is(expectedPairs)); }
public List<MarkerPair> processFile(File file) throws FileNotFoundException, IOException { List<MarkerPair> markerPairs = new LinkedList<>(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { String line = null; int lineNumber = 0; Marker start = null; Marker end = null; while ((line = bufferedReader.readLine()) != null) { lineNumber++; int noSecHubIndex = line.indexOf(NOSECHUB); if (noSecHubIndex == -1) { continue; } boolean isComment = commentChecker.isCommentInLine(line); if (!isComment) { continue; } int endNoSecHubIndex = line.indexOf(NOSECHUB_END); if (endNoSecHubIndex > -1) { end = new Marker(MarkerType.END, lineNumber, endNoSecHubIndex); } else { if (start == null) { start = new Marker(MarkerType.START, lineNumber, noSecHubIndex); } } if (start != null && end != null) { MarkerPair pair = new MarkerPair(); pair.setStart(start); pair.setEnd(end); markerPairs.add(pair); start = null; end = null; } } } return markerPairs; }
FileProcessor { public List<MarkerPair> processFile(File file) throws FileNotFoundException, IOException { List<MarkerPair> markerPairs = new LinkedList<>(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { String line = null; int lineNumber = 0; Marker start = null; Marker end = null; while ((line = bufferedReader.readLine()) != null) { lineNumber++; int noSecHubIndex = line.indexOf(NOSECHUB); if (noSecHubIndex == -1) { continue; } boolean isComment = commentChecker.isCommentInLine(line); if (!isComment) { continue; } int endNoSecHubIndex = line.indexOf(NOSECHUB_END); if (endNoSecHubIndex > -1) { end = new Marker(MarkerType.END, lineNumber, endNoSecHubIndex); } else { if (start == null) { start = new Marker(MarkerType.START, lineNumber, noSecHubIndex); } } if (start != null && end != null) { MarkerPair pair = new MarkerPair(); pair.setStart(start); pair.setEnd(end); markerPairs.add(pair); start = null; end = null; } } } return markerPairs; } }
FileProcessor { public List<MarkerPair> processFile(File file) throws FileNotFoundException, IOException { List<MarkerPair> markerPairs = new LinkedList<>(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { String line = null; int lineNumber = 0; Marker start = null; Marker end = null; while ((line = bufferedReader.readLine()) != null) { lineNumber++; int noSecHubIndex = line.indexOf(NOSECHUB); if (noSecHubIndex == -1) { continue; } boolean isComment = commentChecker.isCommentInLine(line); if (!isComment) { continue; } int endNoSecHubIndex = line.indexOf(NOSECHUB_END); if (endNoSecHubIndex > -1) { end = new Marker(MarkerType.END, lineNumber, endNoSecHubIndex); } else { if (start == null) { start = new Marker(MarkerType.START, lineNumber, noSecHubIndex); } } if (start != null && end != null) { MarkerPair pair = new MarkerPair(); pair.setStart(start); pair.setEnd(end); markerPairs.add(pair); start = null; end = null; } } } return markerPairs; } FileProcessor(); }
FileProcessor { public List<MarkerPair> processFile(File file) throws FileNotFoundException, IOException { List<MarkerPair> markerPairs = new LinkedList<>(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { String line = null; int lineNumber = 0; Marker start = null; Marker end = null; while ((line = bufferedReader.readLine()) != null) { lineNumber++; int noSecHubIndex = line.indexOf(NOSECHUB); if (noSecHubIndex == -1) { continue; } boolean isComment = commentChecker.isCommentInLine(line); if (!isComment) { continue; } int endNoSecHubIndex = line.indexOf(NOSECHUB_END); if (endNoSecHubIndex > -1) { end = new Marker(MarkerType.END, lineNumber, endNoSecHubIndex); } else { if (start == null) { start = new Marker(MarkerType.START, lineNumber, noSecHubIndex); } } if (start != null && end != null) { MarkerPair pair = new MarkerPair(); pair.setStart(start); pair.setEnd(end); markerPairs.add(pair); start = null; end = null; } } } return markerPairs; } FileProcessor(); List<MarkerPair> processFile(File file); }
FileProcessor { public List<MarkerPair> processFile(File file) throws FileNotFoundException, IOException { List<MarkerPair> markerPairs = new LinkedList<>(); try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { String line = null; int lineNumber = 0; Marker start = null; Marker end = null; while ((line = bufferedReader.readLine()) != null) { lineNumber++; int noSecHubIndex = line.indexOf(NOSECHUB); if (noSecHubIndex == -1) { continue; } boolean isComment = commentChecker.isCommentInLine(line); if (!isComment) { continue; } int endNoSecHubIndex = line.indexOf(NOSECHUB_END); if (endNoSecHubIndex > -1) { end = new Marker(MarkerType.END, lineNumber, endNoSecHubIndex); } else { if (start == null) { start = new Marker(MarkerType.START, lineNumber, noSecHubIndex); } } if (start != null && end != null) { MarkerPair pair = new MarkerPair(); pair.setStart(start); pair.setEnd(end); markerPairs.add(pair); start = null; end = null; } } } return markerPairs; } FileProcessor(); List<MarkerPair> processFile(File file);  }