|
| 1 | +/* eslint-disable no-console */ |
1 | 2 | // ===========================
|
2 | 3 | // Type Definitions
|
3 | 4 | // ===========================
|
@@ -217,7 +218,6 @@ export function createProcessingState(): ProcessingState {
|
217 | 218 | moduleImports: new Map(),
|
218 | 219 | availableTypes: new Map(),
|
219 | 220 | availableValues: new Map(),
|
220 |
| - sourceLines: [], |
221 | 221 | currentIndentation: '',
|
222 | 222 | declarationBuffer: null,
|
223 | 223 | }
|
@@ -259,20 +259,8 @@ export function processLine(line: string, state: ProcessingState): void {
|
259 | 259 | const indent = getIndentation(line)
|
260 | 260 | console.log('Processing line with indent:', { line, indent })
|
261 | 261 |
|
262 |
| - if (!state.sourceLines) { |
263 |
| - state.sourceLines = [] |
264 |
| - } |
265 |
| - |
266 |
| - state.sourceLines.push(line) |
267 | 262 | state.currentIndentation = indent
|
268 | 263 |
|
269 |
| - if (!state.isMultiLineDeclaration) { |
270 |
| - state.declarationFormatting = { |
271 |
| - indent, |
272 |
| - content: [], |
273 |
| - } |
274 |
| - } |
275 |
| - |
276 | 264 | const trimmedLine = line.trim()
|
277 | 265 | if (!trimmedLine)
|
278 | 266 | return
|
@@ -509,9 +497,9 @@ export function processDeclaration(declaration: string, state: ProcessingState):
|
509 | 497 | function processDeclarationBuffer(
|
510 | 498 | buffer: NonNullable<ProcessingState['declarationBuffer']>,
|
511 | 499 | state: ProcessingState,
|
| 500 | + isExported: boolean, |
512 | 501 | ): string {
|
513 | 502 | const declaration = buffer.lines.join('\n')
|
514 |
| - const isExported = needsExport(declaration) |
515 | 503 | const cleaned = cleanDeclaration(declaration)
|
516 | 504 |
|
517 | 505 | switch (buffer.type) {
|
@@ -1425,8 +1413,11 @@ function processDeclarationLine(line: string, state: ProcessingState): void {
|
1425 | 1413 | // Clean up any existing declaration first
|
1426 | 1414 | if (state.declarationBuffer) {
|
1427 | 1415 | const cleaned = cleanDeclaration(state.declarationBuffer.lines.join('\n'))
|
1428 |
| - const isExported = needsExport(cleaned) |
1429 |
| - const processed = processDeclarationBuffer(state.declarationBuffer, state) |
| 1416 | + const processed = processDeclarationBuffer( |
| 1417 | + state.declarationBuffer, |
| 1418 | + state, |
| 1419 | + needsExport(cleaned), |
| 1420 | + ) |
1430 | 1421 |
|
1431 | 1422 | if (processed) {
|
1432 | 1423 | if (state.declarationBuffer.comments.length > 0) {
|
@@ -1454,8 +1445,11 @@ function processDeclarationLine(line: string, state: ProcessingState): void {
|
1454 | 1445 | // Check for completion
|
1455 | 1446 | if (isDeclarationComplete(state.declarationBuffer.lines)) {
|
1456 | 1447 | const cleaned = cleanDeclaration(state.declarationBuffer.lines.join('\n'))
|
1457 |
| - const isExported = needsExport(cleaned) |
1458 |
| - const processed = processDeclarationBuffer(state.declarationBuffer, state) |
| 1448 | + const processed = processDeclarationBuffer( |
| 1449 | + state.declarationBuffer, |
| 1450 | + state, |
| 1451 | + needsExport(cleaned), |
| 1452 | + ) |
1459 | 1453 |
|
1460 | 1454 | if (processed) {
|
1461 | 1455 | if (state.declarationBuffer.comments.length > 0) {
|
|
0 commit comments