Cleanup (javadoc; test)

https://github.com/JetBrains/intellij-community/pull/273
This commit is contained in:
Sebastian Zarnekow
2015-06-09 13:28:17 +03:00
committed by Roman Shevchenko
parent deca553e22
commit 4b4671f860
2 changed files with 20 additions and 1 deletions
@@ -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.
* <p/>
* <ul>
* <li><code>java.lang.String</code> -> <code>java.lang</code></li>
* <li><code>java.util.Map.Entry</code> -> <code>java.util.Map</code></li>
* </ul>
*
* @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) {
@@ -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("<![CDATA[abcd]]]><![CDATA[]>efgh]]>", XmlStringUtil.wrapInCDATA("abcd]]>efgh"));
assertEquals("<![CDATA[123<![CDATA[wow<&>]]]><![CDATA[]>]]]><![CDATA[]><![CDATA[123]]>", XmlStringUtil.wrapInCDATA("123<![CDATA[wow<&>]]>]]><![CDATA[123"));
}
public void testGetPackageName() {
assertEquals("java.lang", StringUtil.getPackageName("java.lang.String"));
assertEquals("java.util.Map", StringUtil.getPackageName("java.util.Map.Entry"));
assertEquals("Map", StringUtil.getPackageName("Map.Entry"));
assertEquals("", StringUtil.getPackageName("Number"));
}
}