-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update MethodName component to receive specific props (#3491)
- Loading branch information
Showing
1 changed file
with
26 additions
and
11 deletions.
There are no files selected for viewing
37 changes: 26 additions & 11 deletions
37
extensions/ql-vscode/src/view/model-editor/MethodName.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,48 @@ | ||
import { styled } from "styled-components"; | ||
import type { Method } from "../../model-editor/method"; | ||
|
||
const Name = styled.span` | ||
font-family: var(--vscode-editor-font-family); | ||
word-break: break-all; | ||
`; | ||
|
||
const TypeMethodName = (method: Method) => { | ||
if (!method.typeName) { | ||
return <>{method.methodName}</>; | ||
const TypeMethodName = ({ | ||
typeName, | ||
methodName, | ||
}: { | ||
typeName?: string; | ||
methodName?: string; | ||
}) => { | ||
if (!typeName) { | ||
return <>{methodName}</>; | ||
} | ||
|
||
if (!method.methodName) { | ||
return <>{method.typeName}</>; | ||
if (!methodName) { | ||
return <>{typeName}</>; | ||
} | ||
|
||
return ( | ||
<> | ||
{method.typeName}.{method.methodName} | ||
{typeName}.{methodName} | ||
</> | ||
); | ||
}; | ||
|
||
export const MethodName = (method: Method): React.JSX.Element => { | ||
export const MethodName = ({ | ||
packageName, | ||
typeName, | ||
methodName, | ||
methodParameters, | ||
}: { | ||
packageName: string; | ||
typeName?: string; | ||
methodName?: string; | ||
methodParameters?: string; | ||
}): React.JSX.Element => { | ||
return ( | ||
<Name> | ||
{method.packageName && <>{method.packageName}.</>} | ||
<TypeMethodName {...method} /> | ||
{method.methodParameters} | ||
{packageName && <>{packageName}.</>} | ||
<TypeMethodName typeName={typeName} methodName={methodName} /> | ||
{methodParameters} | ||
</Name> | ||
); | ||
}; |