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
2 changes: 1 addition & 1 deletion client/integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Monitoring-based integration tests enable testing of MCP tools that previously c
## Example: Tool with Both File-Based and Monitoring Tests

```text
client/integration-tests/primitives/tools/codeql_language_server_eval/
client/integration-tests/primitives/tools/codeql_lsp_diagnostics/
└── semantic_validation/
├── before/
│ ├── semantic_query.ql # File-based test input
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# `codeql_lsp_completion/basic_completion`

## PURPOSE

Tests that `codeql_lsp_completion` returns targeted completion items for a
member-access expression. The cursor is positioned after `f.getBa` so the
language server should return completions matching the prefix (e.g.
`getBaseName`). Uses `file_content` to provide inline query text, which
avoids disk I/O and produces a small, focused result set.

## INPUTS

- **file_content**: Inline QL with cursor after `f.getBa`
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
- **line**: 3 (`where f.getBa`)
- **character**: 13 (end of `getBa` prefix)
- **workspace_uri**: `server/ql/javascript/examples`

## EXPECTED OUTPUTS

- A list of completion items matching the `getBa` prefix (e.g. `getBaseName`).
- Monitoring state updated to record a successful `codeql_lsp_completion` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_completion",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sessions": [],
"parameters": {
"file_content": "import javascript\n\nfrom File f\nwhere f.getBa\nselect f",
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
"line": 3,
"character": 13,
"workspace_uri": "server/ql/javascript/examples"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `codeql_lsp_completion/from_clause_completion`

## PURPOSE

Tests that `codeql_lsp_completion` returns keyword completions when the cursor
is positioned after a partial keyword `wh` following a `from` clause. Uses
`file_content` to provide inline query text, producing a small set of
completions (e.g. `where`) rather than an exhaustive type list.

## INPUTS

- **file_content**: Inline QL with cursor after `wh` prefix
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
- **line**: 3 (after `wh`)
- **character**: 2 (end of `wh` prefix)
- **workspace_uri**: `server/ql/javascript/examples`

## EXPECTED OUTPUTS

- A list of completion items matching the `wh` prefix (e.g. `where`).
- Monitoring state updated to record a successful `codeql_lsp_completion` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_completion",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sessions": [],
"parameters": {
"file_content": "import javascript\n\nfrom File f\nwh",
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
"line": 3,
"character": 2,
"workspace_uri": "server/ql/javascript/examples"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `codeql_lsp_definition/basic_definition`

## PURPOSE

Tests that `codeql_lsp_definition` resolves the definition of a type used in a
`from` clause. The cursor is on `File` (line 2, character 7) which should
resolve to the `File` class definition in the JavaScript CodeQL library.
Uses `file_content` to provide inline query text.

## INPUTS

- **file_content**: Inline QL with `from File f` clause
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
- **line**: 2 (on the `File` type in `from File f`)
- **character**: 7 (cursor on `File`)
- **workspace_uri**: `server/ql/javascript/examples`

## EXPECTED OUTPUTS

- One or more definition locations with URIs pointing to `.qll` library files.
- Monitoring state updated to record a successful `codeql_lsp_definition` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_definition",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sessions": [],
"parameters": {
"file_content": "import javascript\n\nfrom File f\nwhere f.getBaseName() = \"test.js\"\nselect f, \"found\"",
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
"line": 2,
"character": 7,
"workspace_uri": "server/ql/javascript/examples"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `codeql_lsp_definition/class_definition`

## PURPOSE

Tests that `codeql_lsp_definition` resolves the definition of the `javascript`
library module from an `import` statement. The cursor is on `javascript`
(line 0, character 10) which should resolve to the library module definition.
Uses `file_content` to provide inline query text.

## INPUTS

- **file_content**: Inline QL with `import javascript` statement
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
- **line**: 0 (on the `import javascript` statement)
- **character**: 10 (cursor on `javascript`)
- **workspace_uri**: `server/ql/javascript/examples`

## EXPECTED OUTPUTS

- One or more definition locations with URIs pointing to `.qll` library files.
- Monitoring state updated to record a successful `codeql_lsp_definition` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_definition",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sessions": [],
"parameters": {
"file_content": "import javascript\n\nfrom File f\nwhere f.getBaseName() = \"test.js\"\nselect f, \"found\"",
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
"line": 0,
"character": 10,
"workspace_uri": "server/ql/javascript/examples"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `codeql_lsp_diagnostics/semantic_validation`

## PURPOSE

Tests that `codeql_lsp_diagnostics` detects semantic errors in QL code that
references undefined types (e.g., `UndefinedType`).

## INPUTS

- **ql_code**: A QL query fragment referencing `UndefinedType` which does not
exist, triggering a semantic "could not resolve type" diagnostic.

## EXPECTED OUTPUTS

- `isValid` is `false` with semantic diagnostics about unresolvable types.
- The `before/semantic_query.ql` contains the erroneous query; `after/semantic_query.ql` shows the corrected version after addressing the diagnostics.
- Monitoring state updated to record a successful `codeql_lsp_diagnostics` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_diagnostics",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success",
"parameters": {
"ql_code": "from NonExistentType item\nwhere item.someProperty() = \"value\"\nselect item, \"This has semantic errors\""
}
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sessions": [],
"parameters": {
"ql_code": "from UndefinedType x\nwhere x = \"test\"\nselect x, \"semantic error: undefined type\""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `codeql_lsp_diagnostics/syntax_validation`

## PURPOSE

Tests that `codeql_lsp_diagnostics` detects syntax errors in invalid QL code.

## INPUTS

- **ql_code**: Invalid QL snippet with syntax errors (`invalid_type x\nwhere x = "test"\nselect x, "This has syntax errors"`).

## EXPECTED OUTPUTS

- `isValid` is `false` with one or more error diagnostics.
- The `before/test_query.ql` contains the erroneous query; `after/test_query.ql` shows the corrected version after addressing the diagnostics.
- Monitoring state updated to record a successful `codeql_lsp_diagnostics` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_diagnostics",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sessions": [],
"parameters": {
"ql_code": "invalid_type x\nwhere x = \"test\"\nselect x, \"This has syntax errors\""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `codeql_lsp_diagnostics/valid_query_no_errors`

## PURPOSE

Tests that `codeql_lsp_diagnostics` returns zero diagnostics for a
syntactically and semantically valid QL snippet.

## INPUTS

- **ql_code**: A valid inline QL query (`select 1 + 1`).

## EXPECTED OUTPUTS

- `isValid` is `true`, zero errors/warnings in the summary.
- The `valid_query.ql` file remains unchanged.
- Monitoring state updated to record a successful `codeql_lsp_diagnostics` call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sessions": [
{
"id": "integration_test_session",
"calls": [
{
"tool": "codeql_lsp_diagnostics",
"timestamp": "2026-02-08T00:00:00.000Z",
"status": "success"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @name Valid Test Query
* @description A valid CodeQL query with no syntax errors
* @id test/valid-query
* @kind problem
* @problem.severity warning
*/

from string x
where x = "test"
select x, "This is a valid query"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sessions": [],
"parameters": {
"ql_code": "select 1 + 1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @name Valid Test Query
* @description A valid CodeQL query with no syntax errors
* @id test/valid-query
* @kind problem
* @problem.severity warning
*/

from string x
where x = "test"
select x, "This is a valid query"
Loading
Loading