(props: ScopeTreeProps)
| 122 | } |
| 123 | |
| 124 | const ScopeTree = (props: ScopeTreeProps) => { |
| 125 | const { scope, startDrag } = props |
| 126 | |
| 127 | const allVars = {} |
| 128 | const allFuncs = {} |
| 129 | |
| 130 | for (const [name, entry] of scope.variables.entries()) { |
| 131 | let hasVar = false |
| 132 | let funcSignature: FunctionSignature = null |
| 133 | for (const metadata of entry.declarers.values()) { |
| 134 | if (metadata.typeInfo?.category === TypeCategory.Function) { |
| 135 | funcSignature = metadata.typeInfo |
| 136 | } else { |
| 137 | hasVar = true |
| 138 | } |
| 139 | } |
| 140 | if (hasVar) { |
| 141 | const nodeBlock = getSingleNodeFragment( |
| 142 | { |
| 143 | type: 'PY_IDENTIFIER', |
| 144 | properties: { identifier: name }, |
| 145 | childSets: {}, |
| 146 | }, |
| 147 | false |
| 148 | ) |
| 149 | allVars[name] = ( |
| 150 | <div className="scope-tray-entry"> |
| 151 | <MicroNode fragment={nodeBlock} startDrag={startDrag} /> |
| 152 | </div> |
| 153 | ) |
| 154 | } |
| 155 | if (funcSignature) { |
| 156 | const func = new PythonCallVariable(null, name, funcSignature) |
| 157 | const nodeBlock = getSingleNodeFragment(func.serialize(), false) |
| 158 | allFuncs[name] = ( |
| 159 | <div className="scope-tray-entry"> |
| 160 | <MicroNode fragment={nodeBlock} startDrag={startDrag} /> |
| 161 | </div> |
| 162 | ) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | const varNames = Object.keys(allVars) |
| 167 | varNames.sort() |
| 168 | const funcNames = Object.keys(allFuncs) |
| 169 | funcNames.sort() |
| 170 | |
| 171 | const scopes = Array.from(scope.childScopes) |
| 172 | return ( |
| 173 | <> |
| 174 | {varNames.map((name, idx) => { |
| 175 | return <React.Fragment key={name}>{allVars[name]}</React.Fragment> |
| 176 | })} |
| 177 | {funcNames.map((name, idx) => { |
| 178 | return <React.Fragment key={name}>{allFuncs[name]}</React.Fragment> |
| 179 | })} |
| 180 | {scopes.map((childScope: PythonScope, idx) => { |
| 181 | if (!childScope.hasEntries()) { |
nothing calls this directly
no test coverage detected