/// <summary> /// Tries coercing qualifier. /// </summary> public bool TryCoerce( QualifierSpaceId targetQualifierSpaceId, QualifierTable qualifierTable, QualifierValueCache cache, PathTable pathTable, StringTable stringTable, LoggingContext loggingContext, out QualifierValue qualifierValue, LineInfo location, bool useDefaultsForCoercion, AbsolutePath path) { Contract.Requires(targetQualifierSpaceId.IsValid); Contract.Requires(qualifierTable != null); Contract.Requires(qualifierTable.IsValidQualifierSpaceId(targetQualifierSpaceId)); Contract.Requires(pathTable != null); Contract.Requires(stringTable != null); Contract.Requires(loggingContext != null); #if DEBUG Contract.Ensures(Contract.ValueAtReturn(out qualifierValue) == null || Contract.Result <bool>() == true, "expected 'qualifierValue' to be set to null when return value is 'false'"); Contract.Ensures(Contract.ValueAtReturn(out qualifierValue) != null || Contract.Result <bool>() == false, "expected 'qualifierValue' to be set to non-null when return value is 'true'"); #endif qualifierValue = null; if (targetQualifierSpaceId == qualifierTable.EmptyQualifierSpaceId) { qualifierValue = CreateEmpty(qualifierTable); return(true); } if (qualifierTable.TryCreateQualifierForQualifierSpace( pathTable, loggingContext, QualifierId, targetQualifierSpaceId, useDefaultsForCoercion, out QualifierId resultingQualifierId, out UnsupportedQualifierValue error)) { qualifierValue = Create(resultingQualifierId, cache, qualifierTable, stringTable); return(true); } var errorLocation = LocationData.Create(path, location.Line, location.Position); error.Location = errorLocation.ToLogLocation(pathTable); Logger.Log.ErrorUnsupportedQualifierValue( loggingContext, error.Location, error.QualifierKey, error.InvalidValue, error.LegalValues); return(false); }
/// <summary> /// Tries coercing qualifier. /// </summary> public bool TryCoerce( QualifierSpaceId targetQualifierSpaceId, QualifierTable qualifierTable, QualifierValueCache cache, PathTable pathTable, StringTable stringTable, LoggingContext loggingContext, out QualifierValue qualifierValue, LineInfo location, bool useDefaultsForCoercion, AbsolutePath path) { Contract.Requires(targetQualifierSpaceId.IsValid); Contract.Requires(qualifierTable != null); Contract.Requires(qualifierTable.IsValidQualifierSpaceId(targetQualifierSpaceId)); Contract.Requires(pathTable != null); Contract.Requires(stringTable != null); Contract.Requires(loggingContext != null); qualifierValue = null; if (targetQualifierSpaceId == qualifierTable.EmptyQualifierSpaceId) { qualifierValue = CreateEmpty(qualifierTable); return(true); } if (qualifierTable.TryCreateQualifierForQualifierSpace( pathTable, loggingContext, QualifierId, targetQualifierSpaceId, useDefaultsForCoercion, out QualifierId resultingQualifierId, out UnsupportedQualifierValue error)) { qualifierValue = Create(resultingQualifierId, cache, qualifierTable, stringTable); return(true); } var errorLocation = LocationData.Create(path, location.Line, location.Position); error.Location = errorLocation.ToLogLocation(pathTable); Logger.Log.ErrorUnsupportedQualifierValue( loggingContext, error.Location, error.QualifierKey, error.InvalidValue, error.LegalValues); return(false); }