From d52bdcfb25f2b7fdc74b43ec0709275bb253f1bd Mon Sep 17 00:00:00 2001 From: Gleb Date: Mon, 24 Apr 2023 13:04:05 +0300 Subject: [PATCH 1/5] Document public members, where it is necessary --- lib/domain/language_check_service.dart | 2 ++ lib/domain/mistake.dart | 13 +++++++++++++ lib/implementations/debounce_lang_tool_service.dart | 5 +++++ lib/implementations/lang_tool_service.dart | 3 +++ .../throttling_lang_tool_service.dart | 5 +++++ lib/presentation/language_tool_text_field.dart | 10 +++++++++- 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/domain/language_check_service.dart b/lib/domain/language_check_service.dart index 1e80726..2689378 100644 --- a/lib/domain/language_check_service.dart +++ b/lib/domain/language_check_service.dart @@ -1,3 +1,5 @@ +// ignore_for_file: public_member_api_docs + import 'package:languagetool_textfield/domain/mistake.dart'; abstract class LanguageCheckService { diff --git a/lib/domain/mistake.dart b/lib/domain/mistake.dart index 731fff2..6923f51 100644 --- a/lib/domain/mistake.dart +++ b/lib/domain/mistake.dart @@ -1,10 +1,23 @@ +/// Object that stores information about a single writing mistake. class Mistake { + /// A brief description of the mistake. final String message; + + /// The type of mistake. final String type; + + /// Position of the beginning of the mistake. final int offset; + + /// Length of the mistake after the offset. final int length; + + /// A list of suggestions for replacing the mistake. + /// + /// Sorted by probability. final List replacements; + /// Object that stores information about a single writing mistake. const Mistake({ required this.message, required this.type, diff --git a/lib/implementations/debounce_lang_tool_service.dart b/lib/implementations/debounce_lang_tool_service.dart index 7599dff..e72c9a9 100644 --- a/lib/implementations/debounce_lang_tool_service.dart +++ b/lib/implementations/debounce_lang_tool_service.dart @@ -2,10 +2,15 @@ import 'package:languagetool_textfield/domain/language_check_service.dart'; import 'package:languagetool_textfield/domain/mistake.dart'; import 'package:throttling/throttling.dart'; +/// Implementation of language check service with debouncing. class DebounceLangToolService extends LanguageCheckService { + /// Base language check service. final LanguageCheckService baseService; + + /// Debouncing. final Debouncing debouncing; + /// Implementation of language check service with debouncing. DebounceLangToolService( this.baseService, Duration debouncingDuration, diff --git a/lib/implementations/lang_tool_service.dart b/lib/implementations/lang_tool_service.dart index 2a16cb2..f736a0e 100644 --- a/lib/implementations/lang_tool_service.dart +++ b/lib/implementations/lang_tool_service.dart @@ -2,9 +2,12 @@ import 'package:language_tool/language_tool.dart'; import 'package:languagetool_textfield/domain/language_check_service.dart'; import 'package:languagetool_textfield/domain/mistake.dart'; +/// Implementation of language check service with language tool service. class LangToolService extends LanguageCheckService { + /// Object that will be used to interact with LanguageTool API. final LanguageTool languageTool; + /// Implementation of language check service with language tool service. const LangToolService(this.languageTool); @override diff --git a/lib/implementations/throttling_lang_tool_service.dart b/lib/implementations/throttling_lang_tool_service.dart index 90f424e..120a5c0 100644 --- a/lib/implementations/throttling_lang_tool_service.dart +++ b/lib/implementations/throttling_lang_tool_service.dart @@ -2,10 +2,15 @@ import 'package:languagetool_textfield/domain/language_check_service.dart'; import 'package:languagetool_textfield/domain/mistake.dart'; import 'package:throttling/throttling.dart'; +/// Implementation of language check service with throttling. class ThrottlingLangToolService extends LanguageCheckService { + /// Base language check service. final LanguageCheckService baseService; + + /// Throttling. final Throttling throttling; + /// Implementation of LanguageCheckService with throttling. ThrottlingLangToolService( this.baseService, Duration throttlingDuration, diff --git a/lib/presentation/language_tool_text_field.dart b/lib/presentation/language_tool_text_field.dart index 769b5ce..2e8fb08 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/presentation/language_tool_text_field.dart @@ -1,12 +1,21 @@ import 'package:flutter/material.dart'; import 'package:languagetool_textfield/domain/language_check_service.dart'; +/// Widget for checking grammar errors. class LanguageToolTextField extends StatefulWidget { + /// Service for checking errors. final LanguageCheckService langService; + + /// The style to use for the text being edited. final TextStyle style; + + /// Decoration of widget final InputDecoration decoration; + + /// Will build custom errors based on state. final Widget Function()? mistakeBuilder; + /// Creates a widget that checks grammar errors. const LanguageToolTextField({ Key? key, required this.langService, @@ -20,7 +29,6 @@ class LanguageToolTextField extends StatefulWidget { } class _LanguageToolTextFieldState extends State { - @override Widget build(BuildContext context) { return const Placeholder(); From 8483304a528466694a5ae48fde8d25349f97b544 Mon Sep 17 00:00:00 2001 From: Gleb Date: Mon, 24 Apr 2023 13:43:21 +0300 Subject: [PATCH 2/5] Fix after review --- lib/domain/language_check_service.dart | 5 +++-- lib/domain/mistake.dart | 6 +++--- lib/implementations/debounce_lang_tool_service.dart | 2 +- lib/implementations/lang_tool_service.dart | 2 +- lib/implementations/throttling_lang_tool_service.dart | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/domain/language_check_service.dart b/lib/domain/language_check_service.dart index 2689378..24b6b65 100644 --- a/lib/domain/language_check_service.dart +++ b/lib/domain/language_check_service.dart @@ -1,9 +1,10 @@ -// ignore_for_file: public_member_api_docs - import 'package:languagetool_textfield/domain/mistake.dart'; +/// Base language check service. abstract class LanguageCheckService { + /// Base language check service constructor. const LanguageCheckService(); + /// Function that finds mistakes in given text. Future> findMistakes(String text); } diff --git a/lib/domain/mistake.dart b/lib/domain/mistake.dart index 6923f51..7c4e723 100644 --- a/lib/domain/mistake.dart +++ b/lib/domain/mistake.dart @@ -1,4 +1,4 @@ -/// Object that stores information about a single writing mistake. +/// A data model classs that stores information about a single writing mistake. class Mistake { /// A brief description of the mistake. final String message; @@ -6,7 +6,7 @@ class Mistake { /// The type of mistake. final String type; - /// Position of the beginning of the mistake. + /// A position of the beginning of the mistake. final int offset; /// Length of the mistake after the offset. @@ -17,7 +17,7 @@ class Mistake { /// Sorted by probability. final List replacements; - /// Object that stores information about a single writing mistake. + /// Create a new instance of the [Mistake] class const Mistake({ required this.message, required this.type, diff --git a/lib/implementations/debounce_lang_tool_service.dart b/lib/implementations/debounce_lang_tool_service.dart index e72c9a9..d6ba1f8 100644 --- a/lib/implementations/debounce_lang_tool_service.dart +++ b/lib/implementations/debounce_lang_tool_service.dart @@ -7,7 +7,7 @@ class DebounceLangToolService extends LanguageCheckService { /// Base language check service. final LanguageCheckService baseService; - /// Debouncing. + /// A debouncing used to debounce the API calls. final Debouncing debouncing; /// Implementation of language check service with debouncing. diff --git a/lib/implementations/lang_tool_service.dart b/lib/implementations/lang_tool_service.dart index f736a0e..c56a3f0 100644 --- a/lib/implementations/lang_tool_service.dart +++ b/lib/implementations/lang_tool_service.dart @@ -4,7 +4,7 @@ import 'package:languagetool_textfield/domain/mistake.dart'; /// Implementation of language check service with language tool service. class LangToolService extends LanguageCheckService { - /// Object that will be used to interact with LanguageTool API. + /// Objects of this class are used to interact with LanguageTool API. final LanguageTool languageTool; /// Implementation of language check service with language tool service. diff --git a/lib/implementations/throttling_lang_tool_service.dart b/lib/implementations/throttling_lang_tool_service.dart index 120a5c0..c4522b7 100644 --- a/lib/implementations/throttling_lang_tool_service.dart +++ b/lib/implementations/throttling_lang_tool_service.dart @@ -7,7 +7,7 @@ class ThrottlingLangToolService extends LanguageCheckService { /// Base language check service. final LanguageCheckService baseService; - /// Throttling. + /// A throttling used to throttle the API calls. final Throttling throttling; /// Implementation of LanguageCheckService with throttling. From 97f2fc79a8410796a80aef59dd18362afd6ebf0e Mon Sep 17 00:00:00 2001 From: Gleb Date: Mon, 24 Apr 2023 15:25:52 +0300 Subject: [PATCH 3/5] Fix after review --- lib/domain/language_check_service.dart | 2 +- lib/domain/mistake.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/domain/language_check_service.dart b/lib/domain/language_check_service.dart index 24b6b65..ac7ee83 100644 --- a/lib/domain/language_check_service.dart +++ b/lib/domain/language_check_service.dart @@ -2,7 +2,7 @@ import 'package:languagetool_textfield/domain/mistake.dart'; /// Base language check service. abstract class LanguageCheckService { - /// Base language check service constructor. + /// Creates a new instance of the [LanguageCheckService] class. const LanguageCheckService(); /// Function that finds mistakes in given text. diff --git a/lib/domain/mistake.dart b/lib/domain/mistake.dart index 7c4e723..b2b4337 100644 --- a/lib/domain/mistake.dart +++ b/lib/domain/mistake.dart @@ -3,7 +3,7 @@ class Mistake { /// A brief description of the mistake. final String message; - /// The type of mistake. + /// A type of this mistake. final String type; /// A position of the beginning of the mistake. @@ -17,7 +17,7 @@ class Mistake { /// Sorted by probability. final List replacements; - /// Create a new instance of the [Mistake] class + /// Creates a new instance of the [Mistake] class const Mistake({ required this.message, required this.type, From ee34a3b21351e1597fce25b30d2dcd7f9fb6f4c9 Mon Sep 17 00:00:00 2001 From: Gleb Date: Mon, 24 Apr 2023 18:14:11 +0300 Subject: [PATCH 4/5] Fix after review --- lib/domain/language_check_service.dart | 2 +- lib/domain/mistake.dart | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/domain/language_check_service.dart b/lib/domain/language_check_service.dart index ac7ee83..ef0db9f 100644 --- a/lib/domain/language_check_service.dart +++ b/lib/domain/language_check_service.dart @@ -5,6 +5,6 @@ abstract class LanguageCheckService { /// Creates a new instance of the [LanguageCheckService] class. const LanguageCheckService(); - /// Function that finds mistakes in given text. + /// Returns found mistakes in the given [text]. Future> findMistakes(String text); } diff --git a/lib/domain/mistake.dart b/lib/domain/mistake.dart index b2b4337..4d15317 100644 --- a/lib/domain/mistake.dart +++ b/lib/domain/mistake.dart @@ -1,4 +1,4 @@ -/// A data model classs that stores information about a single writing mistake. +/// A data model class that stores information about a single writing mistake. class Mistake { /// A brief description of the mistake. final String message; @@ -6,13 +6,13 @@ class Mistake { /// A type of this mistake. final String type; - /// A position of the beginning of the mistake. + /// A position of the beginning of this mistake. final int offset; - /// Length of the mistake after the offset. + /// Length of this mistake after the offset. final int length; - /// A list of suggestions for replacing the mistake. + /// A list of suggestions for replacing this mistake. /// /// Sorted by probability. final List replacements; From 61d935f8d7327c578d5e38ea5dbd00d799b56380 Mon Sep 17 00:00:00 2001 From: Gleb Date: Tue, 25 Apr 2023 12:08:47 +0300 Subject: [PATCH 5/5] Fix after review --- lib/domain/language_check_service.dart | 2 +- lib/domain/mistake.dart | 4 ++-- lib/implementations/debounce_lang_tool_service.dart | 6 +++--- lib/implementations/lang_tool_service.dart | 6 +++--- lib/implementations/throttling_lang_tool_service.dart | 7 ++++--- lib/presentation/language_tool_text_field.dart | 10 +++++----- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/domain/language_check_service.dart b/lib/domain/language_check_service.dart index ef0db9f..16843d9 100644 --- a/lib/domain/language_check_service.dart +++ b/lib/domain/language_check_service.dart @@ -1,6 +1,6 @@ import 'package:languagetool_textfield/domain/mistake.dart'; -/// Base language check service. +/// A base language check service. abstract class LanguageCheckService { /// Creates a new instance of the [LanguageCheckService] class. const LanguageCheckService(); diff --git a/lib/domain/mistake.dart b/lib/domain/mistake.dart index 4d15317..ecbd3a8 100644 --- a/lib/domain/mistake.dart +++ b/lib/domain/mistake.dart @@ -9,7 +9,7 @@ class Mistake { /// A position of the beginning of this mistake. final int offset; - /// Length of this mistake after the offset. + /// A length of this mistake after the offset. final int length; /// A list of suggestions for replacing this mistake. @@ -17,7 +17,7 @@ class Mistake { /// Sorted by probability. final List replacements; - /// Creates a new instance of the [Mistake] class + /// Creates a new instance of the [Mistake] class. const Mistake({ required this.message, required this.type, diff --git a/lib/implementations/debounce_lang_tool_service.dart b/lib/implementations/debounce_lang_tool_service.dart index d6ba1f8..ed14755 100644 --- a/lib/implementations/debounce_lang_tool_service.dart +++ b/lib/implementations/debounce_lang_tool_service.dart @@ -2,15 +2,15 @@ import 'package:languagetool_textfield/domain/language_check_service.dart'; import 'package:languagetool_textfield/domain/mistake.dart'; import 'package:throttling/throttling.dart'; -/// Implementation of language check service with debouncing. +/// A language check service with debouncing. class DebounceLangToolService extends LanguageCheckService { - /// Base language check service. + /// A base language check service. final LanguageCheckService baseService; /// A debouncing used to debounce the API calls. final Debouncing debouncing; - /// Implementation of language check service with debouncing. + /// Creates a new instance of the [DebounceLangToolService] class. DebounceLangToolService( this.baseService, Duration debouncingDuration, diff --git a/lib/implementations/lang_tool_service.dart b/lib/implementations/lang_tool_service.dart index c56a3f0..923b21c 100644 --- a/lib/implementations/lang_tool_service.dart +++ b/lib/implementations/lang_tool_service.dart @@ -2,12 +2,12 @@ import 'package:language_tool/language_tool.dart'; import 'package:languagetool_textfield/domain/language_check_service.dart'; import 'package:languagetool_textfield/domain/mistake.dart'; -/// Implementation of language check service with language tool service. +/// An implementation of language check service with language tool service. class LangToolService extends LanguageCheckService { - /// Objects of this class are used to interact with LanguageTool API. + /// An instance of this class that is used to interact with LanguageTool API. final LanguageTool languageTool; - /// Implementation of language check service with language tool service. + /// Creates a new instance of the [LangToolService]. const LangToolService(this.languageTool); @override diff --git a/lib/implementations/throttling_lang_tool_service.dart b/lib/implementations/throttling_lang_tool_service.dart index c4522b7..139358c 100644 --- a/lib/implementations/throttling_lang_tool_service.dart +++ b/lib/implementations/throttling_lang_tool_service.dart @@ -2,15 +2,16 @@ import 'package:languagetool_textfield/domain/language_check_service.dart'; import 'package:languagetool_textfield/domain/mistake.dart'; import 'package:throttling/throttling.dart'; -/// Implementation of language check service with throttling. +/// A language check service with debouncing. class ThrottlingLangToolService extends LanguageCheckService { - /// Base language check service. + /// A base language check service that is used to interact + /// with the language check API. final LanguageCheckService baseService; /// A throttling used to throttle the API calls. final Throttling throttling; - /// Implementation of LanguageCheckService with throttling. + /// Creates a new instance of the [ThrottlingLangToolService] class. ThrottlingLangToolService( this.baseService, Duration throttlingDuration, diff --git a/lib/presentation/language_tool_text_field.dart b/lib/presentation/language_tool_text_field.dart index 2e8fb08..0652baf 100644 --- a/lib/presentation/language_tool_text_field.dart +++ b/lib/presentation/language_tool_text_field.dart @@ -1,18 +1,18 @@ import 'package:flutter/material.dart'; import 'package:languagetool_textfield/domain/language_check_service.dart'; -/// Widget for checking grammar errors. +/// A TextField widget that checks the grammar using the given [langService] class LanguageToolTextField extends StatefulWidget { - /// Service for checking errors. + /// A service for checking errors. final LanguageCheckService langService; - /// The style to use for the text being edited. + /// A style to use for the text being edited. final TextStyle style; - /// Decoration of widget + /// A decoration of this [TextField]. final InputDecoration decoration; - /// Will build custom errors based on state. + /// A builder function used to build errors. final Widget Function()? mistakeBuilder; /// Creates a widget that checks grammar errors.