|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.tools.lint.detector.api.Detector com.android.tools.lint.detector.api.ResourceXmlDetector com.android.tools.lint.checks.StringFormatDetector
public class StringFormatDetector
Check which looks for problems with formatting strings such as inconsistencies between translations or between string declaration and string usage in Java.
TODO: Verify booleans! TODO: Handle Resources.getQuantityString as well
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.android.tools.lint.detector.api.Detector |
---|
com.android.tools.lint.detector.api.Detector.BinaryResourceScanner, com.android.tools.lint.detector.api.Detector.ClassScanner, com.android.tools.lint.detector.api.Detector.GradleScanner, com.android.tools.lint.detector.api.Detector.JavaScanner, com.android.tools.lint.detector.api.Detector.OtherFileScanner, com.android.tools.lint.detector.api.Detector.ResourceFolderScanner, com.android.tools.lint.detector.api.Detector.XmlScanner |
Field Summary | |
---|---|
static com.android.tools.lint.detector.api.Issue |
ARG_COUNT
Whether formatting argument types are consistent across translations |
static com.android.tools.lint.detector.api.Issue |
ARG_TYPES
Whether the string format supplied in a call to String.format matches the format string |
static com.android.tools.lint.detector.api.Issue |
INVALID
Whether formatting strings are invalid |
Fields inherited from interface com.android.tools.lint.detector.api.Detector.XmlScanner |
---|
ALL |
Constructor Summary | |
---|---|
StringFormatDetector()
Constructs a new StringFormatDetector check |
Method Summary | |
---|---|
void |
afterCheckProject(com.android.tools.lint.detector.api.Context context)
|
boolean |
appliesTo(com.android.tools.lint.detector.api.Context context,
java.io.File file)
|
boolean |
appliesTo(com.android.resources.ResourceFolderType folderType)
|
java.util.Collection<java.lang.String> |
getApplicableElements()
|
java.util.List<java.lang.String> |
getApplicableMethodNames()
|
static lombok.ast.Node |
getParentMethod(lombok.ast.Node node)
Returns the parent method of the given AST node |
static java.lang.String |
getResourceArg(lombok.ast.Node method,
lombok.ast.Node call,
int argIndex)
Returns the resource name corresponding to the given argument in the given call |
static java.lang.String |
getResourceForFirstArg(lombok.ast.Node method,
lombok.ast.Node call)
Returns the resource name corresponding to the first argument in the given call |
static boolean |
isLocaleSpecific(java.lang.String format)
Determines whether the given String.format(String, Object...)
formatting string is "locale dependent", meaning that its output depends
on the locale. |
void |
visitElement(com.android.tools.lint.detector.api.XmlContext context,
org.w3c.dom.Element element)
|
void |
visitMethod(com.android.tools.lint.detector.api.JavaContext context,
lombok.ast.AstVisitor visitor,
lombok.ast.MethodInvocation node)
|
Methods inherited from class com.android.tools.lint.detector.api.ResourceXmlDetector |
---|
run |
Methods inherited from class com.android.tools.lint.detector.api.Detector |
---|
afterCheckFile, afterCheckLibraryProject, appliesToFolder, appliesToResourceRefs, beforeCheckFile, beforeCheckLibraryProject, beforeCheckProject, checkBinaryResource, checkCall, checkClass, checkFolder, checkInstruction, createJavaVisitor, getApplicableAsmNodeTypes, getApplicableAttributes, getApplicableCallNames, getApplicableCallOwners, getApplicableFiles, getApplicableNodeTypes, getSpeed, getSpeed, visitAttribute, visitBuildScript, visitDocument, visitElementAfter, visitResourceReference |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.android.tools.lint.detector.api.Detector.JavaScanner |
---|
appliesToResourceRefs, createJavaVisitor, getApplicableNodeTypes, visitResourceReference |
Methods inherited from interface com.android.tools.lint.detector.api.Detector.XmlScanner |
---|
getApplicableAttributes, visitAttribute, visitDocument, visitElementAfter |
Field Detail |
---|
public static final com.android.tools.lint.detector.api.Issue INVALID
public static final com.android.tools.lint.detector.api.Issue ARG_COUNT
public static final com.android.tools.lint.detector.api.Issue ARG_TYPES
Constructor Detail |
---|
public StringFormatDetector()
StringFormatDetector
check
Method Detail |
---|
public boolean appliesTo(@NonNull com.android.resources.ResourceFolderType folderType)
appliesTo
in class com.android.tools.lint.detector.api.ResourceXmlDetector
public boolean appliesTo(@NonNull com.android.tools.lint.detector.api.Context context, @NonNull java.io.File file)
appliesTo
in class com.android.tools.lint.detector.api.ResourceXmlDetector
public java.util.Collection<java.lang.String> getApplicableElements()
getApplicableElements
in interface com.android.tools.lint.detector.api.Detector.XmlScanner
getApplicableElements
in class com.android.tools.lint.detector.api.Detector
public void visitElement(@NonNull com.android.tools.lint.detector.api.XmlContext context, @NonNull org.w3c.dom.Element element)
visitElement
in interface com.android.tools.lint.detector.api.Detector.XmlScanner
visitElement
in class com.android.tools.lint.detector.api.Detector
public void afterCheckProject(@NonNull com.android.tools.lint.detector.api.Context context)
afterCheckProject
in class com.android.tools.lint.detector.api.Detector
public static boolean isLocaleSpecific(@NonNull java.lang.String format)
String.format(String, Object...)
formatting string is "locale dependent", meaning that its output depends
on the locale. This is the case if it for example references decimal
numbers of dates and times.
format
- the format string
public java.util.List<java.lang.String> getApplicableMethodNames()
getApplicableMethodNames
in interface com.android.tools.lint.detector.api.Detector.JavaScanner
getApplicableMethodNames
in class com.android.tools.lint.detector.api.Detector
public void visitMethod(@NonNull com.android.tools.lint.detector.api.JavaContext context, @Nullable lombok.ast.AstVisitor visitor, @NonNull lombok.ast.MethodInvocation node)
visitMethod
in interface com.android.tools.lint.detector.api.Detector.JavaScanner
visitMethod
in class com.android.tools.lint.detector.api.Detector
@Nullable public static lombok.ast.Node getParentMethod(@NonNull lombok.ast.Node node)
@Nullable public static java.lang.String getResourceForFirstArg(@NonNull lombok.ast.Node method, @NonNull lombok.ast.Node call)
@Nullable public static java.lang.String getResourceArg(@NonNull lombok.ast.Node method, @NonNull lombok.ast.Node call, int argIndex)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |