@@ -8,12 +8,11 @@ import {
88 Type as BaseType ,
99} from "../base/api.ts" ;
1010import type {
11- FileSystemEntries ,
12- ParsedCommandLine ,
13- ProjectData ,
14- SymbolData ,
15- TypeData ,
16- } from "../types.ts" ;
11+ ConfigResponse ,
12+ ProjectResponse ,
13+ SymbolResponse ,
14+ TypeResponse ,
15+ } from "../base/proto.ts" ;
1716import { Client } from "./client.ts" ;
1817
1918export interface APIOptions extends BaseAPIOptions {
@@ -25,7 +24,7 @@ export class API implements BaseAPI<false> {
2524 this . client = new Client ( options ) ;
2625 }
2726
28- parseConfigFile ( fileName : string ) : ParsedCommandLine {
27+ parseConfigFile ( fileName : string ) : ConfigResponse {
2928 return this . client . request ( "parseConfigFile" , { fileName } ) ;
3029 }
3130
@@ -42,7 +41,7 @@ export class API implements BaseAPI<false> {
4241export class Project extends BaseProject < false > {
4342 private client : Client ;
4443
45- constructor ( client : Client , data : ProjectData ) {
44+ constructor ( client : Client , data : ProjectResponse ) {
4645 super ( data ) ;
4746 this . client = client ;
4847 }
@@ -60,14 +59,19 @@ export class Project extends BaseProject<false> {
6059 getSymbolAtPosition ( fileName : string , position : number ) : Symbol | undefined ;
6160 getSymbolAtPosition ( ...params : [ fileName : string , position : number ] | [ readonly { fileName : string ; position : number ; } [ ] ] ) : Symbol | undefined | ( Symbol | undefined ) [ ] {
6261 if ( params . length === 2 ) {
63- const data = this . client . request ( " getSymbolAtPosition" , { project : this . id , fileName : params [ 0 ] , position : params [ 1 ] } ) ;
64- return data ? new Symbol ( this . client , this , data ) : undefined ;
62+ const data = this . client . getSymbolAtPosition ( this . id , params [ 0 ] , params [ 1 ] ) ;
63+ return data . length ? new Symbol ( this . client , data ) : undefined ;
6564 }
6665 else {
67- const data = this . client . request ( "getSymbolAtPosition" , params [ 0 ] . map ( ( { fileName, position } ) => ( { project : this . id , fileName, position } ) ) ) ;
68- return data . map ( ( d : SymbolData | null ) => d ? new Symbol ( this . client , this , d ) : undefined ) ;
66+ // const data = this.client.request("getSymbolAtPosition", params[0].map(({ fileName, position }) => ({ project: this.id, fileName, position })));
67+ // return data.map((d: SymbolResponse | null) => d ? new Symbol(this.client, this, d) : undefined);
6968 }
7069 }
70+
71+ getTypeOfSymbol ( symbol : Symbol ) : Type | undefined {
72+ const data = this . client . getTypeOfSymbol ( this . id , symbol . id ) ;
73+ return data ? new Type ( this . client , data ) : undefined ;
74+ }
7175}
7276
7377export class SourceFile extends BaseSourceFile {
@@ -80,25 +84,18 @@ export class SourceFile extends BaseSourceFile {
8084 }
8185}
8286
83- export class Symbol extends BaseSymbol < false > {
87+ export class Symbol extends BaseSymbol {
8488 private client : Client ;
85- private project : Project ;
8689
87- constructor ( client : Client , project : Project , data : SymbolData ) {
88- super ( data ) ;
90+ constructor ( client : Client , data : Uint8Array ) {
91+ super ( data , client . decoder ) ;
8992 this . client = client ;
90- this . project = project ;
91- }
92-
93- getType ( ) : Type | undefined {
94- const data = this . client . request ( "getTypeOfSymbol" , { project : this . project . id , symbol : this . id } ) ;
95- return data ? new Type ( this . client , data ) : undefined ;
9693 }
9794}
9895
9996export class Type extends BaseType < false > {
10097 private client : Client ;
101- constructor ( client : Client , data : TypeData ) {
98+ constructor ( client : Client , data : Uint8Array ) {
10299 super ( data ) ;
103100 this . client = client ;
104101 }
0 commit comments