Skip to content

Commit

Permalink
Remove signatureHelp prop
Browse files Browse the repository at this point in the history
  • Loading branch information
ncordon committed Jan 19, 2024
1 parent 3af12ed commit f63c123
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
11 changes: 1 addition & 10 deletions packages/react-codemirror/src/CypherEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ export interface CypherEditorProps {
* @default true
*/
lint?: boolean;
/**
* Whether the editor should perform signature help.
*
* @default true
*/
signatureHelp?: boolean;
/**
* The schema to use for autocompletion and linting.
*
Expand Down Expand Up @@ -177,7 +171,6 @@ export class CypherEditor extends Component<CypherEditorProps> {

static defaultProps: CypherEditorProps = {
lint: true,
signatureHelp: true,
schema: {},
overrideThemeBackgroundColor: false,
lineWrap: false,
Expand All @@ -194,12 +187,11 @@ export class CypherEditor extends Component<CypherEditorProps> {
overrideThemeBackgroundColor,
schema,
lint,
signatureHelp,
onChange,
onExecute,
} = this.props;

this.schemaRef.current = { schema, lint, signatureHelp };
this.schemaRef.current = { schema, lint };

const themeExtension = getThemeExtension(
theme,
Expand Down Expand Up @@ -329,7 +321,6 @@ export class CypherEditor extends Component<CypherEditorProps> {
*/
this.schemaRef.current.schema = this.props.schema;
this.schemaRef.current.lint = this.props.lint;
this.schemaRef.current.signatureHelp = this.props.signatureHelp;
}

componentWillUnmount(): void {
Expand Down
10 changes: 0 additions & 10 deletions packages/react-codemirror/src/e2e_tests/signature-help.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ test('Prop signatureHelp set to false disables signature help for functions', as
await mount(
<CypherEditor
value={query}
signatureHelp={false}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -64,7 +63,6 @@ test('Prop signatureHelp set to true disables signature help for procedures', as
await mount(
<CypherEditor
value={query}
signatureHelp={false}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -86,7 +84,6 @@ test('Prop signatureHelp set to true enables signature help', async ({
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand Down Expand Up @@ -125,7 +122,6 @@ test('Signature help shows the description for the first argument', async ({
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -150,7 +146,6 @@ test('Signature help shows the description for the second argument', async ({
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -175,7 +170,6 @@ test('Signature help shows description for arguments with a space following a se
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -200,7 +194,6 @@ test('Signature help shows the description for the third argument', async ({
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -225,7 +218,6 @@ test('Signature help only shows the description past the last argument', async (
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -250,7 +242,6 @@ test('Signature help does not show any help when method finished', async ({
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand All @@ -272,7 +263,6 @@ test('Signature help does not blow up on empty query', async ({
await mount(
<CypherEditor
value={query}
signatureHelp={true}
schema={testData.mockSchema}
autofocus={true}
/>,
Expand Down
14 changes: 11 additions & 3 deletions packages/react-codemirror/src/lang-cypher/signature-help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@ function getSignatureHelpTooltip(
): Tooltip[] {
let result: Tooltip[] = [];
const schema = config.schema;
const tokens = parserWrapper.parsingResult.tokens;
const lastToken = tokens.filter((token) => token.channel == 0).at(-2);

const tokens = parserWrapper.parsingResult.tokens.filter(
(token) => token.channel == 0,
);
const lastToken = tokens.at(-2);
const prevToken = tokens.at(-3);

if (schema && config.signatureHelp && lastToken) {
const pos = state.selection.main.head;
const tree = parserWrapper.parsingResult;
const isOpenBracket = lastToken.text === '(';
const isPairOfBrackets =
prevToken !== undefined &&
prevToken.text === '(' &&
lastToken.text === ')';
const isSeparator = lastToken.text === ',';

if (
(isOpenBracket || isSeparator) &&
(isOpenBracket || isPairOfBrackets || isSeparator) &&
tree &&
findParent(tree.stopNode, (parent) =>
isOpenBracket
Expand Down

0 comments on commit f63c123

Please sign in to comment.