@@ -1786,9 +1786,186 @@ ${caret}
17861786 // SKIP TS-php handles this
17871787 // it('tokenizes classes declared immediately after another class ends', () => {})
17881788
1789- describe ( 'properties' , ( ) => {
1790- it ( 'tokenizes types' , ( ) => {
1791- // up next...
1789+ describe ( "properties" , ( ) => {
1790+ it ( "tokenizes types" , ( ) => {
1791+ editor . setContent ( `
1792+ class A {
1793+ public int $a = 1;
1794+ }
1795+ ` ) ;
1796+
1797+ // public
1798+ expect ( editor ) . toHaveScopesAtPosition (
1799+ [ 2 , 2 ] ,
1800+ [
1801+ "source.php" ,
1802+ "meta.class.php" ,
1803+ "meta.class.body.php" ,
1804+ "storage.modifier.php"
1805+ ]
1806+ ) ;
1807+ // FIXME not supported by tree-sitter-php until > 0.19.0
1808+ // int
1809+ // expect(editor).toHaveScopesAtPosition(
1810+ // [2, 9],
1811+ // [
1812+ // "source.php",
1813+ // "meta.class.php",
1814+ // "meta.class.body.php",
1815+ // "keyword.other.type.php"
1816+ // ]
1817+ // );
1818+ // $
1819+ expect ( editor ) . toHaveScopesAtPosition (
1820+ [ 2 , 13 ] ,
1821+ [
1822+ "source.php" ,
1823+ "meta.class.php" ,
1824+ "meta.class.body.php" ,
1825+ "variable.other.php" ,
1826+ "punctuation.definition.variable.php"
1827+ ]
1828+ ) ;
1829+ // a
1830+ expect ( editor ) . toHaveScopesAtPosition (
1831+ [ 2 , 14 ] ,
1832+ [
1833+ "source.php" ,
1834+ "meta.class.php" ,
1835+ "meta.class.body.php" ,
1836+ "variable.other.php"
1837+ ]
1838+ ) ;
1839+ } ) ;
1840+
1841+ // FIXME not supported by tree-sitter-php until > 0.19.0
1842+ // it("tokenizes nullable types", () => {})
1843+
1844+ it ( "tokenizes 2 modifiers correctly" , ( ) => {
1845+ editor . setContent ( `
1846+ class Foo {
1847+ public static $bar = 'baz';
1848+ }
1849+ ` ) ;
1850+
1851+ // public
1852+ expect ( editor ) . toHaveScopesAtPosition (
1853+ [ 2 , 2 ] ,
1854+ [
1855+ "source.php" ,
1856+ "meta.class.php" ,
1857+ "meta.class.body.php" ,
1858+ "storage.modifier.php"
1859+ ]
1860+ ) ;
1861+ // static
1862+ expect ( editor ) . toHaveScopesAtPosition (
1863+ [ 2 , 9 ] ,
1864+ [
1865+ "source.php" ,
1866+ "meta.class.php" ,
1867+ "meta.class.body.php" ,
1868+ "storage.modifier.php"
1869+ ]
1870+ ) ;
1871+ // $
1872+ expect ( editor ) . toHaveScopesAtPosition (
1873+ [ 2 , 16 ] ,
1874+ [
1875+ "source.php" ,
1876+ "meta.class.php" ,
1877+ "meta.class.body.php" ,
1878+ "variable.other.php" ,
1879+ "punctuation.definition.variable.php"
1880+ ]
1881+ ) ;
1882+ // bar
1883+ expect ( editor ) . toHaveScopesAtPosition (
1884+ [ 2 , 17 ] ,
1885+ [
1886+ "source.php" ,
1887+ "meta.class.php" ,
1888+ "meta.class.body.php" ,
1889+ "variable.other.php"
1890+ ]
1891+ ) ;
1892+ } ) ;
1893+
1894+ // FIXME typed properties not supported by tree-sitter-php until > 0.19.0
1895+ // it('tokenizes namespaces', () => {});
1896+
1897+ it ( "tokenizes multiple properties" , ( ) => {
1898+ // FIXME the TM spec includes property types which aren't yet
1899+ // supported by our version of TS-php. Update this spec to match after
1900+ // TS-php has been updated w/ support for prop types.
1901+ editor . setContent ( `
1902+ class A {
1903+ private static $c1, $c2;
1904+ }
1905+ ` ) ;
1906+
1907+ // private
1908+ expect ( editor ) . toHaveScopesAtPosition (
1909+ [ 2 , 2 ] ,
1910+ [
1911+ "source.php" ,
1912+ "meta.class.php" ,
1913+ "meta.class.body.php" ,
1914+ "storage.modifier.php"
1915+ ]
1916+ ) ;
1917+ // static
1918+ expect ( editor ) . toHaveScopesAtPosition (
1919+ [ 2 , 10 ] ,
1920+ [
1921+ "source.php" ,
1922+ "meta.class.php" ,
1923+ "meta.class.body.php" ,
1924+ "storage.modifier.php"
1925+ ]
1926+ ) ;
1927+ // $
1928+ expect ( editor ) . toHaveScopesAtPosition (
1929+ [ 2 , 17 ] ,
1930+ [
1931+ "source.php" ,
1932+ "meta.class.php" ,
1933+ "meta.class.body.php" ,
1934+ "variable.other.php" ,
1935+ "punctuation.definition.variable.php"
1936+ ]
1937+ ) ;
1938+ // c1
1939+ expect ( editor ) . toHaveScopesAtPosition (
1940+ [ 2 , 18 ] ,
1941+ [
1942+ "source.php" ,
1943+ "meta.class.php" ,
1944+ "meta.class.body.php" ,
1945+ "variable.other.php"
1946+ ]
1947+ ) ;
1948+ // $
1949+ expect ( editor ) . toHaveScopesAtPosition (
1950+ [ 2 , 22 ] ,
1951+ [
1952+ "source.php" ,
1953+ "meta.class.php" ,
1954+ "meta.class.body.php" ,
1955+ "variable.other.php" ,
1956+ "punctuation.definition.variable.php"
1957+ ]
1958+ ) ;
1959+ // c2
1960+ expect ( editor ) . toHaveScopesAtPosition (
1961+ [ 2 , 23 ] ,
1962+ [
1963+ "source.php" ,
1964+ "meta.class.php" ,
1965+ "meta.class.body.php" ,
1966+ "variable.other.php"
1967+ ]
1968+ ) ;
17921969 } ) ;
17931970 } ) ;
17941971
0 commit comments