diff --git a/ets2panda/bindings/test/cases.ts b/ets2panda/bindings/test/cases.ts index 0440a9f933d6de658275bdc5e3bb5f67b97de0df..0b49f7c4a0c1061294f0966378f1f9dff5fc7f40 100644 --- a/ets2panda/bindings/test/cases.ts +++ b/ets2panda/bindings/test/cases.ts @@ -120,7 +120,8 @@ export const basicCases: TestCases = { '5': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights5.ets'), 619], '6': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights6.ets'), 657], '7': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights7.ets'), 733], - '8': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights8.ets'), 677] + '8': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights8.ets'), 677], + '9': [resolveTestPath('test/testcases/getDocumentHighlights/getDocumentHighlights9.ets'), 620] }, getCompletionAtPosition: { expectedFilePath: resolveTestPath('test/expected/getCompletionAtPosition.json'), diff --git a/ets2panda/bindings/test/expected/getDocumentHighlights.json b/ets2panda/bindings/test/expected/getDocumentHighlights.json index cb53f7cf9a11a73a903ae19164bb7c26cfa72379..6ac9f6191e07a308c95e936c2668f0fb247a44bb 100644 --- a/ets2panda/bindings/test/expected/getDocumentHighlights.json +++ b/ets2panda/bindings/test/expected/getDocumentHighlights.json @@ -346,5 +346,38 @@ ] } ] + }, + "9": { + "documentHighlights": [ + { + "fileName": "getDocumentHighlights9.ets", + "highlightSpans": [ + { + "fileName": "getDocumentHighlights9.ets", + "textSpan": { + "start": 618, + "length": 4 + }, + "contextSpan": { + "start": 0, + "length": 0 + }, + "kind": 2 + }, + { + "fileName": "getDocumentHighlights9.ets", + "textSpan": { + "start": 655, + "length": 4 + }, + "contextSpan": { + "start": 0, + "length": 0 + }, + "kind": 2 + } + ] + } + ] } } diff --git a/ets2panda/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights9.ets b/ets2panda/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights9.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1093ed3782931d29b8f0293d1df3ef6291c688b --- /dev/null +++ b/ets2panda/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights9.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Text } from '@ohos.arkui.component' + +Text() \ No newline at end of file diff --git a/ets2panda/lsp/src/internal_api.cpp b/ets2panda/lsp/src/internal_api.cpp index 86b27c2036ce2b4c18f193d22c97b17b8de7db76..3162e6643295cb7fc310239fb1f99547801c46bf 100644 --- a/ets2panda/lsp/src/internal_api.cpp +++ b/ets2panda/lsp/src/internal_api.cpp @@ -721,6 +721,7 @@ HighlightSpanKind GetHightlightSpanKind(ir::AstNode *identifierDeclaration, ir:: DocumentHighlights GetSemanticDocumentHighlights(es2panda_Context *context, size_t position) { auto ctx = reinterpret_cast(context); + SetPhaseManager(ctx->phaseManager); auto ast = ctx->parserProgram->Ast(); std::string fileName(ctx->sourceFile->filePath); auto touchingToken = GetTouchingToken(context, position, false);