@@ -86,6 +86,7 @@ private static Stream<Pair<MethodSymbol, ParameterDefinition>> getParametersByVa
86
86
87
87
private static Stream <VariableSymbol > getVariableByParameter (MethodSymbol method , ParameterDefinition parameterDefinition ) {
88
88
return method .getChildren ().stream ()
89
+ // в будущем могут появиться и другие символы, подчиненные методам
89
90
.filter (sourceDefinedSymbol -> sourceDefinedSymbol .getSymbolKind () == SymbolKind .Variable )
90
91
.filter (variable -> parameterDefinition .getRange ().getStart ().equals (variable .getSelectionRange ().getStart ()))
91
92
.filter (VariableSymbol .class ::isInstance )
@@ -132,13 +133,13 @@ private Optional<Reference> isOverwrited(List<Reference> references) {
132
133
return Optional .of (firstDefIntoAssign );
133
134
}
134
135
var refContextInsideDefAssign = getRefContextInsideDefAssign (firstDefIntoAssign , references .get (1 ));
135
- if (refContextInsideDefAssign .isEmpty ()){
136
+ if (refContextInsideDefAssign .isEmpty ()) {
136
137
return Optional .of (firstDefIntoAssign );
137
138
}
138
139
var isSelfAssign = Boolean .TRUE .equals (refContextInsideDefAssign
139
140
.map (RewriteMethodParameterDiagnostic ::isVarNameOnlyIntoExpression )
140
141
.orElseThrow ());
141
- if (isSelfAssign && references .size () > COUNT_OF_PAIR_FOR_SELF_ASSIGN ){
142
+ if (isSelfAssign && references .size () > COUNT_OF_PAIR_FOR_SELF_ASSIGN ) {
142
143
return isOverwrited (references .subList (COUNT_OF_PAIR_FOR_SELF_ASSIGN , references .size ()));
143
144
}
144
145
}
@@ -155,11 +156,9 @@ private Optional<RuleNode> getRefContextInsideDefAssign(Reference defRef, Refere
155
156
.map (RuleNode ::getParent )
156
157
.filter (BSLParser .AssignmentContext .class ::isInstance )
157
158
.map (BSLParser .AssignmentContext .class ::cast );
158
- if (assignment .isEmpty ()) {
159
- return Optional .empty ();
160
- }
161
159
162
- return Trees .findNodeContainsPosition (assignment .get (), nextRef .getSelectionRange ().getStart ())
160
+ return assignment .flatMap (assignContext ->
161
+ Trees .findNodeContainsPosition (assignContext , nextRef .getSelectionRange ().getStart ()))
163
162
.map (TerminalNode ::getParent );
164
163
}
165
164
@@ -169,7 +168,6 @@ private static boolean isVarNameOnlyIntoExpression(RuleNode refContext) {
169
168
.map (BSLParser .ComplexIdentifierContext .class ::cast )
170
169
.filter (node -> node .getChildCount () == 1 )
171
170
.map (RuleNode ::getParent )
172
- .filter (memberContext -> memberContext .getChildCount () == 1 )
173
171
.filter (BSLParser .MemberContext .class ::isInstance )
174
172
.map (RuleNode ::getParent )
175
173
.filter (expression -> expression .getChildCount () == 1 )
0 commit comments