Skip to content

Commit a9ec266

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[wildcards] Outline computer tests
See: #55681 Change-Id: I321bbcb9c1b45d10977aa860b0585c1d39632ea5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375960 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent cee1a76 commit a9ec266

File tree

1 file changed

+175
-0
lines changed

1 file changed

+175
-0
lines changed

pkg/analysis_server/test/src/computer/outline_computer_test.dart

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,181 @@ set propB(int v) {}
17241724
''');
17251725
}
17261726

1727+
Future<void> test_wildcardLocalFunction() async {
1728+
var unitOutline = await _computeOutline('''
1729+
f() {
1730+
_() {
1731+
_(){}
1732+
}
1733+
}
1734+
''');
1735+
1736+
var topOutlines = unitOutline.children!;
1737+
expect(topOutlines, hasLength(1));
1738+
1739+
assertJsonText(topOutlines.first, '''
1740+
{
1741+
"element": {
1742+
"kind": "FUNCTION",
1743+
"name": "f",
1744+
"location": {
1745+
"file": $testPathJson,
1746+
"offset": 0,
1747+
"length": 1,
1748+
"startLine": 1,
1749+
"startColumn": 1,
1750+
"endLine": 1,
1751+
"endColumn": 2
1752+
},
1753+
"flags": 8,
1754+
"parameters": "()",
1755+
"returnType": ""
1756+
},
1757+
"offset": 0,
1758+
"length": 29,
1759+
"codeOffset": 0,
1760+
"codeLength": 29,
1761+
"children": [
1762+
{
1763+
"element": {
1764+
"kind": "FUNCTION",
1765+
"name": "_",
1766+
"location": {
1767+
"file": $testPathJson,
1768+
"offset": 8,
1769+
"length": 1,
1770+
"startLine": 2,
1771+
"startColumn": 3,
1772+
"endLine": 2,
1773+
"endColumn": 4
1774+
},
1775+
"flags": 16,
1776+
"parameters": "()",
1777+
"returnType": ""
1778+
},
1779+
"offset": 8,
1780+
"length": 19,
1781+
"codeOffset": 8,
1782+
"codeLength": 19,
1783+
"children": [
1784+
{
1785+
"element": {
1786+
"kind": "FUNCTION",
1787+
"name": "_",
1788+
"location": {
1789+
"file": $testPathJson,
1790+
"offset": 18,
1791+
"length": 1,
1792+
"startLine": 3,
1793+
"startColumn": 5,
1794+
"endLine": 3,
1795+
"endColumn": 6
1796+
},
1797+
"flags": 16,
1798+
"parameters": "()",
1799+
"returnType": ""
1800+
},
1801+
"offset": 18,
1802+
"length": 5,
1803+
"codeOffset": 18,
1804+
"codeLength": 5
1805+
}
1806+
]
1807+
}
1808+
]
1809+
}
1810+
''');
1811+
}
1812+
1813+
Future<void> test_wildcardLocalFunction_preWildcards() async {
1814+
var unitOutline = await _computeOutline('''
1815+
// @dart = 3.4
1816+
// (pre wildcard-variables)
1817+
1818+
f() {
1819+
_() {
1820+
_(){}
1821+
}
1822+
}
1823+
''');
1824+
1825+
var topOutlines = unitOutline.children!;
1826+
expect(topOutlines, hasLength(1));
1827+
1828+
assertJsonText(topOutlines.first, '''
1829+
{
1830+
"element": {
1831+
"kind": "FUNCTION",
1832+
"name": "f",
1833+
"location": {
1834+
"file": $testPathJson,
1835+
"offset": 44,
1836+
"length": 1,
1837+
"startLine": 4,
1838+
"startColumn": 1,
1839+
"endLine": 4,
1840+
"endColumn": 2
1841+
},
1842+
"flags": 8,
1843+
"parameters": "()",
1844+
"returnType": ""
1845+
},
1846+
"offset": 44,
1847+
"length": 29,
1848+
"codeOffset": 44,
1849+
"codeLength": 29,
1850+
"children": [
1851+
{
1852+
"element": {
1853+
"kind": "FUNCTION",
1854+
"name": "_",
1855+
"location": {
1856+
"file": $testPathJson,
1857+
"offset": 52,
1858+
"length": 1,
1859+
"startLine": 5,
1860+
"startColumn": 3,
1861+
"endLine": 5,
1862+
"endColumn": 4
1863+
},
1864+
"flags": 16,
1865+
"parameters": "()",
1866+
"returnType": ""
1867+
},
1868+
"offset": 52,
1869+
"length": 19,
1870+
"codeOffset": 52,
1871+
"codeLength": 19,
1872+
"children": [
1873+
{
1874+
"element": {
1875+
"kind": "FUNCTION",
1876+
"name": "_",
1877+
"location": {
1878+
"file": $testPathJson,
1879+
"offset": 62,
1880+
"length": 1,
1881+
"startLine": 6,
1882+
"startColumn": 5,
1883+
"endLine": 6,
1884+
"endColumn": 6
1885+
},
1886+
"flags": 16,
1887+
"parameters": "()",
1888+
"returnType": ""
1889+
},
1890+
"offset": 62,
1891+
"length": 5,
1892+
"codeOffset": 62,
1893+
"codeLength": 5
1894+
}
1895+
]
1896+
}
1897+
]
1898+
}
1899+
''');
1900+
}
1901+
17271902
void _expect(Outline outline,
17281903
{ElementKind? kind,
17291904
bool leaf = false,

0 commit comments

Comments
 (0)