Skip to content

Commit 374bfac

Browse files
committed
using Prettier's getNextNonSpaceNonCommentCharacterIndex and ignoring our old implementation for this
1 parent 71201b0 commit 374bfac

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/comments/handlers/ContractDefinition.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
const {
2-
util: { addLeadingComment, addTrailingComment, addDanglingComment }
2+
util: {
3+
addLeadingComment,
4+
addTrailingComment,
5+
addDanglingComment,
6+
getNextNonSpaceNonCommentCharacterIndex
7+
}
38
} = require('prettier');
4-
const privateUtil = require('../../prettier-comments/common/util');
59

610
function handleContractDefinitionComments(
711
text,
@@ -20,10 +24,8 @@ function handleContractDefinitionComments(
2024
// contract a is abc /* comment */ {}
2125
// The only workaround I found is to look at the next character to see if
2226
// it is a {}.
23-
const nextCharacter = privateUtil.getNextNonSpaceNonCommentCharacter(
24-
text,
25-
comment,
26-
options.locEnd
27+
const nextCharacter = text.charAt(
28+
getNextNonSpaceNonCommentCharacterIndex(text, comment, options.locEnd)
2729
);
2830

2931
// The comment is behind the start of the Block `{}` or behind a base contract

src/nodes/FunctionDefinition.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const {
22
doc: {
33
builders: { dedent, group, hardline, indent, join, line }
4-
}
4+
},
5+
util: { getNextNonSpaceNonCommentCharacterIndex }
56
} = require('prettier/standalone');
67

7-
const privateUtil = require('../prettier-comments/common/util');
88
const printSeparatedList = require('./print-separated-list');
99
const printSeparatedItem = require('./print-separated-item');
1010
const printComments = require('./print-comments');
@@ -45,10 +45,12 @@ const parameters = (parametersType, node, path, print, options) => {
4545
path,
4646
options,
4747
(comment) =>
48-
privateUtil.getNextNonSpaceNonCommentCharacter(
49-
options.originalText,
50-
comment,
51-
options.locEnd
48+
options.originalText.charAt(
49+
getNextNonSpaceNonCommentCharacterIndex(
50+
options.originalText,
51+
comment,
52+
options.locEnd
53+
)
5254
) === ')'
5355
);
5456
return paremeterComments.parts.length > 0

0 commit comments

Comments
 (0)