本文整理了Java中com.android.tools.lint.detector.api.Location.getEnd()
方法的一些代码示例,展示了Location.getEnd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Location.getEnd()
方法的具体详情如下:
包路径:com.android.tools.lint.detector.api.Location
类名称:Location
方法名:getEnd
[英]The end position of the range
[中]范围的结束位置
代码示例来源:origin: com.android.tools.lint/lint-checks
location = Location.create(context.file, start, location.getEnd());
代码示例来源:origin: com.amazon.device.tools.lint/lint-checks
location = Location.create(context.file, start, location.getEnd());
代码示例来源:origin: com.amazon.device.tools.lint/lint-checks
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;
}
代码示例来源:origin: com.android.tools.lint/lint-checks
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;
}
代码示例来源:origin: com.android.tools.lint/lint
@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));
}
代码示例来源:origin: com.android.tools.lint/lint
warning.line = line;
warning.offset = startPosition.getOffset();
Position endPosition = location.getEnd();
if (endPosition != null) {
warning.endOffset = endPosition.getOffset();
代码示例来源:origin: com.android.tools.lint/lint
@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));
}
代码示例来源:origin: com.android.tools.lint/lint
@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);
}
内容来源于网络,如有侵权,请联系作者删除!