Attach comments in multiparser (#2253)

Otherwise it doesn't print comments :(
master
Christopher Chedeau 2017-06-24 11:06:50 -07:00 committed by GitHub
parent 4b955a14c4
commit 2f96357884
4 changed files with 32 additions and 0 deletions

View File

@ -3,6 +3,7 @@
const util = require("./util");
const docUtils = require("./doc-utils");
const docBuilders = require("./doc-builders");
const comments = require("./comments");
const indent = docBuilders.indent;
const hardline = docBuilders.hardline;
const softline = docBuilders.softline;
@ -12,6 +13,9 @@ function printSubtree(subtreeParser, path, print, options) {
const next = Object.assign({}, { transformDoc: doc => doc }, subtreeParser);
next.options = Object.assign({}, options, next.options);
const ast = require("./parser").parse(next.text, next.options);
const astComments = ast.comments;
delete ast.comments;
comments.attach(astComments, ast, next.text, next.options);
const nextDoc = require("./printer").printAstToDoc(ast, next.options);
return next.transformDoc(nextDoc, { path, print });
}

View File

@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`comments.js 1`] = `
graphql.experimental\`
# required by createPaginationContainer
fragment MobileHomeDiffsSearchList_search on DifferentialRevisionSearch {
# required by createPaginationContainer
name
}
\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
graphql.experimental\`
# required by createPaginationContainer
fragment MobileHomeDiffsSearchList_search on DifferentialRevisionSearch {
# required by createPaginationContainer
name
}
\`;
`;

View File

@ -0,0 +1,7 @@
graphql.experimental`
# required by createPaginationContainer
fragment MobileHomeDiffsSearchList_search on DifferentialRevisionSearch {
# required by createPaginationContainer
name
}
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);