|
|
@ -36,20 +36,18 @@ export interface RemixUiEditorContextViewProps { |
|
|
|
declarationOf: (node: astNode) => astNode |
|
|
|
declarationOf: (node: astNode) => astNode |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isDefinition (node: any) { |
|
|
|
function isDefinition(node: any) { |
|
|
|
return node.nodeType === 'ContractDefinition' || |
|
|
|
return node.nodeType === 'ContractDefinition' || |
|
|
|
node.nodeType === 'FunctionDefinition' || |
|
|
|
node.nodeType === 'FunctionDefinition' || |
|
|
|
node.nodeType === 'ModifierDefinition' || |
|
|
|
node.nodeType === 'ModifierDefinition' || |
|
|
|
node.nodeType === 'VariableDeclaration' || |
|
|
|
node.nodeType === 'VariableDeclaration' || |
|
|
|
node.nodeType === 'StructDefinition' || |
|
|
|
node.nodeType === 'StructDefinition' || |
|
|
|
node.nodeType === 'EventDefinition' |
|
|
|
node.nodeType === 'EventDefinition' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type nullableAstNode = astNode | null |
|
|
|
type nullableAstNode = astNode | null |
|
|
|
|
|
|
|
|
|
|
|
export function RemixUiEditorContextView (props: RemixUiEditorContextViewProps) { |
|
|
|
export function RemixUiEditorContextView(props: RemixUiEditorContextViewProps) { |
|
|
|
/* |
|
|
|
/* |
|
|
|
gotoLineDisableRef is used to temporarily disable the update of the view. |
|
|
|
gotoLineDisableRef is used to temporarily disable the update of the view. |
|
|
|
e.g when the user ask the component to "gotoLine" we don't want to rerender the component (but just to put the mouse on the desired line) |
|
|
|
e.g when the user ask the component to "gotoLine" we don't want to rerender the component (but just to put the mouse on the desired line) |
|
|
@ -68,7 +66,7 @@ export function RemixUiEditorContextView (props: RemixUiEditorContextViewProps) |
|
|
|
currentNode: null, |
|
|
|
currentNode: null, |
|
|
|
gasEstimation: { executionCost: '', codeDepositCost: '' } |
|
|
|
gasEstimation: { executionCost: '', codeDepositCost: '' } |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
props.onContextListenerChanged(async (nodes: Array<astNode>) => { |
|
|
|
props.onContextListenerChanged(async (nodes: Array<astNode>) => { |
|
|
|
if (gotoLineDisableRef.current) { |
|
|
|
if (gotoLineDisableRef.current) { |
|
|
@ -88,9 +86,9 @@ export function RemixUiEditorContextView (props: RemixUiEditorContextViewProps) |
|
|
|
references = await props.referencesOf(currentNode) |
|
|
|
references = await props.referencesOf(currentNode) |
|
|
|
if (currentNode.nodeType === 'FunctionDefinition') { |
|
|
|
if (currentNode.nodeType === 'FunctionDefinition') { |
|
|
|
gasEstimation = await props.gasEstimation(currentNode) |
|
|
|
gasEstimation = await props.gasEstimation(currentNode) |
|
|
|
}
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
let activeHighlights = await props.getActiveHighlights() |
|
|
|
const activeHighlights = await props.getActiveHighlights() |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, nodes, references, activeHighlights, currentNode, gasEstimation } |
|
|
|
return { ...prevState, nodes, references, activeHighlights, currentNode, gasEstimation } |
|
|
|
}) |
|
|
|
}) |
|
|
|