From 7446c25e8be55498e1cd7eac3896d942ea860757 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 27 Sep 2011 23:09:15 +0200 Subject: [PATCH] EA-29896 - (IOE: PsiJavaParserFacadeImpl.createExpressionFromText) --- ...cessReplaceableByMethodCallInspection.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/CollectionsFieldAccessReplaceableByMethodCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/CollectionsFieldAccessReplaceableByMethodCallInspection.java index 5390fe0d939c..46ef89df3fbe 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/migration/CollectionsFieldAccessReplaceableByMethodCallInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/migration/CollectionsFieldAccessReplaceableByMethodCallInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 Bas Leijdekkers + * Copyright 2008-2011 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,16 +95,30 @@ public class CollectionsFieldAccessReplaceableByMethodCallInspection for (int i = 0, parameterTypesLength = parameterTypes.length; i < parameterTypesLength; i++) { final PsiType parameterType = parameterTypes[i]; - if (!parameterType.equalsToText( - CommonClassNames.JAVA_LANG_OBJECT)) { - useTypeParameter = true; + if (parameterType instanceof PsiWildcardType) { + final PsiWildcardType wildcardType = + (PsiWildcardType)parameterType; + final PsiType bound = wildcardType.getBound(); + if (bound != null) { + if (!bound.equalsToText( + CommonClassNames.JAVA_LANG_OBJECT)) { + useTypeParameter = true; + } + canonicalTexts[i] = bound.getCanonicalText(); + } else { + canonicalTexts[i] = CommonClassNames.JAVA_LANG_OBJECT; + } + } else { + if (!parameterType.equalsToText( + CommonClassNames.JAVA_LANG_OBJECT)) { + useTypeParameter = true; + } + canonicalTexts[i] = parameterType.getCanonicalText(); } - canonicalTexts[i] = parameterType.getCanonicalText(); } if (useTypeParameter) { return "Collections.<" + StringUtil.join(canonicalTexts, ",") + - '>' + - getCollectionsMethodCallText(referenceName); + '>' + getCollectionsMethodCallText(referenceName); } else { return getUntypedCollectionsMethodCallText(referenceName); }