本文整理汇总了Java中com.android.tools.lint.detector.api.Location.getStart方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getStart方法的具体用法?Java Location.getStart怎么用?Java Location.getStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.tools.lint.detector.api.Location
的用法示例。
在下文中一共展示了Location.getStart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refineLocation
import com.android.tools.lint.detector.api.Location; //导入方法依赖的package包/类
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;
}
示例2: getNameLocation
import com.android.tools.lint.detector.api.Location; //导入方法依赖的package包/类
@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));
}
示例3: getValueLocation
import com.android.tools.lint.detector.api.Location; //导入方法依赖的package包/类
@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));
}