| // Copyright 2020 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| package langserver |
| |
| import ( |
| "log" |
| "os" |
| |
| "fidl-lsp/analysis" |
| "fidl-lsp/state" |
| ) |
| |
| type TestFile struct { |
| Name string |
| Text string |
| } |
| |
| func NewHandlerWithFiles(files ...TestFile) *LangHandler { |
| handler := NewLangHandler( |
| NewDefaultConfig(), |
| log.New(os.Stderr, "[LSP Test] ", log.Lshortfile), |
| analysis.CompiledLibraries{}, |
| ) |
| |
| for _, file := range files { |
| handler.fs.OpenFile(state.EditorFile(file.Name), file.Text) |
| handler.analyzer.Analyze(handler.fs, state.EditorFile(file.Name)) |
| } |
| |
| return handler |
| } |