Java Code Examples for com.puppycrawl.tools.checkstyle.api.AuditEvent#getLine()
The following examples show how to use
com.puppycrawl.tools.checkstyle.api.AuditEvent#getLine() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiffLineFilter.java From diff-check with GNU Lesser General Public License v2.1 | 6 votes |
/** * Only accept events that corresponding to the diff edits * * @return True if the event is corresponding to the diff edits */ @Override public boolean accept(AuditEvent event) { List<Edit> editList = fileEditMap.get(event.getFileName()); if (CollectionUtils.isEmpty(editList)) { return false; } for (Edit edit : editList) { if (edit.getBeginB() < event.getLine() && edit.getEndB() >= event.getLine()) { return true; } if (isEmptyLineSeparatorCheck(event) && event.getLine() == edit.getEndB() + 1) { return true; } } return false; }
Example 2
Source File: Auditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Calculates the offset information for the editor annotations. * * @param error * the audit error * @param markerAttributes * the marker attributes */ private void calculateMarkerOffset(AuditEvent error, Map<String, Object> markerAttributes) { // lazy create the document for the current file if (mDocument == null) { mDocument = connectFileBuffer(mResource); } // Provide offset information for the marker to make // annotated source code possible if (mDocument != null) { try { int line = error.getLine(); IRegion lineInformation = mDocument.getLineInformation(line == 0 ? 0 : line - 1); int lineOffset = lineInformation.getOffset(); int lineLength = lineInformation.getLength(); // annotate from the error column until the end of // the line int offset = error.getLocalizedMessage().getColumnCharIndex(); markerAttributes.put(IMarker.CHAR_START, Integer.valueOf(lineOffset + offset)); markerAttributes.put(IMarker.CHAR_END, Integer.valueOf(lineOffset + lineLength)); } catch (BadLocationException e) { // seems to happen quite often so its no use to log since we // can't do anything about it // CheckstyleLog.log(e); } } }
Example 3
Source File: CheckstyleAuditListener.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
@VisibleForTesting static int getLineId(AuditEvent event) { int result = 1; try { final int eventLine = event.getLine(); if (eventLine > 0) { result = eventLine; } } catch (Exception ex) { LOG.warn("AuditEvent is created incorrectly. Exception happen during getLine()", ex); } return result; }
Example 4
Source File: CoderadarAuditListener.java From coderadar with MIT License | 5 votes |
@Override public void addError(AuditEvent evt) { if (evt.getSeverityLevel() != SeverityLevel.IGNORE) { Metric metric = new Metric("checkstyle:" + evt.getSourceName()); Finding finding = new Finding( evt.getLine(), evt.getLine(), evt.getColumn(), evt.getColumn(), evt.getMessage()); Long metricCount = metricCountExtractor.extractMetricCount(evt); metrics.addFinding(metric, finding, metricCount); } }
Example 5
Source File: RepositoryMinerAudit.java From repositoryminer with Apache License 2.0 | 5 votes |
@Override public void addError(AuditEvent event) { int checkerIndex = event.getSourceName().lastIndexOf('.') + 1; StyleProblem sp = new StyleProblem(event.getLine(), event.getColumn(), event.getMessage(), event.getSeverityLevel().getName(), event.getSourceName().substring(checkerIndex)); fileErrors.get(currFile).add(sp); }