com.android.tools.lint.checks
Class TypoDetector

java.lang.Object
  extended by com.android.tools.lint.detector.api.Detector
      extended by com.android.tools.lint.detector.api.ResourceXmlDetector
          extended by com.android.tools.lint.checks.TypoDetector
All Implemented Interfaces:
com.android.tools.lint.detector.api.Detector.XmlScanner

public class TypoDetector
extends com.android.tools.lint.detector.api.ResourceXmlDetector

Check which looks for likely typos in Strings.

TODO:


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 ISSUE
          The main issue discovered by this detector
 
Fields inherited from interface com.android.tools.lint.detector.api.Detector.XmlScanner
ALL
 
Constructor Summary
TypoDetector()
          Constructs a new detector
 
Method Summary
 boolean appliesTo(com.android.resources.ResourceFolderType folderType)
           
 void beforeCheckFile(com.android.tools.lint.detector.api.Context context)
           
 java.util.Collection<java.lang.String> getApplicableElements()
           
static com.android.utils.Pair<java.lang.String,java.lang.String> getLocale(java.lang.String parent)
          Returns the locale for the given parent folder.
static com.android.utils.Pair<java.lang.String,java.lang.String> getLocale(com.android.tools.lint.detector.api.XmlContext context)
          Returns the locale for the given context.
 com.android.tools.lint.detector.api.Speed getSpeed()
           
static java.util.List<java.lang.String> getSuggestions(java.lang.String errorMessage, com.android.tools.lint.detector.api.TextFormat format)
          Returns the suggested replacements, if any, for the given typo.
static java.lang.String getTypo(java.lang.String errorMessage, com.android.tools.lint.detector.api.TextFormat format)
          Returns the typo word in the error message from this detector
 void visitElement(com.android.tools.lint.detector.api.XmlContext context, org.w3c.dom.Element element)
           
 
Methods inherited from class com.android.tools.lint.detector.api.ResourceXmlDetector
appliesTo, run
 
Methods inherited from class com.android.tools.lint.detector.api.Detector
afterCheckFile, afterCheckLibraryProject, afterCheckProject, applicableSuperClasses, appliesToFolder, appliesToResourceRefs, beforeCheckLibraryProject, beforeCheckProject, checkBinaryResource, checkCall, checkClass, checkClass, checkFolder, checkInstruction, createJavaVisitor, getApplicableAsmNodeTypes, getApplicableAttributes, getApplicableCallNames, getApplicableCallOwners, getApplicableFiles, getApplicableMethodNames, getApplicableNodeTypes, getSpeed, visitAttribute, visitBuildScript, visitDocument, visitElementAfter, visitMethod, 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.XmlScanner
getApplicableAttributes, visitAttribute, visitDocument, visitElementAfter
 

Field Detail

ISSUE

public static final com.android.tools.lint.detector.api.Issue ISSUE
The main issue discovered by this detector

Constructor Detail

TypoDetector

public TypoDetector()
Constructs a new detector

Method Detail

appliesTo

public boolean appliesTo(@NonNull
                         com.android.resources.ResourceFolderType folderType)
Overrides:
appliesTo in class com.android.tools.lint.detector.api.ResourceXmlDetector

getLocale

@Nullable
public static com.android.utils.Pair<java.lang.String,java.lang.String> getLocale(@NonNull
                                                                                           java.lang.String parent)
Returns the locale for the given parent folder.

Parameters:
parent - the name of the parent folder
Returns:
null if the locale is not known, or a pair of language and region where one or the other but not both can be null

getLocale

@Nullable
public static com.android.utils.Pair<java.lang.String,java.lang.String> getLocale(@NonNull
                                                                                           com.android.tools.lint.detector.api.XmlContext context)
Returns the locale for the given context.

Parameters:
context - the context to look up the locale for
Returns:
null if the locale is not known, or a pair of language and region where one or the other but not both can be null

beforeCheckFile

public void beforeCheckFile(@NonNull
                            com.android.tools.lint.detector.api.Context context)
Overrides:
beforeCheckFile in class com.android.tools.lint.detector.api.Detector

getSpeed

@NonNull
public com.android.tools.lint.detector.api.Speed getSpeed()
Overrides:
getSpeed in class com.android.tools.lint.detector.api.Detector

getApplicableElements

public java.util.Collection<java.lang.String> getApplicableElements()
Specified by:
getApplicableElements in interface com.android.tools.lint.detector.api.Detector.XmlScanner
Overrides:
getApplicableElements in class com.android.tools.lint.detector.api.Detector

visitElement

public void visitElement(@NonNull
                         com.android.tools.lint.detector.api.XmlContext context,
                         @NonNull
                         org.w3c.dom.Element element)
Specified by:
visitElement in interface com.android.tools.lint.detector.api.Detector.XmlScanner
Overrides:
visitElement in class com.android.tools.lint.detector.api.Detector

getSuggestions

@Nullable
public static java.util.List<java.lang.String> getSuggestions(@NonNull
                                                                       java.lang.String errorMessage,
                                                                       @NonNull
                                                                       com.android.tools.lint.detector.api.TextFormat format)
Returns the suggested replacements, if any, for the given typo. The error message must be one supplied by lint.

Parameters:
errorMessage - the error message
format - the format of the error message
Returns:
a list of replacement words suggested by the error message

getTypo

@Nullable
public static java.lang.String getTypo(@NonNull
                                                java.lang.String errorMessage,
                                                @NonNull
                                                com.android.tools.lint.detector.api.TextFormat format)
Returns the typo word in the error message from this detector

Parameters:
errorMessage - the error message produced earlier by this detector
format - the format of the error message
Returns:
the typo