mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-04-24 16:42:20 +02:00
parent
bd5dff37f0
commit
b4a9ab9fa5
@ -30,6 +30,7 @@ import org.eclipse.xtext.resource.IResourceServiceProvider;
|
|||||||
|
|
||||||
import com._1c.g5.v8.dt.bsl.common.IBslPreferences;
|
import com._1c.g5.v8.dt.bsl.common.IBslPreferences;
|
||||||
import com._1c.g5.v8.dt.bsl.model.BslPackage;
|
import com._1c.g5.v8.dt.bsl.model.BslPackage;
|
||||||
|
import com._1c.g5.v8.dt.bsl.model.EmptyExpression;
|
||||||
import com._1c.g5.v8.dt.bsl.model.Expression;
|
import com._1c.g5.v8.dt.bsl.model.Expression;
|
||||||
import com._1c.g5.v8.dt.bsl.model.FeatureAccess;
|
import com._1c.g5.v8.dt.bsl.model.FeatureAccess;
|
||||||
import com._1c.g5.v8.dt.bsl.model.FeatureEntry;
|
import com._1c.g5.v8.dt.bsl.model.FeatureEntry;
|
||||||
@ -160,7 +161,8 @@ public class InvocationParamIntersectionCheck
|
|||||||
|
|
||||||
Expression param = inv.getParams().get(i);
|
Expression param = inv.getParams().get(i);
|
||||||
List<TypeItem> sorceTypes = computeTypes(param, actualEnvs);
|
List<TypeItem> sorceTypes = computeTypes(param, actualEnvs);
|
||||||
boolean isUndefined = param == null || param instanceof UndefinedLiteral || isUndefinedType(sorceTypes);
|
boolean isUndefined = param == null || param instanceof UndefinedLiteral || param instanceof EmptyExpression
|
||||||
|
|| isUndefinedType(sorceTypes);
|
||||||
|
|
||||||
List<TypeItem> targetTypes = Collections.emptyList();
|
List<TypeItem> targetTypes = Collections.emptyList();
|
||||||
boolean isIntersect = false;
|
boolean isIntersect = false;
|
||||||
@ -174,7 +176,8 @@ public class InvocationParamIntersectionCheck
|
|||||||
iterator.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean isDefaultValue = targetParams.get(i).isDefaultValue();
|
Parameter parameter = targetParams.get(i);
|
||||||
|
boolean isDefaultValue = parameter.isDefaultValue();
|
||||||
|
|
||||||
if (isDefaultValue && isUndefined)
|
if (isDefaultValue && isUndefined)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
// @strict-types
|
||||||
|
|
||||||
|
Procedure NonComplaint() Export
|
||||||
|
|
||||||
|
Result = StrConcat(, );
|
||||||
|
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
// Parameters:
|
||||||
|
// Parameters - Structure:
|
||||||
|
// * Key1 - Number - has type for key
|
||||||
|
Procedure Complaint(Parameters) Export
|
||||||
|
|
||||||
|
Result = InformationRegisters["MyName"].SliceFirst(, Parameters);
|
||||||
|
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
// Parameters:
|
||||||
|
// Parameters - Structure:
|
||||||
|
// * Key1 - Number - has type for key
|
||||||
|
Procedure Complaint2(Parameters) Export
|
||||||
|
|
||||||
|
Result = InformationRegisters["MyName"].SliceFirst(Undefined, Parameters);
|
||||||
|
|
||||||
|
EndProcedure
|
@ -392,6 +392,30 @@ public class CommonModuleStrictTypesTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of {@link InvocationParamIntersectionCheck} that invokable method parameter type intersects
|
||||||
|
* with caller type, and skip checking if method has default value parameters.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testInvocationParamIntersectionCheckWithDefault() throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
String checkId = "invocation-parameter-type-intersect";
|
||||||
|
String resouceName = "invocation-parameter-type-intersect-with-default";
|
||||||
|
|
||||||
|
Module module = updateAndGetModule(resouceName);
|
||||||
|
|
||||||
|
List<Marker> markers = getMarters(checkId, module);
|
||||||
|
|
||||||
|
assertEquals(1, markers.size());
|
||||||
|
|
||||||
|
Marker marker = markers.get(0);
|
||||||
|
assertEquals("5", marker.getExtraInfo().get("line"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private List<Marker> getMarters(String checkId, Module module)
|
private List<Marker> getMarters(String checkId, Module module)
|
||||||
{
|
{
|
||||||
String id = module.eResource().getURI().toPlatformString(true);
|
String id = module.eResource().getURI().toPlatformString(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user