add LinkedHashMap to mockJdk7

This commit is contained in:
peter
2015-10-06 15:27:44 +02:00
parent 06c0f35c8f
commit 4d76c50f69
12 changed files with 54 additions and 38 deletions

View File

@@ -2252,6 +2252,47 @@
<item name='java.util.IdentityHashMap.Values java.util.Iterator&lt;V&gt; iterator()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap LinkedHashMap(java.util.Map&lt;? extends K,? extends V&gt;) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap V get(java.lang.Object)'>
<annotation name='org.jetbrains.annotations.Nullable'/>
</item>
<item name='java.util.LinkedHashMap boolean containsValue(java.lang.Object) 0'>
<annotation name='org.jetbrains.annotations.Nullable'/>
</item>
<item name='java.util.LinkedHashMap boolean removeEldestEntry(java.util.Map.Entry&lt;K,V&gt;)'>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="value" val="&quot;!null-&gt;false;null-&gt;false&quot;"/>
<val name="pure" val="true"/>
</annotation>
</item>
<item name='java.util.LinkedHashMap boolean removeEldestEntry(java.util.Map.Entry&lt;K,V&gt;) 0'>
<annotation name='org.jetbrains.annotations.Nullable'/>
</item>
<item name='java.util.LinkedHashMap java.util.Iterator&lt;K&gt; newKeyIterator()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap java.util.Iterator&lt;V&gt; newValueIterator()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap java.util.Iterator&lt;java.util.Map.Entry&lt;K,V&gt;&gt; newEntryIterator()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap.Entry void addBefore(java.util.LinkedHashMap.Entry&lt;K,V&gt;) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap.Entry void recordAccess(java.util.HashMap&lt;K,V&gt;) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='java.util.LinkedHashMap.Entry void recordRemoval(java.util.HashMap&lt;K,V&gt;) 0'>
<annotation name='org.jetbrains.annotations.Nullable'/>
</item>
<item name='java.util.LinkedHashMap.LinkedHashIterator boolean hasNext()'>
<annotation name='org.jetbrains.annotations.Contract'>
<val name="pure" val="true"/>
</annotation>
</item>
<item name='java.util.Locale Locale(java.lang.String) 0'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>

Binary file not shown.

View File

@@ -102,19 +102,6 @@ public class HashSet<E>
''')
}
protected final void addLinkedHashMap() {
myFixture.addClass """\
package java.util;
public class LinkedHashMap<K,V> extends HashMap<K,V> implements Map<K,V> {
public LinkedHashMap(int initialCapacity, float loadFactor) {}
public LinkedHashMap(int initialCapacity) {}
public LinkedHashMap() {}
public LinkedHashMap(Map<? extends K, ? extends V> m) {}
public LinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) {}
}"""
}
protected final void addAnnotationCollector() {
myFixture.addClass '''\
package groovy.transform;

View File

@@ -398,7 +398,7 @@ println(new CccMap(foo: [:]))
println(new CccList(foo: []))
println(new CccMap(foo: <warning descr="Type of argument 'foo' can not be 'ArrayList'">[]</warning>))
println(new CccList(foo: <warning descr="Type of argument 'foo' can not be 'Map'">[:]</warning>))
println(new CccList(foo: <warning descr="Type of argument 'foo' can not be 'LinkedHashMap'">[:]</warning>))
"""
}

View File

@@ -47,7 +47,6 @@ class LiteralConstructorUsagesTest extends LightGroovyTestCase {
}
void testLiteralConstructorWithNamedArgs() {
addLinkedHashMap()
myFixture.addFileToProject "a.groovy", """\
import groovy.transform.Immutable

View File

@@ -493,7 +493,6 @@ static bar(String s) {
}
void testLiteralConstructorWithNamedArgs() {
addLinkedHashMap()
testHighlighting('''\
import groovy.transform.Immutable

View File

@@ -303,7 +303,6 @@ public @interface DelegatesTo {
}
void testNamedArgs() {
addLinkedHashMap()
assertScript '''
def with(@DelegatesTo.Target Object target, @DelegatesTo(strategy = Closure.DELEGATE_FIRST) Closure arg) {
for (Closure a : arg) {
@@ -321,12 +320,10 @@ def test() {
}
test()
''', 'HashMap'
''', 'LinkedHashMap'
}
void testEllipsisArgs() {
addLinkedHashMap()
assertScript '''
def with(@DelegatesTo.Target Object target, @DelegatesTo(strategy = Closure.DELEGATE_FIRST) Closure... arg) {
for (Closure a : arg) {
@@ -347,7 +344,7 @@ def test() {
test()
''', 'HashMap'
''', 'LinkedHashMap'
}
void testShouldChooseMethodFromOwnerInJava() {
myFixture.configureByText("Abc.java", '''\
@@ -567,7 +564,6 @@ class Abc {
}
''')
addLinkedHashMap()
assertScript '''
@CompileStatic
def test() {
@@ -577,7 +573,7 @@ def test() {
}
test()
''', 'HashMap'
''', 'LinkedHashMap'
}
void testEllipsisArgsInJava() {
@@ -596,8 +592,6 @@ class Abc {
}
''')
addLinkedHashMap()
assertScript '''
@CompileStatic
def test() {
@@ -610,7 +604,7 @@ def test() {
test()
''', 'HashMap'
''', 'LinkedHashMap'
}
void testTarget() {
@@ -634,7 +628,6 @@ foo(4) {
}
void testGenericTypeIndex() {
addLinkedHashMap()
assertScript('''\
public <K, V> void foo(@DelegatesTo.Target Map<K, V> map, @DelegatesTo(genericTypeIndex = 1) Closure c) {}
@@ -645,7 +638,6 @@ foo([1:'ab', 2:'cde']) {
}
void testGenericTypeIndex1() {
addLinkedHashMap()
assertScript('''\
public <K, V> void foo(@DelegatesTo.Target Map<K, V> map, @DelegatesTo(genericTypeIndex = 0) Closure c) {}

View File

@@ -289,7 +289,7 @@ List<Integer> l2
}
void testIndexPropertyInLHS() {
assertTypeEquals("java.util.Map", 'a.groovy')
assertTypeEquals("java.util.LinkedHashMap", 'a.groovy')
}
void testEmptyMapTypeArgs() {
@@ -300,7 +300,7 @@ X<String, Integer> x = [:]
''')
def type = ((myFixture.file as GroovyFile).statements[0] as GrVariableDeclaration).variables[0].initializerGroovy.type
assertEquals("java.util.Map<java.lang.String,java.lang.Integer>", type.canonicalText)
assertEquals("java.util.LinkedHashMap<java.lang.String,java.lang.Integer>", type.canonicalText)
}
void testRawCollectionsInCasts() {
@@ -411,7 +411,7 @@ print lis<caret>t
doTest('''\
def map = cond ? [1:'a', 2:'a', 3:'a'] : [:]
print ma<caret>p
''', "$JAVA_UTIL_MAP<$JAVA_LANG_STRING, $JAVA_LANG_STRING>")
''', "java.util.LinkedHashMap<$JAVA_LANG_STRING, $JAVA_LANG_STRING>")
}
void testEmptyMapOrMapWithGenerics2() {
@@ -702,7 +702,7 @@ def foo(Map map) {
while(true)
ma<caret>p = [a:map]
}
''', 'java.util.Map<java.lang.String, java.util.Map>')
''', 'java.util.LinkedHashMap<java.lang.String, java.util.Map>')
}
void testRecursionWithLists() {

View File

@@ -27,8 +27,6 @@ class FileGenerationTest extends LightGroovyTestCase {
final String basePath = TestUtils.testDataPath + 'refactoring/convertGroovyToJava/file'
private void doTest() {
addLinkedHashMap()
final String testName = getTestName(true)
final PsiFile file = myFixture.configureByFile("${testName}.groovy");
assertInstanceOf file, GroovyFile

View File

@@ -106,7 +106,7 @@ class FooSpec extends spock.lang.Specification {
}
public void testShlSimple() {
doTest(CommonClassNames.JAVA_UTIL_MAP, """
doTest(AbstractMap.name, """
class FooSpec extends spock.lang.Specification {
def "foo test"() {
expect:

View File

@@ -1,2 +1,2 @@
java.util.Map map = new java.util.Map();
java.util.LinkedHashMap map = new java.util.LinkedHashMap();
print(map.get(1));

View File

@@ -1,4 +1,4 @@
java.util.Map<java.lang.String, java.lang.Integer> map1 = new java.util.Map<java.lang.String, java.lang.Integer>(1);
java.util.LinkedHashMap<java.lang.String, java.lang.Integer> map1 = new java.util.LinkedHashMap<java.lang.String, java.lang.Integer>(1);
map1.put("1", 2);
java.util.Map<java.lang.String, java.lang.Integer> map = map1;
java.util.LinkedHashMap<java.lang.String, java.lang.Integer> map = map1;
print(map.get("1"));