diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index bc4181e3cf9c..b50ab3e3cbc9 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -281,6 +281,18 @@ public class StringUtil extends StringUtilRt { return getPackageName(fqName, '.'); } + /** + * Given a fqName returns the package name for the type or the containing type. + *

+ *

+ * + * @param fqName a fully qualified type name. Not supposed to contain any type arguments + * @param separator the separator to use. Typically '.' + * @return the package name of the type or the declarator of the type. The empty string if the given fqName is unqualified + */ @NotNull @Contract(pure = true) public static String getPackageName(@NotNull String fqName, char separator) { diff --git a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java index 59ee8a8280e7..2d80c681bb87 100644 --- a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java +++ b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -380,4 +380,11 @@ public class StringUtilTest extends TestCase { assertEquals("efgh]]>", XmlStringUtil.wrapInCDATA("abcd]]>efgh")); assertEquals("]]]>]]]>", XmlStringUtil.wrapInCDATA("123]]>]]>