-
Notifications
You must be signed in to change notification settings - Fork 117
Feature/os class module type #3113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Qodana Community for JVM14 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
88e8e3b to
7992f30
Compare
|
Important Auto Review SkippedDraft detected. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe changes primarily involve code cleanliness and refactoring for readability and maintainability. Whitespace has been trimmed, annotations added to suppress deprecation warnings, and spacing issues have been addressed. New functionality includes the addition of a Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Qodana Community for JVM17 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java
Outdated
Show resolved
Hide resolved
...n/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java
Show resolved
Hide resolved
...ain/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java
Show resolved
Hide resolved
src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java
Outdated
Show resolved
Hide resolved
.../java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java
Show resolved
Hide resolved
|
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (52)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BasicBlockVertex.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphWalker.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplier.java (6 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplier.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/ParametersDeserializer.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java (6 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleTypeComputer.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java (7 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java (3 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbol.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnostic.java (4 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeOutOfRegionDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnostic.java (3 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnostic.java (3 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnostic.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCompatibilityMode.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java (4 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/references/OscriptReferenceFinder.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java (5 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Modules.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java (2 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslExpression.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ConstructorCallNode.java (2 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionParseTreeRewriter.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionTreeBuildingVisitor.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java (1 hunks)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/UnaryOperationNode.java (1 hunks)
- src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java (1 hunks)
- src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolTest.java (1 hunks)
- src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnosticTest.java (1 hunks)
- src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilderTest.java (1 hunks)
- src/test/java/com/github/_1c_syntax/bsl/languageserver/references/OscriptReferenceFinderTest.java (1 hunks)
- src/test/resources/context/symbol/variableSymbolTest.os (1 hunks)
- src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl (1 hunks)
- src/test/resources/metadata/oscript/main.os (1 hunks)
- src/test/resources/metadata/oscript/Классы/ТестовыйКласс.os (1 hunks)
- src/test/resources/metadata/oscript/Модули/ТестовыйМодуль.os (1 hunks)
Files skipped from review due to trivial changes (24)
- src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLWorkspaceService.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/BasicBlockVertex.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraphWalker.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/DisableDiagnosticTriggeringSupplier.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/codeactions/QuickFixSupplier.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AllFunctionPathMustHaveReturnDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CodeAfterAsyncCallDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicatedInsertionIntoCollectionDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IdenticalExpressionsDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectUseOfStrTemplateDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MissingTemporaryFileDeletionDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UnusedLocalVariableDiagnostic.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilder.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Modules.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Ranges.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Trees.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/BslExpression.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ConstructorCallNode.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionParseTreeRewriter.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/ExpressionTreeBuildingVisitor.java
- src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/UnaryOperationNode.java
- src/test/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContextTest.java
- src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ForbiddenMetadataNameDiagnosticTest.java
Additional comments: 50
src/test/resources/context/symbol/variableSymbolTest.os (1)
- 1-3: The procedure
В()correctly instantiates a new object ofМойКласс. Ensure thatМойКлассis defined and accessible within the scope.src/test/resources/metadata/oscript/main.os (1)
- 1-4: The instantiation of
ТестовыйКлассand the subsequent operation are syntactically correct. Ensure thatТестовыйМодуль.ЭкспортныйМетод()is defined and returns a compatible type for addition withТестовыйКласс.src/test/resources/metadata/oscript/Классы/ТестовыйКласс.os (2)
2-5: The procedure
ПростоПроцедура()is declared correctly but is empty. If this is intentional (e.g., for a test stub), it's fine; otherwise, implementation is needed.7-10: The procedure
ПриСозданииОбъекта()is also declared correctly but is empty. As withПростоПроцедура(), ensure this is intentional.src/test/resources/metadata/oscript/Модули/ТестовыйМодуль.os (2)
2-4: The procedure
ПростоМетод()is declared correctly. Ensure that it is intended to be private since it lacks theЭкспортkeyword.6-8: The procedure
ЭкспортныйМетод()is correctly declared as exported and callsПростоМетод(). Ensure thatПростоМетод()is intended to be called here and that it exists.src/test/resources/hover/variableSymbolMarkupContentBuilder.bsl (1)
- 35-35: The instantiation of
ИмяКлассаis correct. Ensure thatИмяКлассаis defined and that this instantiation is used as intended.src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/expressiontree/TernaryOperatorNode.java (1)
- 40-40: The constructor access level change to
privateprevents subclassing. Ensure thatTernaryOperatorNodeis not intended to be subclassed and that instances are only created through the staticcreatemethod.src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/VariableSymbol.java (1)
- 54-54: The addition of the
getType()method to theVariableSymbolinterface requires all implementing classes to provide an implementation for this method. Verify that all implementations have been updated accordingly.src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/Location.java (1)
- 72-72: The assignment of
endCharacteris now unconditional, which could be a logical change. Verify that this change is intentional and thatendCharactershould always be set to the value fromrange.getEnd().getCharacter()regardless of any conditions.src/main/java/com/github/_1c_syntax/bsl/languageserver/references/model/SymbolOccurrence.java (1)
- 58-69: The changes in the
compareTomethod alter the comparison logic. Ensure that the new comparison order (URI, range, occurrence type, and symbol) is intended and that it aligns with the desired sorting behavior.src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticCompatibilityMode.java (1)
- 51-51: The addition of
COMPATIBILITY_MODE_8_3_21to theDiagnosticCompatibilityModeenum is correct. Ensure that this new version is supported and handled correctly in all relevant parts of the application.src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleTypeComputer.java (1)
- 30-75: The
ModuleTypeComputerclass and its methodscomputeModuleTypeandcomputeTypeNameare correctly implemented. Ensure that the logic withincomputeBSLandcomputeOSmethods correctly determines the module types based on the document context and that thecomputeTypeNamemethod correctly extracts the type name from the URI.src/test/java/com/github/_1c_syntax/bsl/languageserver/references/OscriptReferenceFinderTest.java (2)
43-55: The test
testFindReferenceToClassis implemented correctly. Ensure that the test setup is correct and that the reference is indeed present at the specified position.57-73: The test
testFindReferenceToModuleis implemented correctly. It checks for the presence of a reference and the absence of a variable at specified positions. Ensure that the test setup is correct and that the assertions reflect the expected behavior.src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/IntBasedVariableSymbol.java (1)
- 78-81: The addition of the
typeparameter to theIntBasedVariableSymbolconstructor is correct. Ensure that all instantiations ofIntBasedVariableSymbolhave been updated to pass the newtypeparameter and that thetypeis correctly handled in the superclass.src/main/java/com/github/_1c_syntax/bsl/languageserver/configuration/databind/ParametersDeserializer.java (1)
- 81-82: The instantiation of
TypeReferenceusing an empty anonymous class is a common Java idiom to work around type erasure by subclassing. This change seems correct, but ensure that theTypeReferenceis used as intended and that the deserialization logic is not affected.src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/ShortBasedVariableSymbol.java (1)
- 78-81: The addition of the
typeparameter to theShortBasedVariableSymbolconstructor is consistent with the changes in theAbstractVariableSymbolclass. Ensure that all instantiations ofShortBasedVariableSymbolare updated to include the newtypeargument.src/main/java/com/github/_1c_syntax/bsl/languageserver/references/OscriptReferenceFinder.java (1)
- 1-93: No specific changes are highlighted within the hunk for
OscriptReferenceFinder. Assuming the class is provided for context, no action is required.src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/UsingCancelParameterDiagnostic.java (1)
- 72-72: The change in the
visitSubmethod adjusts the text extraction for thelValuein thecancelPattern.matchercall. Ensure that the new logic correctly matches the intended pattern and that the diagnostic's behavior remains consistent with its purpose.src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MagicDateDiagnostic.java (1)
- 112-112: The modification in the
checkExclAddDiagnosticmethod changes the conditional check forctx instanceof BSLParser.CallParamListContext. Ensure that this change correctly reflects the intended logic and that the diagnostic's behavior is as expected.src/main/java/com/github/_1c_syntax/bsl/languageserver/cli/FormatCommand.java (1)
- 137-137: The change in the
findFilesForFormattingmethod adds spaces around the condition check for directory existence. This is a code style improvement and should not affect the logic or control flow.src/main/java/com/github/_1c_syntax/bsl/languageserver/context/symbol/AbstractVariableSymbol.java (3)
101-101: The addition of the
typefield in theAbstractVariableSymbolclass is a significant change. Ensure that all subclasses and usages ofAbstractVariableSymbolare updated to handle the newtypefield appropriately.197-198: The
typeparameter is now passed to the constructor ofShortBasedVariableSymbolin thebuildmethod. Verify that this change is reflected everywhereShortBasedVariableSymbolis instantiated.217-217: The
typeparameter is also passed to the constructor ofIntBasedVariableSymbolin thebuildmethod. Verify that this change is reflected everywhereIntBasedVariableSymbolis instantiated.src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/IncorrectLineBreakDiagnostic.java (1)
- 107-107: Please ensure that the addition of a space before the opening brace in the
ifcondition aligns with the project's coding standards.src/test/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolTest.java (1)
- 147-154: Ensure that the new test method
testVariableNewOSis correctly asserting the expected behavior and that the file path and variable type are correct.src/test/java/com/github/_1c_syntax/bsl/languageserver/hover/VariableSymbolMarkupContentBuilderTest.java (1)
- 132-148: Ensure that the new test method
testMethodVarContentFromDirectFile_type_from_newis correctly asserting the expected behavior and that the content generation for the variable symbol is accurate.src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SelectionRangeProvider.java (3)
28-38: The addition of imports for
Token,TerminalNode,Tree,Position, andPositionssuggests new functionality related to parsing and position handling. Ensure these imports are used within the file and are not extraneous to avoid unnecessary dependencies.83-83: The formatting change in the
getSelectionRangemethod's parameters is cosmetic and should follow the project's style guide. If the project has a defined style for method parameters, ensure this change is consistent with it.218-266: New methods related to position handling within parse trees and tokens have been added. Verify that these methods are correctly implemented and performant, especially in the context of large parse trees where performance could be a concern.
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/VariableSymbolComputer.java (5)
65-68: The constructor now accepts a
List<MethodSymbol>instead of a different type. Ensure that all instantiations ofVariableSymbolComputerthroughout the codebase have been updated to pass the correct type.159-171: The method
visitLValuehas been renamed tovisitAssignment, and its logic has been adjusted. Ensure that this renaming and logic change is consistent with the intended functionality and that all references to the old method name have been updated.210-220: The
getVariableScopemethod has been modified to handle different contexts. Verify that the new logic correctly resolves variable scopes in all scenarios where this method is used.252-262: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [255-271]
The
updateVariablesCachemethod has been extended to include type information. Ensure that the handling of type information is correct and that the performance is acceptable, especially when dealing with a large number of variables.
- 282-291: A new method
typeNamehas been introduced to extract type information from assignment contexts. Verify that this method correctly extracts the type information and is used appropriately within the class.src/main/java/com/github/_1c_syntax/bsl/languageserver/references/ReferenceIndex.java (4)
73-73: The use of the
varkeyword for local variable declarations is a Java best practice for enhancing code readability and maintainability, provided the type is clear from the context. Ensure that the use ofvardoes not reduce code clarity in these instances.167-174: The
addMethodCallmethod now uses thevarkeyword for local variables. Confirm that the types of these variables are clear from the context to maintain code readability.197-209: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [200-216]
The
addVariableUsagemethod has been updated to use thevarkeyword. Ensure that the types of the variables are clear from the context and that the use ofvardoes not obscure the code's intent.
- 257-257: The
getSourceDefinedSymbolmethod now uses thevarkeyword for local variables. Confirm that the types of these variables are clear from the context to maintain code readability.src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java (10)
31-31: The import of
ModuleTypeComputeris added to support the new functionality for computing module types.121-121: The addition of
typeNameas aLazyobject is intended to cache the computed type name. Ensure that thecomputeTypeNamemethod is implemented correctly and that the cached value is used appropriately throughout the codebase.Verification successful
The
computeTypeNamemethod is implemented in theDocumentContext.javafile and it uses theModuleTypeComputerto compute the type name. Additionally, thetypeName.getOrCompute()method is used within the same file, indicating that the cached value is being accessed appropriately.* 373-373: Refactoring of `computeModuleType` to use `ModuleTypeComputer` is noted. Ensure that the `ModuleTypeComputer` class is correctly implemented and that the refactoring maintains the intended functionality.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the implementation of computeTypeName method. ast-grep --lang java --pattern $'private String computeTypeName() { $$$ }' # Verify the usage of typeName in the codebase. rg --type java 'typeName.getOrCompute()'Length of output: 699
Verification successful
The
ModuleTypeComputerclass is implemented with methods to compute the module type based on the file type and the document's URI. ThecomputeModuleTypemethod delegates tocomputeBSLorcomputeOSdepending on the file type, andcomputeTypeNamecomputes the type name for OScript modules and classes. The refactoring appears to maintain the intended functionality.* 378-378: Refactoring of `computeTypeName` to use `ModuleTypeComputer` is noted. Similar to `computeModuleType`, ensure that the `computeTypeName` method is correctly implemented and that the refactoring maintains the intended functionality.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the implementation of ModuleTypeComputer class. ast-grep --lang java --pattern $'class ModuleTypeComputer { $$$ }' # Verify the usage of computeModuleType in the codebase. rg --type java 'computeModuleType()'Length of output: 696
Script:
#!/bin/bash # Inspect the contents of ModuleTypeComputer.java to verify the implementation. cat src/main/java/com/github/_1c_syntax/bsl/languageserver/context/computer/ModuleTypeComputer.javaLength of output: 2610
Verification successful
To verify the correct implementation of the
computeTypeNamemethod and its usage withinDocumentContext.java, as well as to ensure thatModuleTypeComputeris properly implemented, I will generate additional shell scripts to:
- Check the full implementation of the
computeTypeNamemethod inDocumentContext.java.- Inspect the
ModuleTypeComputerclass and itscomputeTypeNamemethod to ensure it is correctly implemented.
To further investigate the implementation of the
computeTypeNamemethod within theModuleTypeComputerclass, I will adjust theast-greppattern to be less specific and also usecatto directly inspect theModuleTypeComputerclass file.
The
ModuleTypeComputerclass has been successfully located, and its contents have been provided. ThecomputeTypeNamemethod within this class is implemented to return the file name without the.osextension if the module type isOScriptModuleorOScriptClass. Otherwise, it returns an empty string. This implementation seems to be consistent with the intended functionality of computing a type name based on the document context and module type.The
computeModuleTypemethod is also present, and it contains logic to determine the module type based on the file type and path, which supports the functionality of thecomputeTypeNamemethod by providing the necessary module type information.Based on the provided context and the new information from the scripts, the refactoring of the
computeTypeNamemethod to useModuleTypeComputerappears to be correctly implemented and maintains the intended functionality.* 162-162: The refactoring of `getTokensFromDefaultChannel` to use Java streams and the `toList` method is noted. Ensure that the stream operation correctly filters tokens from the default channel.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the implementation of computeTypeName method. ast-grep --lang java --pattern $'private String computeTypeName() { $$$ }' # Verify the usage of typeName in the codebase. rg --type java 'typeName.getOrCompute()'Length of output: 699
Script:
#!/bin/bash # Check the full implementation of computeTypeName method in DocumentContext.java cat src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.java | grep -A 10 "private String computeTypeName()" # Inspect the ModuleTypeComputer class and its computeTypeName method ast-grep --lang java --pattern $'class ModuleTypeComputer { $$$ computeTypeName() { $$$ } $$$ }'Length of output: 617
Script:
#!/bin/bash # Inspect the ModuleTypeComputer class and its computeTypeName method with a less specific pattern ast-grep --lang java --pattern $'class ModuleTypeComputer { $$$ }' # Directly inspect the ModuleTypeComputer class file fd "ModuleTypeComputer.java" --exec cat {}Length of output: 2621
Verification successful
The verification of the
getTokensFromDefaultChannelmethod shows that it is used in various places within the codebase, including diagnostics and context computation. The refactored method appears to be functioning correctly, as it is being utilized without any issues reported in the output.Given that the method is used in several diagnostics and context computations, it is important that the refactoring to use Java streams and the
toListmethod does not introduce any behavioral changes unless intended. The usage oftoListis a standard practice in Java for collecting stream results into a list, and the filtering by the default channel is a common operation when dealing with token streams.Since the output does not indicate any errors or issues with the usage of the refactored method, and the refactoring itself follows Java best practices, it seems that the changes are correctly implemented.
* 168-168: The refactoring of `getComments` to use Java streams and the `toList` method is noted. Ensure that the stream operation correctly filters comment tokens.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the usage of getTokensFromDefaultChannel in the codebase. rg --type java 'getTokensFromDefaultChannel()'Length of output: 985
Verification successful
The implementation of the
getComments()method inDocumentContext.javahas been successfully retrieved. The method filters tokens from the token stream, selecting only those of typeBSLLexer.LINE_COMMENT, and collects them into a list.Here is the relevant part of the implementation:
public List<Token> getComments() { return getTokens().stream() .filter(token -> token.getType() == BSLLexer.LINE_COMMENT) .toList(); }This confirms that the
getComments()method is indeed using a stream operation to filter out comment tokens, specifically those that are line comments. The use offilterwith the conditiontoken.getType() == BSLLexer.LINE_COMMENTensures that only line comment tokens are included in the resulting list.Based on this information, the refactoring of
getCommentsto use Java streams and thetoListmethod is correctly implemented to filter comment tokens as intended.* 373-373: Refactoring of `computeModuleType` to use `ModuleTypeComputer` is noted. Ensure that the `ModuleTypeComputer` class is correctly implemented and that the refactoring maintains the intended functionality.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the usage of getComments in the codebase. rg --type java 'getComments()'Length of output: 3139
Script:
#!/bin/bash # Retrieve the implementation of getComments() from DocumentContext.java ast-grep --lang java --pattern $'class DocumentContext { $$$ public List<Token> getComments() { $$$ } $$$ }'Length of output: 121
Script:
#!/bin/bash # Extract the implementation of getComments() from DocumentContext.java using ripgrep rg --type java --context 10 'public List<Token> getComments\(\)' src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.javaLength of output: 731
Verification successful
To verify the correct implementation of the
ModuleTypeComputerclass and thecomputeModuleTypemethod, we need to view the contents of theModuleTypeComputer.javafile. Let's generate a script to do that.
The
ModuleTypeComputerclass has been successfully located and its contents displayed. The class contains a constructor that accepts aDocumentContextobject and two methods:computeModuleTypeandcomputeTypeName. ThecomputeModuleTypemethod checks the file type and calls eithercomputeBSLorcomputeOSto determine the module type, defaulting toModuleType.UNKNOWNif the file type is neither BSL nor OS. ThecomputeBSLandcomputeOSmethods contain logic specific to each file type to compute the module type. ThecomputeTypeNamemethod computes the type name for OScript modules and classes by extracting the file name from the document's URI and removing the.osextension.Based on the provided output, the refactoring to use the
ModuleTypeComputerclass appears to be correctly implemented, with thecomputeModuleTypemethod inDocumentContext.javanow creating an instance ofModuleTypeComputerand calling itscomputeModuleTypemethod.* 378-378: Refactoring of `computeTypeName` to use `ModuleTypeComputer` is noted. Similar to `computeModuleType`, ensure that the `computeTypeName` method is correctly implemented and that the refactoring maintains the intended functionality.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the implementation of ModuleTypeComputer class. ast-grep --lang java --pattern $'class ModuleTypeComputer { $$$ }' # Verify the usage of computeModuleType in the codebase. rg --type java 'computeModuleType()'Length of output: 696
Script:
#!/bin/bash # Find the ModuleTypeComputer.java file and display its contents fd 'ModuleTypeComputer.java' --exec cat {}Length of output: 2553
Verification successful
The refactoring of the
computeTypeNamemethod to useModuleTypeComputerhas been verified, and it is correctly implemented in theDocumentContext.javafile. Additionally, the usage oftypeName.getOrCompute()within the same file suggests that thetypeNameis being computed and cached as expected.* 162-162: The refactoring of `getTokensFromDefaultChannel` to use Java streams and the `toList` method is noted. Ensure that the stream operation correctly filters tokens from the default channel.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the implementation of computeTypeName method. ast-grep --lang java --pattern $'private String computeTypeName() { $$$ }' # Verify the usage of typeName in the codebase. rg --type java 'typeName.getOrCompute()'Length of output: 699
Verification successful
The refactoring of
getTokensFromDefaultChannelto use Java streams and thetoListmethod has been verified in the codebase. It is used in several diagnostic classes and within theDocumentContextclass. The stream operation correctly filters tokens from the default channel, and the usage of the method in the codebase suggests that the refactoring should not alter its intended behavior.* 168-168: The refactoring of `getComments` to use Java streams and the `toList` method is noted. Ensure that the stream operation correctly filters comment tokens.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the usage of getTokensFromDefaultChannel in the codebase. rg --type java 'getTokensFromDefaultChannel()'Length of output: 985
Verification successful
The provided script output shows the implementation of the
getComments()method withinDocumentContext.java. The method filters tokens from the token list, keeping only those where the token type isBSLLexer.LINE_COMMENT. The stream operation concludes with atoList()call, which collects the filtered tokens into a list.The filtering condition checks if the token type is
BSLLexer.LINE_COMMENT, which suggests that it is correctly identifying line comment tokens. There is no indication from the output that the stream operation is incorrect or that the filter condition is improperly set.Based on the output, the refactoring of
getCommentsto use Java streams and thetoListmethod appears to be implemented correctly, as it filters the tokens to include only comments.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the usage of getComments in the codebase. rg --type java 'getComments()'Length of output: 3139
Script:
#!/bin/bash # Examine the implementation of getComments() in DocumentContext.java rg --type java --context 10 'public List<Token> getComments\(\)' src/main/java/com/github/_1c_syntax/bsl/languageserver/context/DocumentContext.javaLength of output: 731
| public ParseTree visitFile(BSLParser.FileContext ctx) { | ||
|
|
||
| // Для неизвестных модулей не будем требовать нахождения кода в области | ||
| // fix me bsl only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment // fix me bsl only suggests that there may be outstanding work to be done here. Please address or remove this comment if it's no longer relevant.
| if (documentContext.getUri().getPath().contains("Модули")) { | ||
| return ModuleType.OScriptModule; | ||
| } else if (documentContext.getUri().getPath().contains("Классы")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Думаю, стоит завести список имен, которые будут идентифицироваться как классы\модули. Например англоязычные названия, каталог с командами для приложения или иное. Можно попробовать отдельно читать конфиг библиотеки, при его наличии
|
Qodana Community for JVM15 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
|




Описание
Связанные задачи
Closes
Чеклист
Общие
gradlew precommit)Для диагностик
Дополнительно
Summary by CodeRabbit
New Features
8.3.21to compatibility mode options.Enhancements
varkeyword andtoList()method.Bug Fixes
Documentation
Tests