Skip to content

Commit

Permalink
refactor: rename line-splitting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ony3000 committed May 15, 2024
1 parent b12e8ce commit 81862fd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/packages/core-parts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ function parseLineByLine(
}

/**
* If `Text` exists after `ClosingBrace`, add a line break between `ClosingBrace` and `Text`.
* Add a line break after `ClosingBrace`.
*/
function splitLineStartingWithClosingBrace(lineNodes: LineNode[]) {
function splitLineContainingClosingBrace(lineNodes: LineNode[]) {
for (let lineIndex = lineNodes.length - 1; lineIndex >= 0; lineIndex -= 1) {
const { indentLevel, parts } = lineNodes[lineIndex];
const temporaryLineNodes: LineNode[] = [];
Expand Down Expand Up @@ -120,9 +120,9 @@ function splitLineStartingWithClosingBrace(lineNodes: LineNode[]) {
}

/**
* If `Text` exists before `OpeningBrace`, add a line break between `OpeningBrace` and `Text`.
* Add a line break before `OpeningBrace`.
*/
function splitLineEndingWithOpeningBrace(lineNodes: LineNode[]) {
function splitLineContainingOpeningBrace(lineNodes: LineNode[]) {
for (let lineIndex = lineNodes.length - 1; lineIndex >= 0; lineIndex -= 1) {
const { indentLevel, parts } = lineNodes[lineIndex];
const temporaryLineNodes: LineNode[] = [];
Expand Down Expand Up @@ -199,10 +199,10 @@ export function parseLineByLineAndAssemble(

const lineNodes = parseLineByLine(formattedText, indentUnit, targetBraceNodes);

splitLineStartingWithClosingBrace(lineNodes);
splitLineContainingClosingBrace(lineNodes);

if (options.braceStyle === 'allman') {
splitLineEndingWithOpeningBrace(lineNodes);
splitLineContainingOpeningBrace(lineNodes);
}

return assembleLine(lineNodes, indentUnit);
Expand Down

0 comments on commit 81862fd

Please sign in to comment.