@Override @NonNull public Location getValueLocation(@NonNull XmlContext context, @NonNull Attr node) { Location location = getLocation(context, node); Position start = location.getStart(); Position end = location.getEnd(); if (start == null || end == null) { return location; } int totalLength = end.getOffset() - start.getOffset(); int length = node.getValue().length(); int delta = totalLength - 1 - length; int startOffset = start.getOffset() + delta; int startColumn = start.getColumn() + delta; return Location.create(location.getFile(), new DefaultPosition(start.getLine(), startColumn, startOffset), new DefaultPosition(end.getLine(), startColumn + length, startOffset + length)); }
if (message != null && !message.isEmpty()) { Position start = l.getStart(); int line = start != null ? start.getLine() : -1; String path = client.getDisplayPath(warning.project, l.getFile()); writeLocation(l.getFile(), path, line); if (s.length() > 0) { writer.write("<pre class=\"errorlines\">\n"); int offset = start != null ? start.getOffset() : -1; appendCodeBlock(s, line, offset); writer.write("\n</pre>"); while (l != null) { Position start = l.getStart(); int line = start != null ? start.getLine() : -1; String path = client.getDisplayPath(warning.project, l.getFile()); writer.write("<li> ");
private static Location refineLocation(Context context, Location location, String formatString, int substringStart, int substringEnd) { Position startLocation = location.getStart(); Position endLocation = location.getEnd(); if (startLocation != null && endLocation != null) { int startOffset = startLocation.getOffset(); int endOffset = endLocation.getOffset(); if (startOffset >= 0) { String contents = context.getClient().readFile(location.getFile()); if (endOffset <= contents.length() && startOffset < endOffset) { int formatOffset = contents.indexOf(formatString, startOffset); if (formatOffset != -1 && formatOffset <= endOffset) { return Location.create(location.getFile(), contents, formatOffset + substringStart, formatOffset + substringEnd); } } } } return location; }
Position start = currentLocation.getStart(); if (start != null) { int line = start.getLine(); if (line >= 0) {
if (message != null && !message.isEmpty()) { Position start = l.getStart(); int line = start != null ? start.getLine() : -1; String path = client .getDisplayPath(warning.project, l.getFile()); CharSequence s = client.readFile(l.getFile()); if (s.length() > 0) { int offset = start != null ? start.getOffset() : -1; appendCodeBlock(l.getFile(), s, offset, -1, warning.severity); while (l != null) { Position start = l.getStart(); int line = start != null ? start.getLine() : -1; String path = client .getDisplayPath(warning.project, l.getFile());
private static Location refineLocation(Context context, Location location, String formatString, int substringStart, int substringEnd) { Position startLocation = location.getStart(); Position endLocation = location.getEnd(); if (startLocation != null && endLocation != null) { int startOffset = startLocation.getOffset(); int endOffset = endLocation.getOffset(); if (startOffset >= 0) { CharSequence contents = context.getClient().readFile(location.getFile()); if (endOffset <= contents.length() && startOffset < endOffset) { int formatOffset = indexOf(contents, formatString, startOffset); if (formatOffset != -1 && formatOffset <= endOffset) { return Location.create(location.getFile(), contents, formatOffset + substringStart, formatOffset + substringEnd); } } } } return location; }
@Override @NonNull public Location getNameLocation(@NonNull XmlContext context, @NonNull Node node) { Location location = getLocation(context, node); Position start = location.getStart(); Position end = location.getEnd(); if (start == null || end == null) { return location; } int delta = node instanceof Element ? 1 : 0; // Elements: skip "<" int length = node.getNodeName().length(); int startOffset = start.getOffset() + delta; int startColumn = start.getColumn() + delta; return Location.create(location.getFile(), new DefaultPosition(start.getLine(), startColumn, startOffset), new DefaultPosition(end.getLine(), startColumn + length, startOffset + length)); }
@Override @NonNull public Location getNameLocation(@NonNull JavaContext context, @NonNull Node node) { // The range on method name identifiers is wrong in the ECJ nodes; just take start of // name + length of name if (node instanceof MethodDeclaration) { MethodDeclaration declaration = (MethodDeclaration) node; Identifier identifier = declaration.astMethodName(); Location location = getLocation(context, identifier); com.android.tools.lint.detector.api.Position start = location.getStart(); com.android.tools.lint.detector.api.Position end = location.getEnd(); int methodNameLength = identifier.astValue().length(); if (start != null && end != null && end.getOffset() - start.getOffset() > methodNameLength) { end = new DefaultPosition(start.getLine(), start.getColumn() + methodNameLength, start.getOffset() + methodNameLength); return Location.create(location.getFile(), start, end); } return location; } return super.getNameLocation(context, node); }
int line = startPosition.getLine(); warning.line = line; warning.offset = startPosition.getOffset(); Position endPosition = location.getEnd(); if (endPosition != null) { warning.endOffset = endPosition.getOffset(); int column = startPosition.getColumn(); if (column < 0) { column = 0; int endLine = endPosition.getLine(); int endColumn = endPosition.getColumn(); if (endLine == line && endColumn > column) { for (int i = column; i < endColumn; i++) {
int startOffset = d.astParts().first().getPosition().getStart(); Position start = location.getStart(); int startColumn = start.getColumn(); int startLine = start.getLine(); start = new DefaultPosition(startLine, startColumn + startOffset - start.getOffset(), startOffset); int fqcnLength = fqcn.length(); Position end = new DefaultPosition(startLine, start.getColumn() + fqcnLength, start.getOffset() + fqcnLength); location = Location.create(location.getFile(), start, end); Position existingStart = existingLocation.getStart(); if (start != null && existingStart != null && start.getLine() == existingStart.getLine()) { return true;