mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
This commit is contained in:
parent
77dd34b1b2
commit
d592f54910
3 changed files with 26 additions and 2 deletions
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { matchContainerName } from '../../utils/symbol_utils';
|
||||
|
||||
describe('matchSymbolName', () => {
|
||||
it('should match symbol that has type annotation', () => {
|
||||
expect(matchContainerName('Session', 'Session<key, value>')).toBe(true);
|
||||
});
|
||||
it('should not match symbol that has same start but not end with type annotation', () => {
|
||||
expect(matchContainerName('Session', 'SessionTail')).toBe(false);
|
||||
});
|
||||
});
|
|
@ -13,6 +13,7 @@ import { loadStructure, loadStructureFailed, loadStructureSuccess } from '../act
|
|||
import { ServerNotInitialized } from '../../common/lsp_error_codes';
|
||||
import { languageServerInitializing } from '../actions/language_server';
|
||||
import { SymbolWithMembers } from '../reducers/symbol';
|
||||
import { matchContainerName } from '../utils/symbol_utils';
|
||||
|
||||
const STRUCTURE_TREE_POLLING_INTERVAL_SEC = 3;
|
||||
|
||||
|
@ -40,9 +41,8 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols =>
|
|||
if (containerName === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const regex = new RegExp(`^${containerName}[<(]?.*[>)]?$`);
|
||||
const result = tree.find((s: SymbolInformation) => {
|
||||
return regex.test(s.name);
|
||||
return matchContainerName(containerName, s.name);
|
||||
});
|
||||
if (result) {
|
||||
return result;
|
||||
|
|
8
x-pack/plugins/code/public/utils/symbol_utils.ts
Normal file
8
x-pack/plugins/code/public/utils/symbol_utils.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export const matchContainerName = (containerName: string, symbolName: string) =>
|
||||
new RegExp(`^${containerName}[[<(].*[>)]]?$`).test(symbolName);
|
Loading…
Add table
Add a link
Reference in a new issue