From 4cac1b96189f5ff808a1330e837f7860b1f8f86b Mon Sep 17 00:00:00 2001 From: shafang Date: Thu, 11 Jul 2019 11:40:45 -0700 Subject: [PATCH 01/10] remove java code isImple check but move to suppression and add only check for public class for external Dependency check --- .../ExternalDependencyExposedCheck.java | 20 +++++++++---------- .../checkstyle/checkstyle-suppressions.xml | 6 +++++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java index 6c4a730d5a99c..af388c4d6778f 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java @@ -29,12 +29,12 @@ public class ExternalDependencyExposedCheck extends AbstractCheck { ))); private final Map simpleClassNameToQualifiedNameMap = new HashMap<>(); - private static boolean isImplPackage; + + private boolean isPublicClass; @Override public void beginTree(DetailAST rootAST) { simpleClassNameToQualifiedNameMap.clear(); - isImplPackage = false; } @Override @@ -50,7 +50,6 @@ public int[] getAcceptableTokens() { @Override public int[] getRequiredTokens() { return new int[] { - TokenTypes.PACKAGE_DEF, TokenTypes.IMPORT, TokenTypes.METHOD_DEF }; @@ -58,22 +57,21 @@ public int[] getRequiredTokens() { @Override public void visitToken(DetailAST token) { - if (isImplPackage) { - return; - } - switch (token.getType()) { - case TokenTypes.PACKAGE_DEF: - String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); - isImplPackage = packageName.contains(".implementation"); - break; case TokenTypes.IMPORT: // Add all imported classes into a map, key is the name of class and value is the full package path of class. final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(".") + 1); simpleClassNameToQualifiedNameMap.put(className, importClassPath); break; + case TokenTypes.CLASS_DEF: + final DetailAST modifiersToken = token.findFirstToken(TokenTypes.MODIFIERS); + isPublicClass = modifiersToken.branchContains(TokenTypes.LITERAL_PUBLIC); + break; case TokenTypes.METHOD_DEF: + if (!isPublicClass) { + return; + } checkNoExternalDependencyExposed(token); break; default: diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index 1f9752c52de54..ac7af8e887727 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -86,7 +86,11 @@ - + + + + + From 65f084d6a3df9b3bc8bde61621522fa6644e9431 Mon Sep 17 00:00:00 2001 From: shafang Date: Thu, 25 Jul 2019 14:36:04 -0700 Subject: [PATCH 02/10] external dependency check fix --- .../ExternalDependencyExposedCheck.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java index b36f28e10be83..5d4b617441355 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java @@ -21,16 +21,13 @@ * No external dependency exposed in public API */ public class ExternalDependencyExposedCheck extends AbstractCheck { - private static final String EXTERNAL_DEPENDENCY_ERROR = - "Class ''%s'', is a class from external dependency. You should not use it as a return or method argument type."; - private static final Set VALID_DEPENDENCY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "java", "com.azure", "reactor", "io.netty.buffer.ByteBuf" ))); private final Map simpleClassNameToQualifiedNameMap = new HashMap<>(); - private boolean isPublicClass; + private boolean isPublicAPI; @Override public void beginTree(DetailAST rootAST) { @@ -51,6 +48,7 @@ public int[] getAcceptableTokens() { public int[] getRequiredTokens() { return new int[] { TokenTypes.IMPORT, + TokenTypes.CLASS_DEF, TokenTypes.METHOD_DEF }; } @@ -68,10 +66,10 @@ public void visitToken(DetailAST token) { // CLASS_DEF always has MODIFIERS final AccessModifier accessModifier = CheckUtil.getAccessModifierFromModifiersToken( token.findFirstToken(TokenTypes.MODIFIERS)); - isPublicClass = accessModifier.equals(AccessModifier.PUBLIC); + isPublicAPI = accessModifier.equals(AccessModifier.PUBLIC) || accessModifier.equals(AccessModifier.PROTECTED); break; case TokenTypes.METHOD_DEF: - if (!isPublicClass) { + if (!isPublicAPI) { return; } checkNoExternalDependencyExposed(token); @@ -101,14 +99,14 @@ private void checkNoExternalDependencyExposed(DetailAST methodDefToken) { final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE); if (typeToken != null) { getInvalidReturnTypes(typeToken).forEach( - (token, returnTypeName) -> log(token, String.format(EXTERNAL_DEPENDENCY_ERROR, returnTypeName))); + (token, returnTypeName) -> log(token, String.format("Class ''%s'', is a class from external dependency. You should not use it as a return type.", returnTypeName))); } // Checks for the parameters of the method final DetailAST parametersToken = methodDefToken.findFirstToken(TokenTypes.PARAMETERS); if (parametersToken != null) { getInvalidParameterTypes(parametersToken).forEach( - (token, returnTypeName) -> log(token, String.format(EXTERNAL_DEPENDENCY_ERROR, returnTypeName))); + (token, parameterTypeName) -> log(token, String.format("Class ''%s'', is a class from external dependency. You should not use it as a method argument type.", parameterTypeName))); } } @@ -149,10 +147,12 @@ private Map getInvalidReturnTypes(DetailAST typeToken) { private Map getInvalidParameterTypes(DetailAST parametersTypeToken) { final Map invalidParameterTypesMap = new HashMap<>(); for (DetailAST ast = parametersTypeToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { +// log(ast, "ast type (getInvalidParameterTypes) ==== " + ast.getText()); if (ast.getType() == TokenTypes.PARAMETER_DEF) { invalidParameterTypesMap.putAll(getInvalidTypeFromTypeArguments(ast.findFirstToken(TokenTypes.TYPE))); } } +// log(parametersTypeToken, "Invalid Type (parametersTypeToken) MAP size = " + invalidParameterTypesMap.size()); return invalidParameterTypesMap; } @@ -170,15 +170,21 @@ private Map getInvalidTypeFromTypeArguments(DetailAST typeArg } // Checks multiple type arguments for (DetailAST ast = typeArgumentsToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { - if (ast.getType() != TokenTypes.TYPE_ARGUMENT) { - continue; - } - - final String invalidTypeName = getInvalidTypeNameFromTypeArgument(ast); - if (invalidTypeName != null) { - invalidTypesMap.put(ast, invalidTypeName); +// log(ast, "ast type (getInvalidTypeFromTypeArguments) ==== " + ast.getText()); + if (ast.getType() == TokenTypes.IDENT) { + final String identName = ast.getText(); + if (!isValidClassDependency(identName)) { + invalidTypesMap.put(ast, identName); + } + } else if (ast.getType() == TokenTypes.TYPE_ARGUMENT) { + final String invalidTypeName = getInvalidTypeNameFromTypeArgument(ast); + if (invalidTypeName != null) { +// log(ast, "Invalid Type Name ===== " + invalidTypeName); + invalidTypesMap.put(ast, invalidTypeName); + } } } +// log(typeArgumentsToken, "Invalid Type (typeArgumentsToken) MAP size = " + invalidTypesMap.size()); return invalidTypesMap; } @@ -204,7 +210,7 @@ private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { * A helper function that checks for whether a class is from a valid internal dependency or is a suppression class * * @param typeName the type name of class - * @return true if the class is a suppression class, otherwise, return false. + * @return true if the class is a suppression class, otherwise, return false. */ private boolean isValidClassDependency(String typeName) { // If the qualified class name does not exist in the map, From e39620fdf6c6d07c6ca06b02f7420152ccf59fce Mon Sep 17 00:00:00 2001 From: shafang Date: Thu, 25 Jul 2019 18:19:54 -0700 Subject: [PATCH 03/10] skip check for sample --- .../src/main/resources/checkstyle/checkstyle-suppressions.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index 27d8784c5efdc..361d56362fc13 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -94,8 +94,10 @@ + + + - From d548b95ebbbf4e952c7a5ff2080a6d2f36375923 Mon Sep 17 00:00:00 2001 From: shafang Date: Fri, 26 Jul 2019 13:30:52 -0700 Subject: [PATCH 04/10] remove unused import --- .../implementation/serializer/jackson/HttpHeadersSerializer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/serializer/jackson/HttpHeadersSerializer.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/serializer/jackson/HttpHeadersSerializer.java index 4174330878b02..352a9dd4251d5 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/serializer/jackson/HttpHeadersSerializer.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/serializer/jackson/HttpHeadersSerializer.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.module.SimpleModule; import java.io.IOException; From 7a297a16c188bdfa4c3e38884d6631b69fc87c92 Mon Sep 17 00:00:00 2001 From: shafang Date: Fri, 26 Jul 2019 13:46:58 -0700 Subject: [PATCH 05/10] remove test code --- .../checkstyle/checks/ExternalDependencyExposedCheck.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java index 5d4b617441355..c6504c615b0c6 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java @@ -170,7 +170,6 @@ private Map getInvalidTypeFromTypeArguments(DetailAST typeArg } // Checks multiple type arguments for (DetailAST ast = typeArgumentsToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { -// log(ast, "ast type (getInvalidTypeFromTypeArguments) ==== " + ast.getText()); if (ast.getType() == TokenTypes.IDENT) { final String identName = ast.getText(); if (!isValidClassDependency(identName)) { @@ -179,12 +178,10 @@ private Map getInvalidTypeFromTypeArguments(DetailAST typeArg } else if (ast.getType() == TokenTypes.TYPE_ARGUMENT) { final String invalidTypeName = getInvalidTypeNameFromTypeArgument(ast); if (invalidTypeName != null) { -// log(ast, "Invalid Type Name ===== " + invalidTypeName); invalidTypesMap.put(ast, invalidTypeName); } } } -// log(typeArgumentsToken, "Invalid Type (typeArgumentsToken) MAP size = " + invalidTypesMap.size()); return invalidTypesMap; } From 0722af3362f03b294011263c9bbeff04a748d50b Mon Sep 17 00:00:00 2001 From: shafang Date: Fri, 26 Jul 2019 14:56:49 -0700 Subject: [PATCH 06/10] remove comments --- .../tools/checkstyle/checks/ExternalDependencyExposedCheck.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java index c6504c615b0c6..b61b1aaf67f28 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java @@ -147,12 +147,10 @@ private Map getInvalidReturnTypes(DetailAST typeToken) { private Map getInvalidParameterTypes(DetailAST parametersTypeToken) { final Map invalidParameterTypesMap = new HashMap<>(); for (DetailAST ast = parametersTypeToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { -// log(ast, "ast type (getInvalidParameterTypes) ==== " + ast.getText()); if (ast.getType() == TokenTypes.PARAMETER_DEF) { invalidParameterTypesMap.putAll(getInvalidTypeFromTypeArguments(ast.findFirstToken(TokenTypes.TYPE))); } } -// log(parametersTypeToken, "Invalid Type (parametersTypeToken) MAP size = " + invalidParameterTypesMap.size()); return invalidParameterTypesMap; } From b668fbad76eb914166c5d3c2fe9949476a67d97e Mon Sep 17 00:00:00 2001 From: shafang Date: Fri, 26 Jul 2019 15:08:27 -0700 Subject: [PATCH 07/10] refactor error message --- .../checkstyle/checks/ExternalDependencyExposedCheck.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java index b61b1aaf67f28..fe548c8ee27c1 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java @@ -21,6 +21,7 @@ * No external dependency exposed in public API */ public class ExternalDependencyExposedCheck extends AbstractCheck { + private static final String EXTERNAL_DEPENDENCY_ERROR = "Class ''%s'', is a class from external dependency. You should not use it as a %s type."; private static final Set VALID_DEPENDENCY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "java", "com.azure", "reactor", "io.netty.buffer.ByteBuf" ))); @@ -99,14 +100,14 @@ private void checkNoExternalDependencyExposed(DetailAST methodDefToken) { final DetailAST typeToken = methodDefToken.findFirstToken(TokenTypes.TYPE); if (typeToken != null) { getInvalidReturnTypes(typeToken).forEach( - (token, returnTypeName) -> log(token, String.format("Class ''%s'', is a class from external dependency. You should not use it as a return type.", returnTypeName))); + (token, returnTypeName) -> log(token, String.format(EXTERNAL_DEPENDENCY_ERROR, returnTypeName, "return"))); } // Checks for the parameters of the method final DetailAST parametersToken = methodDefToken.findFirstToken(TokenTypes.PARAMETERS); if (parametersToken != null) { getInvalidParameterTypes(parametersToken).forEach( - (token, parameterTypeName) -> log(token, String.format("Class ''%s'', is a class from external dependency. You should not use it as a method argument type.", parameterTypeName))); + (token, parameterTypeName) -> log(token, String.format(EXTERNAL_DEPENDENCY_ERROR, parameterTypeName, "method argument"))); } } From f7a0a39968d8422716f35235d1272455065ad1e9 Mon Sep 17 00:00:00 2001 From: shafang Date: Sat, 27 Jul 2019 17:33:41 -0700 Subject: [PATCH 08/10] refactor the sections of suppression for easier to review --- .../checkstyle/checkstyle-suppressions.xml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index 361d56362fc13..ce9608a9c6d25 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -94,13 +94,20 @@ - - - - - - - + + + + + + + + + + + + + + From 846b4326d9b163f0d70deec7cac0483a0c393df7 Mon Sep 17 00:00:00 2001 From: shafang Date: Sat, 27 Jul 2019 17:45:23 -0700 Subject: [PATCH 09/10] wording --- .../src/main/resources/checkstyle/checkstyle-suppressions.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml index ce9608a9c6d25..f7675dbe9b2fc 100755 --- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml +++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -94,7 +94,7 @@ - + @@ -106,7 +106,7 @@ - + From 3ee4fa9c6518f3309f85f972c75aededec7fc5e2 Mon Sep 17 00:00:00 2001 From: shafang Date: Mon, 29 Jul 2019 09:46:42 -0700 Subject: [PATCH 10/10] generic model --- .../ExternalDependencyExposedCheck.java | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java index fe548c8ee27c1..44522a4e8597a 100644 --- a/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java +++ b/eng/code-quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ExternalDependencyExposedCheck.java @@ -28,7 +28,7 @@ public class ExternalDependencyExposedCheck extends AbstractCheck { private final Map simpleClassNameToQualifiedNameMap = new HashMap<>(); - private boolean isPublicAPI; + private boolean isPublicClass; @Override public void beginTree(DetailAST rootAST) { @@ -67,10 +67,10 @@ public void visitToken(DetailAST token) { // CLASS_DEF always has MODIFIERS final AccessModifier accessModifier = CheckUtil.getAccessModifierFromModifiersToken( token.findFirstToken(TokenTypes.MODIFIERS)); - isPublicAPI = accessModifier.equals(AccessModifier.PUBLIC) || accessModifier.equals(AccessModifier.PROTECTED); + isPublicClass = accessModifier.equals(AccessModifier.PUBLIC) || accessModifier.equals(AccessModifier.PROTECTED); break; case TokenTypes.METHOD_DEF: - if (!isPublicAPI) { + if (!isPublicClass) { return; } checkNoExternalDependencyExposed(token); @@ -133,7 +133,7 @@ private Map getInvalidReturnTypes(DetailAST typeToken) { // TYPE_ARGUMENTS, add all invalid external types to the map final DetailAST typeArgumentsToken = typeToken.findFirstToken(TokenTypes.TYPE_ARGUMENTS); if (typeArgumentsToken != null) { - invalidReturnTypeMap.putAll(getInvalidTypeFromTypeArguments(typeArgumentsToken)); + getInvalidParameterType(typeArgumentsToken, invalidReturnTypeMap); } return invalidReturnTypeMap; @@ -149,59 +149,37 @@ private Map getInvalidParameterTypes(DetailAST parametersType final Map invalidParameterTypesMap = new HashMap<>(); for (DetailAST ast = parametersTypeToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { if (ast.getType() == TokenTypes.PARAMETER_DEF) { - invalidParameterTypesMap.putAll(getInvalidTypeFromTypeArguments(ast.findFirstToken(TokenTypes.TYPE))); + getInvalidParameterType(ast.findFirstToken(TokenTypes.TYPE), invalidParameterTypesMap); } } return invalidParameterTypesMap; } /** - * A helper function that checks TYPE AST node. Since both return type and input parameter argument type has - * TYPE AST node under. This function applied to both. + * Get all invalid AST nodes from a given token. DFS tree traversal used to find all invalid nodes. * - * @param typeArgumentsToken TYPE_ARGUMENTS AST node - * @return a map that maps all the invalid TYPE_ARGUMENT node and the type name + * @param token TYPE_ARGUMENT, TYPE_ARGUMENTS or TYPE AST node + * @return a map that maps all the invalid node and the type name */ - private Map getInvalidTypeFromTypeArguments(DetailAST typeArgumentsToken) { - final Map invalidTypesMap = new HashMap<>(); - if (typeArgumentsToken == null) { + private Map getInvalidParameterType(DetailAST token, Map invalidTypesMap) { + if (token == null) { return invalidTypesMap; } - // Checks multiple type arguments - for (DetailAST ast = typeArgumentsToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { - if (ast.getType() == TokenTypes.IDENT) { + + for (DetailAST ast = token.getFirstChild(); ast != null; ast = ast.getNextSibling()) { + final int tokenType = ast.getType(); + if (tokenType == TokenTypes.IDENT) { final String identName = ast.getText(); if (!isValidClassDependency(identName)) { invalidTypesMap.put(ast, identName); } - } else if (ast.getType() == TokenTypes.TYPE_ARGUMENT) { - final String invalidTypeName = getInvalidTypeNameFromTypeArgument(ast); - if (invalidTypeName != null) { - invalidTypesMap.put(ast, invalidTypeName); - } + } else if (tokenType == TokenTypes.TYPE_ARGUMENT || tokenType == TokenTypes.TYPE_ARGUMENTS) { + getInvalidParameterType(ast, invalidTypesMap); } } return invalidTypesMap; } - /** - * Get invalid type name from TYPE_ARGUMENT - * - * @param typeArgumentToken TYPE_ARGUMENT AST node - * @return an invalid type name if it is an invalid library. Otherwise, returns null. - */ - private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { - final DetailAST identToken = typeArgumentToken.findFirstToken(TokenTypes.IDENT); - // if there is no IDENT token, implies the token is default java types. - if (identToken == null) { - return null; - } - - final String typeName = identToken.getText(); - // if not exist in the classPathMap, that implies the type is java default types, such as int. - return isValidClassDependency(typeName) ? null : typeName; - } - /** * A helper function that checks for whether a class is from a valid internal dependency or is a suppression class *