Closed hurricup closed 5 days ago
The pull request introduces significant modifications across various classes in the LanguageTool project, primarily focusing on the transition from direct instantiation of language classes to a singleton pattern using getInstance()
methods. This change affects classes related to both German and French language processing, ensuring consistent management of language instances. Additionally, several import statements have been reorganized for clarity, and some methods have been simplified to enhance readability and maintainability. Overall, the changes aim to improve the efficiency and consistency of language instance usage throughout the codebase.
File Path | Change Summary |
---|---|
languagetool-core/src/main/java/org/languagetool/Languages.java |
Updated import statements and modified initialization of staticAndDynamicLanguages . Retained existing methods. |
languagetool-dev/src/main/java/org/languagetool/dev/GenderWordFinder.java |
Changed instantiation of GermanyGerman to use getInstance() . Logic remains unchanged. |
languagetool-dev/src/main/java/org/languagetool/dev/GermanOldSpellingFinder.java |
Updated instantiation of GermanyGerman to use getInstance() . Logic remains unchanged. |
languagetool-dev/src/main/java/org/languagetool/dev/MissingGermanCompoundAdjectiveFinder.java |
Changed instantiation of GermanyGerman to use getInstance() . Logic remains unchanged. |
languagetool-dev/src/main/java/org/languagetool/dev/MissingGermanCompoundsFinder.java |
Updated instantiation of GermanSpellerRule to use getInstance() . Logic remains unchanged. |
languagetool-dev/src/main/java/org/languagetool/dev/MissingGermanWords.java |
Changed instantiation of GermanSpellerRule to use getInstance() . Logic remains unchanged. |
languagetool-dev/src/main/java/org/languagetool/dev/archive/GermanTaggerEnhancer.java |
Updated instantiation of Tagger to use getInstance() . Reorganized import statements. |
languagetool-dev/src/main/java/org/languagetool/dev/archive/SimpleRuleCounter.java |
Removed unused import and changed instantiation of GermanyGerman to use getInstance() . |
languagetool-dev/src/main/java/org/languagetool/dev/bigdata/GermanReflexiveVerbGuesser.java |
Updated initialization of synthesizer to use getInstance() . Logic remains unchanged. |
languagetool-dev/src/test/java/org/languagetool/dev/bigdata/CommonCrawlToNgramTest.java |
Changed instantiation of CommonCrawlToNgram to use getInstance() . Reordered import statements. |
languagetool-language-modules/de-DE-x-simple-language/src/main/java/org/languagetool/language/SimpleGerman.java |
Updated instantiation of GermanRuleDisambiguator to use getInstance() . Reorganized imports. |
languagetool-language-modules/de/src/main/java/org/languagetool/language/German.java |
Added new imports, updated getDefaultLanguageVariant() to use getInstance() , and introduced a new constant. |
languagetool-language-modules/de/src/main/java/org/languagetool/language/GermanyGerman.java |
Added GERMANY_GERMAN_SHORT_CODE , deprecated constructor, and introduced getInstance() . |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/GermanCompoundRule.java |
Updated access to GermanyGerman instance to use getInstance() . |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/GermanNumberInWordFilter.java |
Changed instance access to getInstance() . Logic remains unchanged. |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/GermanRepeatedWordsRule.java |
Updated constructor to use getInstance() . Simplified isException method. |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/MissingCommaRelativeClauseRule.java |
Updated access to GermanyGerman instance to use getInstance() . |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/PotentialCompoundFilter.java |
Changed instance access to getInstance() . Logic remains unchanged. |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/ProhibitedCompoundRule.java |
Updated instance access to getInstance() . Logic remains unchanged. |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/RemoveUnknownCompoundsFilter.java |
Changed access to GermanyGerman instance to use getInstance() . Logic remains unchanged. |
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/ValidWordFilter.java |
Updated access to GermanSpellerRule instance to use getInstance() . Logic remains unchanged. |
languagetool-language-modules/de/src/test/java/org/languagetool/GermanyGermanConcurrencyTest.java |
Updated createLanguage method to use getInstance() . |
languagetool-language-modules/de/src/test/java/org/languagetool/JLanguageToolTest.java |
Changed instantiation of GermanyGerman to use getInstance() in multiple test methods. |
languagetool-language-modules/de/src/test/java/org/languagetool/rules/de/AgreementRule2Test.java |
Updated instantiation of JLanguageTool and AgreementRule2 to use getInstance() . |
languagetool-language-modules/fr/src/main/java/org/languagetool/language/BelgianFrench.java |
Added instantiationTrace and updated constructor to check for existing instances. |
languagetool-language-modules/fr/src/main/java/org/languagetool/language/CanadianFrench.java |
Added instantiationTrace and updated constructor for existing instance check. |
languagetool-language-modules/fr/src/main/java/org/languagetool/language/French.java |
Added FRENCH_SHORT_CODE , updated constructors, and modified methods to use Collections.singletonList() . |
languagetool-language-modules/fr/src/main/java/org/languagetool/language/SwissFrench.java |
Added instantiationTrace and updated constructor for existing instance check. |
languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/FindSuggestionsFilter.java |
Updated instantiation of MorfologikFrenchSpellerRule to use French.getInstance() . |
languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/FrenchNumberInWordFilter.java |
Updated instantiation of French to use getInstance() . |
languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/FrenchPartialPosTagFilter.java |
Changed instantiation of disambiguator to use getInstance() . |
languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/FrenchRepeatedWordsRule.java |
Updated constructor to use getInstance() and simplified isException method. |
languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/InterrogativeVerbFilter.java |
Updated morfologikRule to be final and changed instantiation to getInstance() . |
languagetool-language-modules/fr/src/main/java/org/languagetool/tagging/disambiguation/fr/FrenchHybridDisambiguator.java |
Updated instantiation of disambiguator to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/FrenchConcurrencyTest.java |
Updated createLanguage method to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/JLanguageToolTest.java |
Changed instantiation of French to use getInstance() in multiple test methods. |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/fr/FrenchTest.java |
Updated instantiation of French to use getInstance() in multiple test methods. |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/fr/GenericUnpairedBracketsRuleTest.java |
Updated instantiation of JLanguageTool to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/fr/MorfologikFrenchSpellerRuleTest.java |
Updated JLanguageTool and MorfologikFrenchSpellerRule instantiation to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/fr/QuestionWhitespaceRuleTest.java |
Updated instantiation of French to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/fr/QuestionWhitespaceStrictRuleTest.java |
Updated instantiation of French to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/fr/SimpleReplaceRuleTest.java |
Updated JLanguageTool instantiation to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/rules/spelling/hunspell/TestFrenchDisambiguator.java |
Updated instantiation of French to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/tagging/disambiguation/rules/fr/FrenchRuleDisambiguatorTest.java |
Updated instantiation of French to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/tagging/fr/FrenchTaggerTest.java |
Updated instantiation of French to use getInstance() . |
languagetool-language-modules/fr/src/test/java/org/languagetool/tokenizers/fr/FrenchSentenceTokenizerTest.java |
Updated instantiation of SRXSentenceTokenizer to use getInstance() . |
languagetool-server/src/test/java/org/languagetool/server/HTTPSServerTest.java |
Updated instantiation of GermanyGerman to use getInstance() . Modified assertions in runTests . |
languagetool-server/src/test/java/org/languagetool/server/HTTPServerTest.java |
Changed instantiation of GermanyGerman to use getInstance() . Modified assertions in various methods. |
languagetool-standalone/src/test/java/org/languagetool/JLanguageToolTest.java |
Updated instantiation of GermanyGerman and French to use getInstance() . |
languagetool-standalone/src/test/java/org/languagetool/LanguageTest.java |
Updated equality checks to use getInstance() for GermanyGerman . |
languagetool-standalone/src/test/java/org/languagetool/dev/MultiThreadingTest2.java |
Updated LANG initialization to use getInstance() . |
languagetool-standalone/src/test/java/org/languagetool/gui/ConfigurationTest.java |
Updated instantiation of French to use getInstance() . |
languagetool-standalone/src/test/java/org/languagetool/rules/patterns/StartupTimePerformanceTest.java |
Updated instantiation of GermanyGerman to use getInstance() . |
languagetool-wikipedia/src/test/java/org/languagetool/dev/index/IndexerSearcherTest.java |
Updated instantiation of French and GermanyGerman to use getInstance() . |
languagetool-wikipedia/src/test/java/org/languagetool/dev/wikipedia/SuggestionReplacerTest.java |
Updated instantiation of GermanyGerman to use getInstance() . Added suppression annotation for deprecated usage. |
languagetool-wikipedia/src/test/java/org/languagetool/dev/wikipedia/WikipediaQuickCheckTest.java |
Updated instantiation of GermanyGerman to use getInstance() . |
French
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
We did get a report that when the French language is active, a lot of memory consumed. I did investigate and there are a lot of things that could be optimized. I made some improvements and will split them into several PRs to make it easier to review.
In this PR:
getInstance
should be used to obtain it). API prevents you from the instantiating yourself.getInstance
should be used to obtain it). API prevents you from the instantiating yourself.Languages
instantiated all languages twice for no reason on class loading.My intent is to do the same for all languages in LT. This improves the loading timing and reduce the memory footprint. Currently, LT has a lot of unnecessary duplicated objects while working.
Here is the synthetic test I am using for the snapshots:
Total results of all changes I made with (English, German, French): Before:
After:
Summary by CodeRabbit
New Features
GermanyGerman
andFrench
language instances across various components, improving resource management and consistency.Bug Fixes
Documentation
Chores