在
Android Studio中,我有时会使用这种注释来禁用我已处理的特定代码行的检查警告,例如:
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation textView.setBackgroundDrawable(ContextCompat.getDrawable(mContext,R.drawable.calendar_item_separator)); } else { textView.setBackground(ContextCompat.getDrawable(mContext,R.drawable.calendar_item_separator)); }
在这个例子中,我使用了关键字“deprecation”,但是找不到可用关键字的完整列表.
有没有人发现?
谢谢!
解决方法
我终于成功地从这个Github
source code中获取了关键字列表.
我贴在这里,以防万一:
"localInspection": [ { "language": "JAVA","shortName": "UndesirableClassUsage","displayName": "Undesirable class usage","groupName": "IntelliJ IDEA Platform Inspections","enabledByDefault": "true","level": "WARNING","implementationClass": "com.intellij.codeInspection.internal.UndesirableClassUsageInspection" },{ "language": "JAVA","shortName": "FileEqualsUsage","displayName": "File.equals() usage","implementationClass": "com.intellij.codeInspection.internal.FileEqualsUsageInspection" },"shortName": "GtkPreferredJComboBoxRenderer","displayName": "Preferred JComboBox renderer","implementationClass": "com.intellij.codeInspection.internal.GtkPreferredJComboBoxRendererInspection" },"shortName": "UnsafeVfsRecursion","displayName": "Unsafe VFS recursion","implementationClass": "com.intellij.codeInspection.internal.UnsafeVfsRecursionInspection" },"shortName": "ConstantConditions","bundle": "messages.InspectionsBundle","key": "inspection.data.flow.display.name","groupName": "Probable bugs","implementationClass": "com.intellij.codeInspection.dataFlow.DataFlowInspection" },"shortName": "UnusedAssignment","displayName": "Unused assignment","implementationClass": "com.intellij.codeInspection.defUse.DefUseInspection" },"shortName": "NumericOverflow","displayName": "Numeric overflow","groupName": "Numeric issues","implementationClass": "com.intellij.codeInspection.NumericOverflowInspection" },"shortName": "RedundantCast","displayName": "Redundant type cast","groupName": "Verbose or redundant code constructs","implementationClass": "com.intellij.codeInspection.redundantCast.RedundantCastInspection" },"shortName": "RedundantTypeArguments","key": "inspection.redundant.type.display.name","implementationClass": "com.intellij.codeInspection.miscGenerics.RedundantTypeArgsInspection" },"shortName": "RedundantArrayCreation","key": "inspection.redundant.array.creation.display.name","implementationClass": "com.intellij.codeInspection.miscGenerics.RedundantArrayForVarargsCallInspection" },"shortName": "SuspicIoUsMethodCalls","key": "inspection.suspicIoUs.collections.method.calls.display.name","implementationClass": "com.intellij.codeInspection.miscGenerics.SuspicIoUsCollectionsMethodCallsInspection" },"shortName": "LocalCanBeFinal","key": "inspection.local.can.be.final.display.name","groupName": "Code style issues","enabledByDefault": "false","implementationClass": "com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal" },"shortName": "JavaDoc","key": "inspection.javadoc.display.name","groupKey": "group.names.javadoc.issues","implementationClass": "com.intellij.codeInspection.javaDoc.JavaDocLocalInspection" },"shortName": "JavadocReference","key": "inspection.javadoc.ref.display.name","level": "ERROR","implementationClass": "com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection" },"suppressId": "deprecation","shortName": "Deprecation","displayName": "Deprecated API usage","groupName": "","implementationClass": "com.intellij.codeInspection.deprecation.DeprecationInspection" },"suppressId": "extensionSyntax","key": "deprecated.defender.Syntax.description","implementationClass": "com.intellij.codeInspection.deprecation.DeprecatedDefenderSyntaxInspection" },{ "language": "XML","shortName": "DeprecatedClassUsageInspection","displayName": "Deprecated API usage in XML","groupName": "XML","implementationClass": "com.intellij.util.xml.DeprecatedClassUsageInspection" },"shortName": "EqualsAndHashcode","key": "inspection.equals.hashcode.display.name","implementationClass": "com.intellij.codeInspection.equalsAndHashcode.EqualsAndHashcode" },"shortName": "Since15","key": "inspection.1.5.display.name","groupName": "Java language level migration aids","implementationClass": "com.intellij.codeInspection.java15api.Java15APIUsageInspection" },"shortName": "Dependency","displayName": "Illegal package dependencies","implementationClass": "com.intellij.codeInspection.dependencyViolation.DependencyInspection" },"shortName": "FieldCanBeLocal","key": "inspection.field.can.be.local.display.name","groupName": "Class structure","runForWholeFile": "true","implementationClass": "com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection" },"shortName": "ParameterCanBeLocal","key": "inspection.parameter.can.be.local.display.name","implementationClass": "com.intellij.codeInspection.varScopeCanBeNarrowed.ParameterCanBeLocalInspection" },"shortName": "NullableProblems","key": "inspection.nullable.problems.display.name","implementationClass": "com.intellij.codeInspection.nullable.NullableStuffInspection" },"shortName": "TestOnlyProblems","key": "inspection.test.only.problems.display.name","groupName": "General","implementationClass": "com.intellij.codeInspection.testOnly.TestOnlyInspection" },"shortName": "WrongPackageStatement","key": "wrong.package.statement","implementationClass": "com.intellij.codeInspection.wrongPackageStatement.WrongPackageStatementInspection" },"shortName": "SillyAssignment","key": "inspection.variable.assigned.to.itself.display.name","implementationClass": "com.intellij.codeInspection.sillyAssignment.SillyAssignmentInspection" },"shortName": "RedundantThrowsDeclaration","key": "redundant.throws.declaration","groupName": "Declaration redundancy","implementationClass": "com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration" },"shortName": "AccessStaticViaInstance","key": "access.static.via.instance","implementationClass": "com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance" },{ "shortName": "DefaultFileTemplate","key": "default.file.template.display.name","implementationClass": "com.intellij.codeInspection.defaultFileTemplateUsage.DefaultFileTemplateUsageInspection" },"suppressId": "UnusedDeclaration","alternativeId": "unused","shortName": "UNUSED_SYMBOL","displayName": "Unused symbol","implementationClass": "com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection","unfair": "true" },"shortName": "UNUSED_IMPORT","displayName": "Unused import (editor light)","groupName": "Imports","implementationClass": "com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection" },"suppressId": "unchecked","shortName": "UNCHECKED_WARNING","displayName": "Unchecked warning","implementationClass": "com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection" },"shortName": "SuspicIoUsNameCombination","key": "suspicIoUs.name.combination.display.name","implementationClass": "com.intellij.codeInspection.suspicIoUsNameCombination.SuspicIoUsNameCombinationInspection" },"shortName": "DuplicateThrows","key": "inspection.duplicate.throws.display.name","implementationClass": "com.intellij.codeInspection.duplicateThrows.DuplicateThrowsInspection" },"shortName": "FieldAccessNotGuarded","displayName": "Unguarded field access","groupName": "Concurrency annotation issues","implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.FieldAccessNotGuardedInspection" },"shortName": "InstanceGuardedByStatic","displayName": "Instance member guarded by static field","implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.InstanceGuardedByStaticInspection" },"shortName": "NonFinalFieldInImmutable","displayName": "Non-final field in @Immutable class","implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.NonFinalFieldInImmutableInspection" },"shortName": "NonFinalGuard","displayName": "Non-final @GuardedBy field","implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.NonFinalGuardInspection" },"shortName": "StaticGuardedByInstance","displayName": "Static member guarded by instance field or this","implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.StaticGuardedByInstanceInspection" },"shortName": "UnknownGuard","displayName": "Unknown @GuardedBy field","implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.UnknownGuardInspection" },"shortName": "Convert2Diamond","displayName": "Explicit type can be replaced with <>","implementationClass": "com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection" },"shortName": "Convert2Lambda","displayName": "Anonymous type can be replaced with lambda","implementationClass": "com.intellij.codeInspection.AnonymousCanBeLambdaInspection" },"shortName": "Anonymous2MethodRef","displayName": "Anonymous type can be replaced with method reference","implementationClass": "com.intellij.codeInspection.AnonymousCanBeMethodReferenceInspection" },"shortName": "Convert2MethodRef","displayName": "Lambda can be replaced with method reference","implementationClass": "com.intellij.codeInspection.LambdaCanBeMethReferenceInspection" },"shortName": "CodeBlock2Expr","displayName": "Lambda code block can be replaced with expression","implementationClass": "com.intellij.codeInspection.RedundantLambdaCodeBlockInspection" },"shortName": "SafeVarargsDetector","displayName": "Possible heap pollution from parameterized vararg type","implementationClass": "com.intellij.codeInspection.PossibleHeapPollutionVarargsInspection" },"shortName": "JavacQuirks","key": "inspection.compiler.javac.quirks.name","groupName": "Compiler issues","implementationClass": "com.intellij.codeInspection.compiler.JavacQuirksInspection" },"shortName": "MagicConstant","displayName": "Magic Constant","implementationClass": "com.intellij.codeInspection.magicConstant.MagicConstantInspection" } ],"globalInspection": [ { "shortName": "WeakerAccess","displayName": "Declaration access can be weaker","implementationClass": "com.intellij.codeInspection.visibility.VisibilityInspection" },{ "shortName": "CanBeFinal","displayName": "Declaration can have final modifier","implementationClass": "com.intellij.codeInspection.canBeFinal.CanBeFinalInspection" },{ "shortName": "UnusedParameters","key": "inspection.unused.parameter.display.name","implementationClass": "com.intellij.codeInspection.unusedParameters.UnusedParametersInspection" },{ "shortName": "SameParameterValue","key": "inspection.same.parameter.display.name","implementationClass": "com.intellij.codeInspection.sameParameterValue.SameParameterValueInspection" },{ "shortName": "UnusedReturnValue","key": "inspection.unused.return.value.display.name","implementationClass": "com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue" },{ "shortName": "SameReturnValue","key": "inspection.same.return.value.display.name","implementationClass": "com.intellij.codeInspection.sameReturnValue.SameReturnValueInspection" },{ "shortName": "EmptyMethod","displayName": "Empty method","implementationClass": "com.intellij.codeInspection.emptyMethod.EmptyMethodInspection" },{ "shortName": "RedundantThrows","displayName": "Redundant throws clause","implementationClass": "com.intellij.codeInspection.unneededThrows.RedundantThrows" },{ "shortName": "UnnecessaryModuleDependencyInspection","key": "unnecessary.module.dependency.display.name","implementationClass": "com.intellij.codeInspection.unnecessaryModuleDependency.UnnecessaryModuleDependencyInspection" },{ "shortName": "RedundantSuppression","key": "inspection.redundant.suppression.name","implementationClass": "com.intellij.codeInspection.RedundantSuppressInspection" } ]
由于某种原因我还不知道,使用注释// noinspection< keyword>一直不工作
为了能够使用关键字UnusedDeclaration我不得不在我的变量声明之前写这行:
/** @noinspection UnusedDeclaration */ private static final String TAG = "DateTools";