String getLineText(int lineNumber) { String result = cachedLines.getIfPresent(lineNumber); if (result != null) return result; if (reader.getLineNumber() > lineNumber) reader = createReader(); assert reader.getLineNumber() <= lineNumber; try { while (reader.getLineNumber() < lineNumber) { final String lineText = reader.readLine(); if (lineText == null) return null; } result = reader.readLine(); if (result == null) return null; cachedLines.put(lineNumber, result); return result; } catch (IOException e) { return null; } } }
String getLineText(int lineNumber) { String result = cachedLines.getIfPresent(lineNumber); if (result != null) return result; if (reader.getLineNumber() > lineNumber) reader = createReader(); assert reader.getLineNumber() <= lineNumber; try { while (reader.getLineNumber() < lineNumber) { final String lineText = reader.readLine(); if (lineText == null) return null; } result = reader.readLine(); if (result == null) return null; cachedLines.put(lineNumber, result); return result; } catch (IOException e) { return null; } } }
/** * Gets the text of the line specified problem occured or * <code>null</code> if there is no line information. * * @param problem problem to process * @return the text of the line or <code>null</code> if there * is no line information */ protected String getLineText(ICompilerProblem problem) { String filePath = problem.getSourcePath(); if (filePath == null) return null; int lineNumber = problem.getLine(); if (lineNumber < 0) return null; FileLineInfo fileLineInfo = readers.getUnchecked(filePath); return fileLineInfo.getLineText(lineNumber); }
/** * Gets the text of the line specified problem occured or * <code>null</code> if there is no line information. * * @param problem problem to process * @return the text of the line or <code>null</code> if there * is no line information */ protected String getLineText(ICompilerProblem problem) { String filePath = problem.getSourcePath(); if (filePath == null) return null; int lineNumber = problem.getLine(); if (lineNumber < 0) return null; FileLineInfo fileLineInfo = readers.getUnchecked(filePath); return fileLineInfo.getLineText(lineNumber); }
FileLineInfo(String fileName) { this.fileName = fileName; this.reader = createReader(); cachedLines = CacheBuilder.newBuilder() .concurrencyLevel(1) .softValues() .maximumSize(MAX_CACHED_LINES_PER_FILE) .build(); }
@Override public FileLineInfo load(String fileName) { return new FileLineInfo(fileName); } });
FileLineInfo(String fileName) { this.fileName = fileName; this.reader = createReader(); cachedLines = CacheBuilder.newBuilder() .concurrencyLevel(1) .softValues() .maximumSize(MAX_CACHED_LINES_PER_FILE) .build(); }
@Override public FileLineInfo load(String fileName) { return new FileLineInfo(fileName); } });