Skip to content

Commit

Permalink
Update MethodName component to receive specific props (#3491)
Browse files Browse the repository at this point in the history
  • Loading branch information
charisk authored Mar 20, 2024
1 parent 724370f commit 3519139
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions extensions/ql-vscode/src/view/model-editor/MethodName.tsx
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>
);
};

0 comments on commit 3519139

Please sign in to comment.