Skip to content

Commit

Permalink
format_code_in_doc_comments = true
Browse files Browse the repository at this point in the history
Summary: D52632085

Reviewed By: zertosh

Differential Revision: D52639960

fbshipit-source-id: c659c45c7b1752b556ffce3d1ee65faed01b8e87
  • Loading branch information
stepancheg authored and facebook-github-bot committed Jan 10, 2024
1 parent 1d03b4e commit a130c02
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 19 deletions.
7 changes: 0 additions & 7 deletions cst_to_ast.rs
Expand Up @@ -87,7 +87,6 @@ pub struct RecoverableErrorLocation {
/// Parser is responsible for driving parsing of a python code String into an internal CST representation
/// before lowering to an AST. The AST is expected to match 1:1 with CPython. The AST is held within an
/// `ASTAndMetaData` instance (and potentitally additional metadata)
///
#[derive(Debug)]
pub struct Parser {
code: String,
Expand All @@ -107,7 +106,6 @@ pub struct FilteredCSTParser<'a> {

///
/// `ASTAndMetaData` presently just holds the lowered AST
///
#[derive(Debug)]
pub struct ASTAndMetaData {
// AST root for what was parsed correctly
Expand Down Expand Up @@ -253,7 +251,6 @@ impl Parser {
/// Public entry point to parse code.
/// Code is defined at construction time (`new`) but it could also be passed
/// to this function. We could also pass a delta
///
pub fn parse(&mut self) -> Result<(), ParserError> {
let mut cst_to_ast = SitterParser::new();
cst_to_ast.set_language(tree_sitter_python::language())?;
Expand Down Expand Up @@ -305,7 +302,6 @@ impl Parser {

///
/// Mark all error nodes from the Tree-sitter CST as SyntaxErrors
///
fn find_error_nodes(&mut self, node: TSNode) {
if node.kind() == "ERROR" {
let parser_error = RecoverableError::SyntaxError("invalid syntax".to_string());
Expand Down Expand Up @@ -5062,7 +5058,6 @@ impl<'parser> FilteredCSTParser<'parser> {
/// 6. We add escape characters again if needed (' -> \' or " -> \"). In practice,
/// this is relevant only when the the string contains both single (') and double
/// (") quotes.
///
fn process_string(&mut self, string_contents: String, node: &Node) -> ExprDesc {
// TODO: this method is getting quite unweildly, we should refactor it.
let mut string_contents = string_contents;
Expand Down Expand Up @@ -5327,7 +5322,6 @@ impl<'parser> FilteredCSTParser<'parser> {
/// Will return an identifier as a String and will record a
/// recoverable error if the identifier is invalid
/// (e.g. keyword, empty space etc)
///
fn get_valid_identifier(&mut self, node: &Node) -> String {
let identifier: String = self.get_text(node);
self.check_identifier_valid(&identifier, node);
Expand All @@ -5337,7 +5331,6 @@ impl<'parser> FilteredCSTParser<'parser> {
///
/// Will record a recoverable error if the identifier
/// is invalid (e.g. keyword, empty space etc)
///
fn check_identifier_valid(&mut self, identifier: &String, node: &Node) {
if self.python_keywords.contains(identifier) {
self.record_recoverable_error(
Expand Down
1 change: 0 additions & 1 deletion ffi_python.rs
Expand Up @@ -58,7 +58,6 @@ fn py_parse_module_print_ast_pretty_and_errors(

///
/// run errpy but ignore result - useful for benchmarking
///
#[pyfunction]
fn py_parse_module(input_code: String) -> PyResult<()> {
let mut cst_to_ast = CSTToASTParser::new(input_code);
Expand Down
2 changes: 0 additions & 2 deletions parser_post_process.rs
Expand Up @@ -35,7 +35,6 @@ impl ParserPostprocessor {
/// * It begins with a letter or an underscore.
/// * It is not followed by any punctuation.
/// * It is not a reserved keyword.
///
fn valid_tokens_preceding_dot(&self, line: &str) -> bool {
let preceding_tokens = match line.rsplit_once([' ', '.', ')', '\'', '}', ']', '\"']) {
Some((_, identifier_and_trailing_dot)) => identifier_and_trailing_dot,
Expand All @@ -55,7 +54,6 @@ impl ParserPostprocessor {
///
/// Injects a `AUTOCOMPLETE_TOKEN` to the input code if a valid identifier
/// followed by a trailing dot is found.
///
fn process_trailing_dots(&self, line: &str) -> String {
let re = Regex::new(r"\.\s").expect("Invalid Regex");
let mut result = Vec::new();
Expand Down
1 change: 0 additions & 1 deletion parser_pre_process.rs
Expand Up @@ -70,7 +70,6 @@ fn handle_quote_character(
///
/// For now this function is only used on in the context of AST production
/// so it's fit for purpose.
///
pub fn remove_comments(input_code: String) -> String {
use StringCommentState::*;

Expand Down
1 change: 0 additions & 1 deletion printers.rs
Expand Up @@ -125,7 +125,6 @@ impl ParsingAndPrinter {

///
/// Will return an empty string if there are no errors
///
fn extract_errors(metadata: &ASTAndMetaData) -> String {
let mut errors = String::new();
if !metadata.recoverable_errors.is_empty() {
Expand Down
1 change: 0 additions & 1 deletion printers/ast_pretty_print.rs
Expand Up @@ -306,7 +306,6 @@ fn format_vec_pattern(choices: &[Pattern], pprint_output: &mut PrintHelper) {
///
/// Function will format output without a trailing newline
/// the caller is to add newline after the block if appropriate
///
fn format_block(body: &[Stmt], pprint_output: &mut PrintHelper) {
pprint_output.inc_ident();
for item in body.iter() {
Expand Down
1 change: 0 additions & 1 deletion printers/ast_print.rs
Expand Up @@ -848,7 +848,6 @@ impl fmt::Display for Cmpop {
/// Attempt to replicate PyOS_double_to_string function used by float_repr
/// in floatobject.c for representing floats as strings
/// https://github.com/python/cpython/blob/df81d2892eed3a256eb61ce59304f2173fb0c945/Python/pystrtod.c
///
pub fn cpython_float_to_string(value: &f64, is_complex: bool) -> String {
if value.log10().ceil() >= 17. {
// 17 digits or more requires exponent representation with + after the e
Expand Down
4 changes: 0 additions & 4 deletions sitter.rs
Expand Up @@ -23,7 +23,6 @@ use crate::node_wrapper::Node;

///
/// Token supertype after extraction from Tree-sitter CST
///
#[derive(Debug)]
pub enum NodeType<'a> {
Error,
Expand Down Expand Up @@ -158,7 +157,6 @@ pub enum Delimiter {
///
/// A production is a node to traverse and it carries a
/// reference to the sitter node
///
#[derive(Debug)]
pub struct Production<'a> {
pub production_kind: ProductionKind,
Expand All @@ -167,7 +165,6 @@ pub struct Production<'a> {

///
/// Various forms of ProductionKind
///
#[derive(Debug, PartialEq)]
#[allow(non_camel_case_types)]
pub enum ProductionKind {
Expand Down Expand Up @@ -282,7 +279,6 @@ impl<'a> Production<'a> {

///
/// Wrap a sitter `Node` into its structured wrapper (`NodeType`)
///
pub fn get_node_type<'a>(node: &'a Node<'a>) -> NodeType<'a> {
match node.kind() {
// keywords
Expand Down
1 change: 0 additions & 1 deletion tests/test_parser_post_process.rs
Expand Up @@ -5,7 +5,6 @@

///
/// Tests the process_trailing_dots method of the `parser_post_process` module.
///

#[cfg(test)]
mod process_trailing_dots_tests {
Expand Down

0 comments on commit a130c02

Please sign in to comment.