prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
89 lines (81 loc) • 1.72 kB
JavaScript
import {
handleOwnLineComment,
handleEndOfLineComment,
handleRemainingComment
} from '../prettier-comments/language-js/comments.js';
import handlers from './handlers/index.js';
export function solidityHandleOwnLineComment(
comment,
text,
options,
ast,
isLastComment
) {
const { precedingNode, enclosingNode, followingNode } = comment;
const handlerArguments = {
text,
precedingNode,
enclosingNode,
followingNode,
comment,
options
};
if (
handlers.some((handler) => handler(handlerArguments)) ||
handleOwnLineComment(comment, text, options, ast, isLastComment)
) {
return true;
}
return false;
}
export function solidityHandleEndOfLineComment(
comment,
text,
options,
ast,
isLastComment
) {
const { precedingNode, enclosingNode, followingNode } = comment;
const handlerArguments = {
text,
precedingNode,
enclosingNode,
followingNode,
comment,
options
};
if (
handlers.some((handler) => handler(handlerArguments)) ||
handleEndOfLineComment(comment, text, options, ast, isLastComment)
) {
return true;
}
return false;
}
export function solidityHandleRemainingComment(
comment,
text,
options,
ast,
isLastComment
) {
const { precedingNode, enclosingNode, followingNode } = comment;
const handlerArguments = {
text,
precedingNode,
enclosingNode,
followingNode,
comment,
options
};
if (
handlers.some((handler) => handler(handlerArguments)) ||
handleRemainingComment(comment, text, options, ast, isLastComment)
) {
return true;
}
return false;
}
export function isBlockComment(comment) {
return comment.type === 'BlockComment';
}