1
0
Fork 0

Always set isIncomplete to true

pull/165/head
Felix Becker 2016-11-29 22:16:57 +01:00
parent 38383fcaf0
commit 04a517c674
2 changed files with 36 additions and 15 deletions

View File

@ -124,6 +124,7 @@ class CompletionProvider
} }
$list = new CompletionList; $list = new CompletionList;
$list->isIncomplete = true;
// A non-free node means we do NOT suggest global symbols // A non-free node means we do NOT suggest global symbols
if ( if (
@ -380,4 +381,24 @@ class CompletionProvider
} }
return $vars; return $vars;
} }
private static function createTextEdit(PhpDocument $doc, Position $pos, string $insert): string
{
$content = $doc->getContent();
$offset = $pos->toOffset($content);
$contentLen = strlen($content);
for ($i = $offset; $i <= $contentLen; $i++) {
if (substr($content, $offset, $offset + $i) === substr($content, $offset - $i)) {
$insert = substr($offset, $i);
break;
}
}
for ($i = $offset; $i <= $contentLen; $i++) {
if (substr($content, $offset, $i) === substr($content, $headLen - $i)) {
$insert = substr($insert, $i);
break;
}
}
return new TextEdit(new Range($pos, $pos), $insert);
}
} }

View File

@ -60,7 +60,7 @@ class CompletionTest extends TestCase
'\TestClass', // Return type of the method '\TestClass', // Return type of the method
'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.' 'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.'
) )
]), $items); ], true), $items);
} }
public function testPropertyAndMethodWithoutPrefix() public function testPropertyAndMethodWithoutPrefix()
@ -84,7 +84,7 @@ class CompletionTest extends TestCase
'\TestClass', // Return type of the method '\TestClass', // Return type of the method
'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.' 'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.'
) )
]), $items); ], true), $items);
} }
public function testVariable() public function testVariable()
@ -116,7 +116,7 @@ class CompletionTest extends TestCase
null, null,
new TextEdit(new Range(new Position(8, 5), new Position(8, 5)), 'param') new TextEdit(new Range(new Position(8, 5), new Position(8, 5)), 'param')
) )
]), $items); ], true), $items);
} }
public function testVariableWithPrefix() public function testVariableWithPrefix()
@ -138,7 +138,7 @@ class CompletionTest extends TestCase
null, null,
new TextEdit(new Range(new Position(8, 6), new Position(8, 6)), 'aram') new TextEdit(new Range(new Position(8, 6), new Position(8, 6)), 'aram')
) )
]), $items); ], true), $items);
} }
public function testNewInNamespace() public function testNewInNamespace()
@ -170,7 +170,7 @@ class CompletionTest extends TestCase
null, null,
'TestClass' 'TestClass'
), ),
]), $items); ], true), $items);
} }
public function testUsedClass() public function testUsedClass()
@ -188,7 +188,7 @@ class CompletionTest extends TestCase
'TestNamespace', 'TestNamespace',
'Pariatur ut laborum tempor voluptate consequat ea deserunt.' 'Pariatur ut laborum tempor voluptate consequat ea deserunt.'
) )
]), $items); ], true), $items);
} }
public function testStaticPropertyWithPrefix() public function testStaticPropertyWithPrefix()
@ -209,7 +209,7 @@ class CompletionTest extends TestCase
null, null,
'$staticTestProperty' '$staticTestProperty'
) )
]), $items); ], true), $items);
} }
public function testStaticWithoutPrefix() public function testStaticWithoutPrefix()
@ -242,7 +242,7 @@ class CompletionTest extends TestCase
'mixed', // Method return type 'mixed', // Method return type
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.' 'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
) )
]), $items); ], true), $items);
} }
public function testStaticMethodWithPrefix() public function testStaticMethodWithPrefix()
@ -260,7 +260,7 @@ class CompletionTest extends TestCase
'mixed', // Method return type 'mixed', // Method return type
'Do magna consequat veniam minim proident eiusmod incididunt aute proident.' 'Do magna consequat veniam minim proident eiusmod incididunt aute proident.'
) )
]), $items); ], true), $items);
} }
public function testClassConstWithPrefix() public function testClassConstWithPrefix()
@ -278,7 +278,7 @@ class CompletionTest extends TestCase
'int', 'int',
'Anim labore veniam consectetur laboris minim quis aute aute esse nulla ad.' 'Anim labore veniam consectetur laboris minim quis aute aute esse nulla ad.'
) )
]), $items); ], true), $items);
} }
public function testFullyQualifiedClass() public function testFullyQualifiedClass()
@ -299,7 +299,7 @@ class CompletionTest extends TestCase
null, null,
'TestClass' 'TestClass'
) )
]), $items); ], true), $items);
} }
public function testKeywords() public function testKeywords()
@ -313,7 +313,7 @@ class CompletionTest extends TestCase
$this->assertEquals(new CompletionList([ $this->assertEquals(new CompletionList([
new CompletionItem('class', CompletionItemKind::KEYWORD, null, null, null, null, 'class '), new CompletionItem('class', CompletionItemKind::KEYWORD, null, null, null, null, 'class '),
new CompletionItem('clone', CompletionItemKind::KEYWORD, null, null, null, null, 'clone ') new CompletionItem('clone', CompletionItemKind::KEYWORD, null, null, null, null, 'clone ')
]), $items); ], true), $items);
} }
public function testHtmlWithoutPrefix() public function testHtmlWithoutPrefix()
@ -335,7 +335,7 @@ class CompletionTest extends TestCase
null, null,
new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '<?php') new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '<?php')
) )
]), $items); ], true), $items);
} }
public function testHtmlWithPrefix() public function testHtmlWithPrefix()
@ -357,7 +357,7 @@ class CompletionTest extends TestCase
null, null,
new TextEdit(new Range(new Position(0, 1), new Position(0, 1)), '?php') new TextEdit(new Range(new Position(0, 1), new Position(0, 1)), '?php')
) )
]), $items); ], true), $items);
} }
public function testNamespace() public function testNamespace()
@ -378,6 +378,6 @@ class CompletionTest extends TestCase
null, null,
'SomeNamespace' 'SomeNamespace'
) )
]), $items); ], true), $items);
} }
} }