Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (api *API) HandleRequest(ctx context.Context, method string, payload []byte
}))
case MethodGetDiagnostics:
params := params.(*GetDiagnosticsParams)
return encodeJSON((api.GetDiagnostics(ctx, params.Project)))
return encodeJSON((api.GetDiagnostics(ctx, params.Project, params.FileNames)))
default:
return nil, fmt.Errorf("unhandled API method %q", method)
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func (api *API) GetSourceFile(projectId Handle[project.Project], fileName string
return sourceFile, nil
}

func (api *API) GetDiagnostics(ctx context.Context, projectId Handle[project.Project]) ([]*ls.Diagnostic, error) {
func (api *API) GetDiagnostics(ctx context.Context, projectId Handle[project.Project], fileNames []string) ([]*ls.Diagnostic, error) {
projectPath, ok := api.projects[projectId]
if !ok {
return nil, errors.New("project ID not found")
Expand All @@ -278,7 +278,7 @@ func (api *API) GetDiagnostics(ctx context.Context, projectId Handle[project.Pro
}

languageService := ls.NewLanguageService(project.GetProgram(), snapshot)
diagnostics := languageService.GetDiagnostics(ctx)
diagnostics := languageService.GetDiagnostics(ctx, fileNames)

api.symbolsMu.Lock()
defer api.symbolsMu.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion internal/api/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ func NewSymbolResponse(symbol *ast.Symbol) *SymbolResponse {
}

type GetDiagnosticsParams struct {
Project Handle[project.Project] `json:"project"`
Project Handle[project.Project] `json:"project"`
FileNames []string `json:"fileNames"`
}

type GetTypeOfSymbolParams struct {
Expand Down
12 changes: 10 additions & 2 deletions internal/ls/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ func (d *diagnosticList) getDiagnostics() []*Diagnostic {
return d.diagnostics
}

func (l *LanguageService) GetDiagnostics(ctx context.Context) []*Diagnostic {
func (l *LanguageService) GetDiagnostics(ctx context.Context, fileNames []string) []*Diagnostic {
program := l.GetProgram()
sourceFiles := program.GetSourceFiles()
var sourceFiles []*ast.SourceFile
if len(fileNames) > 0 {
sourceFiles = make([]*ast.SourceFile, 0, len(fileNames))
for _, fileName := range fileNames {
sourceFiles = append(sourceFiles, program.GetSourceFile(fileName))
}
} else {
sourceFiles = program.GetSourceFiles()
}
diagnosticList := &diagnosticList{
diagnostics: make([]*Diagnostic, 0),
}
Expand Down