com.android.tools.lint.checks
Class TypographyDetector

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.TypographyDetector
All Implemented Interfaces:
com.android.tools.lint.detector.api.Detector.XmlScanner

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

Checks for various typographical issues in string definitions.


Nested Class Summary
static class TypographyDetector.ReplaceEdit
          An object describing a single edit to be made.
 
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 DASHES
          Replace hyphens with dashes?
static com.android.tools.lint.detector.api.Issue ELLIPSIS
          Replace ...
static com.android.tools.lint.detector.api.Issue FRACTIONS
          Replace fraction strings with fraction characters?
static com.android.tools.lint.detector.api.Issue OTHER
          The main issue discovered by this detector
static com.android.tools.lint.detector.api.Issue QUOTES
          Replace dumb quotes with smart quotes?
 
Fields inherited from interface com.android.tools.lint.detector.api.Detector.XmlScanner
ALL
 
Constructor Summary
TypographyDetector()
          Constructs a new TypographyDetector
 
Method Summary
 boolean appliesTo(com.android.resources.ResourceFolderType folderType)
           
 void beforeCheckProject(com.android.tools.lint.detector.api.Context context)
           
 java.util.Collection<java.lang.String> getApplicableElements()
           
static java.util.List<TypographyDetector.ReplaceEdit> getEdits(java.lang.String issueId, java.lang.String message, org.w3c.dom.Node textNode)
          Returns a list of edits to be applied to fix the suggestion made by the given warning.
static java.util.List<TypographyDetector.ReplaceEdit> getEdits(java.lang.String issueId, java.lang.String message, java.lang.String text)
          Returns a list of edits to be applied to fix the suggestion made by the given warning.
 com.android.tools.lint.detector.api.Speed getSpeed()
           
 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, beforeCheckFile, beforeCheckLibraryProject, 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

DASHES

public static final com.android.tools.lint.detector.api.Issue DASHES
Replace hyphens with dashes?


QUOTES

public static final com.android.tools.lint.detector.api.Issue QUOTES
Replace dumb quotes with smart quotes?


FRACTIONS

public static final com.android.tools.lint.detector.api.Issue FRACTIONS
Replace fraction strings with fraction characters?


ELLIPSIS

public static final com.android.tools.lint.detector.api.Issue ELLIPSIS
Replace ... with the ellipsis character?


OTHER

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

Constructor Detail

TypographyDetector

public TypographyDetector()
Constructs a new TypographyDetector

Method Detail

appliesTo

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

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

beforeCheckProject

public void beforeCheckProject(@NonNull
                               com.android.tools.lint.detector.api.Context context)
Overrides:
beforeCheckProject 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

getEdits

public static java.util.List<TypographyDetector.ReplaceEdit> getEdits(java.lang.String issueId,
                                                                      java.lang.String message,
                                                                      org.w3c.dom.Node textNode)
Returns a list of edits to be applied to fix the suggestion made by the given warning. The specific issue id and message should be the message provided by this detector in an earlier run.

This is intended to help tools implement automatic fixes of these warnings. The reason only the message and issue id can be provided instead of actual state passed in the data field to a reporter is that fix operation can be run much later than the lint is processed (for example, in a subsequent run of the IDE when only the warnings have been persisted),

Parameters:
issueId - the issue id, which should be the id for one of the typography issues
message - the actual error message, which should be a message provided by this detector
textNode - a text node which corresponds to the text node the warning operated on
Returns:
a list of edits, which is never null but could be empty. The offsets in the edit objects are relative to the text node.

getEdits

public static java.util.List<TypographyDetector.ReplaceEdit> getEdits(java.lang.String issueId,
                                                                      java.lang.String message,
                                                                      java.lang.String text)
Returns a list of edits to be applied to fix the suggestion made by the given warning. The specific issue id and message should be the message provided by this detector in an earlier run.

This is intended to help tools implement automatic fixes of these warnings. The reason only the message and issue id can be provided instead of actual state passed in the data field to a reporter is that fix operation can be run much later than the lint is processed (for example, in a subsequent run of the IDE when only the warnings have been persisted),

Parameters:
issueId - the issue id, which should be the id for one of the typography issues
message - the actual error message, which should be a message provided by this detector
text - the text of the XML node where the warning appeared
Returns:
a list of edits, which is never null but could be empty. The offsets in the edit objects are relative to the text node.