Skip to content

Commit 5a8518b

Browse files
authored
Merge pull request #528 from prettier-solidity/prettier_utils
using Prettier's utils and ignoring our old implementation for these
2 parents 40f3aa7 + 374bfac commit 5a8518b

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

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/comments/printer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const {
22
doc: {
33
builders: { hardline, join }
4-
}
4+
},
5+
util: { hasNewline }
56
} = require('prettier');
6-
const { hasNewline } = require('../prettier-comments/common/util');
77

88
function isIndentableBlockComment(comment) {
99
// If the comment has multiple lines and every line starts with a star

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)