/** * Constructs a new {@link DefaultLocationHandle} * * @param context the context pointing to the file and its contents * @param startOffset the start offset within the file * @param endOffset the end offset within the file */ public DefaultLocationHandle(@NonNull Context context, int startOffset, int endOffset) { file = context.file; contents = context.getContents(); this.startOffset = startOffset; this.endOffset = endOffset; }
private String getText(ASTNode node) { String source = context.getContents(); Pair<Integer, Integer> offsets = getOffsets(node, context); return source.substring(offsets.getFirst(), offsets.getSecond()); } };
@Override public void run(Context context) { String contents = context.getContents(); if (contents != null) { int index = contents.indexOf( // Old pattern: "-keepclasseswithmembernames class * {\n" + //$NON-NLS-1$ " public <init>(android."); //$NON-NLS-1$ if (index != -1) { context.client.report(context, ISSUE, context.getLocation(context), "Obsolete proguard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames", null); } } }
@Override public void run(@NonNull Context context) { String contents = context.getContents(); if (contents == null) { return; } int offset = 0; Iterator<String> iterator = Splitter.on('\n').split(contents).iterator(); String line; for (; iterator.hasNext(); offset += line.length() + 1) { line = iterator.next(); if (line.startsWith("#") || line.startsWith(" ")) { continue; } if (line.indexOf('\\') == -1 && line.indexOf(':') == -1) { continue; } int valueStart = line.indexOf('=') + 1; if (valueStart == 0) { continue; } checkLine(context, contents, line, offset, valueStart); } }
@Override public void run(@NonNull Context context) { CharSequence contents = context.getContents(); if (contents == null) { return; } int offset = 0; Iterator<String> iterator = Splitter.on('\n').split(contents).iterator(); String line; for (; iterator.hasNext(); offset += line.length() + 1) { line = iterator.next(); if (line.startsWith("#") || line.startsWith(" ")) { continue; } if (line.indexOf('\\') == -1 && line.indexOf(':') == -1) { continue; } int valueStart = line.indexOf('=') + 1; if (valueStart == 0) { continue; } checkLine(context, contents, line, offset, valueStart); } }
/** Returns whether this file contains any suppress comment markers */ public boolean containsCommentSuppress() { if (containsCommentSuppress == null) { containsCommentSuppress = false; String prefix = getSuppressCommentPrefix(); if (prefix != null) { CharSequence contents = getContents(); if (contents != null) { containsCommentSuppress = indexOf(contents, prefix) != -1; } } } return containsCommentSuppress; }
CharSequence contents = getContents(); assert contents != null; // otherwise we wouldn't be here if (startOffset >= contents.length()) {
@Override public void run(@NonNull Context context) { String contents = context.getContents(); if (contents != null) { if (context.isEnabled(WRONG_KEEP)) {
private void visitQuietly(@NonNull final Context context, Map<String, Object> sharedData) { CharSequence sequence = context.getContents(); if (sequence == null) { return;
String source = context.getContents(); assert source != null; // because we successfully parsed int start = 0;
CharSequence source = context.getContents(); assert source != null; // because we successfully parsed int start = 0;
private void visitQuietly(@NonNull final Context context, Map<String, Object> sharedData) { String source = context.getContents(); if (source == null) { return;
@Override public void run(@NonNull Context context) { CharSequence contents = context.getContents(); if (contents != null) { if (context.isEnabled(WRONG_KEEP)) {
CharSequence source = context.getContents(); if (source == null) { return;
warning.fileContents = context.getContents();
@Override public void beforeCheckFile(@NonNull Context context) { CharSequence source = context.getContents(); if (source == null) { return;