コード例 #1
0
ファイル: symbols.test.ts プロジェクト: tiravata/vetur
  test('Id and classes', function () {
    const content = '<html id=\'root\'><body id="Foo" class="bar"><div class="a b"></div></body></html>';

    const expected = [
      {
        name: 'html#root',
        kind: SymbolKind.Field,
        containerName: '',
        location: Location.create(TEST_URI, Range.create(0, 0, 0, 80))
      },
      {
        name: 'body#Foo.bar',
        kind: SymbolKind.Field,
        containerName: 'html#root',
        location: Location.create(TEST_URI, Range.create(0, 16, 0, 73))
      },
      {
        name: 'div.a.b',
        kind: SymbolKind.Field,
        containerName: 'body#Foo.bar',
        location: Location.create(TEST_URI, Range.create(0, 43, 0, 66))
      }
    ];

    testSymbolsFor(content, expected);
  });
コード例 #2
0
ファイル: symbols.test.ts プロジェクト: tiravata/vetur
  test('Self closing', function () {
    const content = '<html><br id="Foo"><br id=Bar></html>';

    const expected = [
      {
        name: 'html',
        kind: SymbolKind.Field,
        containerName: '',
        location: Location.create(TEST_URI, Range.create(0, 0, 0, 37))
      },
      {
        name: 'br#Foo',
        kind: SymbolKind.Field,
        containerName: 'html',
        location: Location.create(TEST_URI, Range.create(0, 6, 0, 19))
      },
      {
        name: 'br#Bar',
        kind: SymbolKind.Field,
        containerName: 'html',
        location: Location.create(TEST_URI, Range.create(0, 19, 0, 30))
      }
    ];

    testSymbolsFor(content, expected);
  });
コード例 #3
0
ファイル: symbols.test.ts プロジェクト: tiravata/vetur
  test('No attrib', function () {
    const content = '<html><body><div></div></body></html>';

    const expected = [
      {
        name: 'html',
        kind: SymbolKind.Field,
        containerName: '',
        location: Location.create(TEST_URI, Range.create(0, 0, 0, 37))
      },
      {
        name: 'body',
        kind: SymbolKind.Field,
        containerName: 'html',
        location: Location.create(TEST_URI, Range.create(0, 6, 0, 30))
      },
      {
        name: 'div',
        kind: SymbolKind.Field,
        containerName: 'body',
        location: Location.create(TEST_URI, Range.create(0, 12, 0, 23))
      }
    ];

    testSymbolsFor(content, expected);
  });
コード例 #4
0
ファイル: workspace.test.ts プロジェクト: illarionvk/dotfiles
 it('should get quickfix item from Location', async () => {
   let filepath = await createTmpFile('quickfix')
   let uri = URI.file(filepath).toString()
   let p = Position.create(0, 0)
   let loc = Location.create(uri, Range.create(p, p))
   let item = await workspace.getQuickfixItem(loc)
   expect(item.filename).toBe(filepath)
   expect(item.text).toBe('quickfix')
 })
コード例 #5
0
ファイル: symbols.test.ts プロジェクト: tiravata/vetur
 test('Interpolation', () => {
   testSymbolsFor('<div>{{test}}</div>', [
     {
       containerName: '',
       name: 'div',
       kind: SymbolKind.Field,
       location: Location.create(TEST_URI, Range.create(0, 0, 0, 19))
     }
   ]);
 });
コード例 #6
0
ファイル: symbols.test.ts プロジェクト: tiravata/vetur
 test('Simple', () => {
   testSymbolsFor('<div></div>', [
     {
       containerName: '',
       name: 'div',
       kind: SymbolKind.Field,
       location: Location.create(TEST_URI, Range.create(0, 0, 0, 11))
     }
   ]);
   testSymbolsFor('<div><input checked id="test" class="checkbox"></div>', [
     {
       containerName: '',
       name: 'div',
       kind: SymbolKind.Field,
       location: Location.create(TEST_URI, Range.create(0, 0, 0, 53))
     },
     {
       containerName: 'div',
       name: 'input#test.checkbox',
       kind: SymbolKind.Field,
       location: Location.create(TEST_URI, Range.create(0, 5, 0, 47))
     }
   ]);
 });
コード例 #7
0
        plan(3, async () => {
            const fileText = trimLiteral`
            |  .gaga {
            |    -st-states: active;
            |    color: red;
            |}
            |
            |.gaga:active .gaga {
            |    background-color: fuchsia;
            |}
            |
            |.lokal {
            |    -st-extends:      gaga;
            |}
            |
            |.mixed {
            |    -st-mixin: lokal,
            |    gaga, lokal,
            |    gaga;
            |}`;

            const fileName = 'references.st.css';
            const fileSystem = new MemoryFileSystem('', { content: { [fileName]: fileText } });

            init(fileSystem, testCon.server);
            const context = { includeDeclaration: true };
            const textDocument = TextDocumentItem.create(
                toVscodePath('/' + fileName),
                'stylable',
                0,
                fileSystem.loadTextFileSync(fileName)
            );
            const refsInSelector = await testCon.client.references({
                context,
                textDocument,
                position: { line: 5, character: 16 }
            });
            const refsInMixin = await testCon.client.references({
                context,
                textDocument,
                position: { line: 10, character: 25 }
            });
            const refsInExtends = await testCon.client.references({
                context,
                textDocument,
                position: { line: 15, character: 6 }
            });
            const expectedRefs = [
                // Refs should be listed in the order they appear in the file
                Location.create(textDocument.uri, createRange(0, 3, 0, 7)),
                Location.create(textDocument.uri, createRange(5, 1, 5, 5)),
                Location.create(textDocument.uri, createRange(5, 14, 5, 18)),
                Location.create(textDocument.uri, createRange(10, 22, 10, 26)),
                Location.create(textDocument.uri, createRange(15, 4, 15, 8)),
                Location.create(textDocument.uri, createRange(16, 4, 16, 8))
            ];

            expect(refsInSelector).to.eql(expectedRefs);
            expect(refsInMixin).to.eql(expectedRefs);
            expect(refsInExtends).to.eql(expectedRefs);
        })
コード例 #8
0
            plan(4, async () => {
                // Not implemented yet
                const topFileText = trimLiteral`
            |:import {
            |    -st-from: "./import.st.css";
            |    -st-named: gaga;
            |}
            |
            |.baga {
            |    -st-extends: gaga;
            |    background-color: goldenrod;
            |}`;

                const baseFileText = trimLiteral`
            |.gaga {
            |    -st-states: aState
            |}
            |
            |.gaga:aState {
            |    color:blue;
            |    mask: lala
            |}
            `;

                const baseFileName = 'import.st.css';
                const topFileName = 'top.st.css';
                const fileSystem = new MemoryFileSystem('', {
                    content: { [baseFileName]: baseFileText, [topFileName]: topFileText }
                });

                init(fileSystem, testCon.server);
                const context = { includeDeclaration: true };
                const baseTextDocument = TextDocumentItem.create(
                    toVscodePath('/' + baseFileName),
                    'stylable',
                    0,
                    fileSystem.loadTextFileSync(baseFileName)
                );
                const topTextDocument = TextDocumentItem.create(
                    toVscodePath('/' + topFileName),
                    'stylable',
                    0,
                    fileSystem.loadTextFileSync(topFileName)
                );

                const refRequests: ReferenceParams[] = [
                    { context, textDocument: baseTextDocument, position: { line: 0, character: 3 } },
                    { context, textDocument: baseTextDocument, position: { line: 4, character: 2 } },
                    { context, textDocument: topTextDocument, position: { line: 2, character: 18 } },
                    { context, textDocument: topTextDocument, position: { line: 6, character: 20 } }
                ];

                const expectedRefs = [
                    // Refs should be listed in the order they appear in each file, current file first.
                    Location.create(baseTextDocument.uri, createRange(0, 1, 0, 5)),
                    Location.create(baseTextDocument.uri, createRange(4, 1, 4, 5)),
                    Location.create(topTextDocument.uri, createRange(2, 15, 2, 19)),
                    Location.create(topTextDocument.uri, createRange(6, 17, 6, 21))
                ];

                refRequests.forEach(async refReq => {
                    const actualRefs = await testCon.client.references({
                        context,
                        textDocument: refReq.textDocument,
                        position: refReq.position
                    });
                    expect(actualRefs).to.eql(expectedRefs);
                });
            })
コード例 #9
0
ファイル: service.ts プロジェクト: wix/stylable-intelligence
 return res.map(loc => Location.create(toVscodePath(loc.uri), loc.range));
コード例 #10
0
		test('basic symbols', () => {
			let p = new Parser();
			assertSymbols(p, '.foo {}', [{ name: '.foo', kind: SymbolKind.Class, location: Location.create('test://test/test.css' ,newRange(0, 7)) }]);
			assertSymbols(p, '.foo:not(.selected) {}', [{ name: '.foo:not(.selected)', kind: SymbolKind.Class, location: Location.create('test://test/test.css' ,newRange(0, 22)) }]);
		});