CodeFile codeFile = new CodeFile(path);
checkProposals(new ScopeTrieBuilder(codeFile, SyntaxType.JS), new String[0], "foo", false);
}
public void testExternalFileTopLevelProposals() {
CodeBlockImpl file1 = MockCodeBlockImpl.make().setBlockType(CodeBlock.Type.VALUE_FILE)
.setChildren(JsoArray.<CodeBlock>create())
.setId("0")
.setName("/file1.js");
file1.getChildren().add(MockCodeBlockImpl
.make()
.setId("1")
.setBlockType(CodeBlock.Type.VALUE_FUNCTION)
.setName("foobar")
.setStartLineNumber(0)
.setStartColumn(0)
.setEndLineNumber(0)
.setEndColumn(49));
file1.getChildren().add(MockCodeBlockImpl
.make()
.setId("2")
.setBlockType(CodeBlock.Type.VALUE_FUNCTION)
.setName("barbaz")
.setStartLineNumber(0)
.setStartColumn(0)
.setEndLineNumber(0)
.setEndColumn(49));
CodeBlockImpl file2 = MockCodeBlockImpl.make().setBlockType(CodeBlock.Type.VALUE_FILE)
.setChildren(JsoArray.<CodeBlock>create())
.setId("1")
.setName("/file2.js");
file2.getChildren().add(MockCodeBlockImpl
.make()
.setId("1")
.setBlockType(CodeBlock.Type.VALUE_FUNCTION)
.setName("foobaz")
.setStartLineNumber(0)
.setStartColumn(0)
.setEndLineNumber(0)
.setEndColumn(49));
file2.getChildren().add(MockCodeBlockImpl
.make()
.setId("2")
.setBlockType(CodeBlock.Type.VALUE_FUNCTION)
.setName("barfoo")
.setStartLineNumber(0)
.setStartColumn(0)
.setEndLineNumber(0)
.setEndColumn(49));
CodeFile codeFile = new CodeFile(path);
ScopeTrieBuilder builder = new ScopeTrieBuilder(codeFile, SyntaxType.JS);
JsoStringMap<CodeBlock> codeBlockMap = JsoStringMap.create();
codeBlockMap.put(file1.getName(), file1);
codeBlockMap.put(file2.getName(), file2);
builder.setCodeGraph(CodeGraphImpl.make().setCodeBlockMap(codeBlockMap));
JsonArray<AutocompleteProposal> proposals = checkProposals(
builder, new String[] {"foobar", "foobaz"}, "foo", false);
assertEquals(new PathUtil("/file1.js"),