提交 a88b006c 编写于 作者: J Jason Malinowski

Merge remote-tracking branch 'dotnet/dev15-preview-5' into master

......@@ -224,7 +224,7 @@ private void AddToDecisionTree(DecisionTree decisionTree, BoundPatternSwitchLabe
case BoundKind.ConstantPattern:
{
var constantPattern = (BoundConstantPattern)pattern;
AddByValue(decisionTree, constantPattern.Value, (e, t) => new DecisionTree.Guarded(e, t, default(ImmutableArray<KeyValuePair<BoundExpression, LocalSymbol>>), _section, guard, label), label.HasErrors);
AddByValue(decisionTree, constantPattern.Value, (e, t) => new DecisionTree.Guarded(e, t, default(ImmutableArray<KeyValuePair<BoundExpression, LocalSymbol>>), _section, guard, label));
break;
}
case BoundKind.DeclarationPattern:
......@@ -475,7 +475,7 @@ private ErrorCode CheckSubsumed(BoundPattern pattern, DecisionTree decisionTree,
BoundExpression expression,
TypeSymbol type);
private DecisionTree AddByValue(DecisionTree decision, BoundExpression value, DecisionMaker makeDecision, bool hasErrors)
private DecisionTree AddByValue(DecisionTree decision, BoundExpression value, DecisionMaker makeDecision)
{
if (decision.MatchIsComplete)
{
......@@ -487,17 +487,17 @@ private DecisionTree AddByValue(DecisionTree decision, BoundExpression value, De
switch (decision.Kind)
{
case DecisionTree.DecisionKind.ByType:
return AddByValue((DecisionTree.ByType)decision, value, makeDecision, hasErrors);
return AddByValue((DecisionTree.ByType)decision, value, makeDecision);
case DecisionTree.DecisionKind.ByValue:
return AddByValue((DecisionTree.ByValue)decision, value, makeDecision, hasErrors);
return AddByValue((DecisionTree.ByValue)decision, value, makeDecision);
case DecisionTree.DecisionKind.Guarded:
return AddByValue((DecisionTree.Guarded)decision, value, makeDecision, hasErrors);
return AddByValue((DecisionTree.Guarded)decision, value, makeDecision);
default:
throw ExceptionUtilities.UnexpectedValue(decision.Kind);
}
}
private DecisionTree AddByValue(DecisionTree.Guarded guarded, BoundExpression value, DecisionMaker makeDecision, bool hasErrors)
private DecisionTree AddByValue(DecisionTree.Guarded guarded, BoundExpression value, DecisionMaker makeDecision)
{
if (guarded.Default != null)
{
......@@ -511,20 +511,20 @@ private DecisionTree AddByValue(DecisionTree.Guarded guarded, BoundExpression va
guarded.Default = new DecisionTree.ByValue(guarded.Expression, guarded.Type, null);
}
return AddByValue(guarded.Default, value, makeDecision, hasErrors);
return AddByValue(guarded.Default, value, makeDecision);
}
private DecisionTree AddByValue(DecisionTree.ByValue byValue, BoundExpression value, DecisionMaker makeDecision, bool hasErrors)
private DecisionTree AddByValue(DecisionTree.ByValue byValue, BoundExpression value, DecisionMaker makeDecision)
{
Debug.Assert(value.Type == byValue.Type);
if (byValue.Default != null)
{
return AddByValue(byValue.Default, value, makeDecision, hasErrors);
return AddByValue(byValue.Default, value, makeDecision);
}
// For error recovery, to avoid "unreachable code" diagnostics when there is a bad case
// label, we use the case label itself as the value key.
object valueKey = hasErrors ? (object)value : value.ConstantValue.Value;
object valueKey = value.ConstantValue?.Value ?? value;
DecisionTree valueDecision;
if (byValue.ValueAndDecision.TryGetValue(valueKey, out valueDecision))
{
......@@ -546,13 +546,13 @@ private DecisionTree AddByValue(DecisionTree.ByValue byValue, BoundExpression va
return valueDecision;
}
private DecisionTree AddByValue(DecisionTree.ByType byType, BoundExpression value, DecisionMaker makeDecision, bool hasErrors)
private DecisionTree AddByValue(DecisionTree.ByType byType, BoundExpression value, DecisionMaker makeDecision)
{
if (byType.Default != null)
{
try
{
return AddByValue(byType.Default, value, makeDecision, hasErrors);
return AddByValue(byType.Default, value, makeDecision);
}
finally
{
......@@ -619,7 +619,7 @@ private DecisionTree AddByValue(DecisionTree.ByType byType, BoundExpression valu
byType.TypeAndDecision.Add(new KeyValuePair<TypeSymbol, DecisionTree>(value.Type, forType));
}
return AddByValue(forType, value, makeDecision, hasErrors);
return AddByValue(forType, value, makeDecision);
}
private DecisionTree AddByType(DecisionTree decision, TypeSymbol type, DecisionMaker makeDecision)
......
......@@ -193,6 +193,26 @@ private bool TryDisplayReferences(Tuple<IEnumerable<ReferencedSymbol>, Solution>
public async Task FindReferencesAsync(
Document document, int position, FindReferencesContext context)
{
// NOTE: All ConFigureAwaits in this method need to pass 'true' so that
// we return to the caller's context. that's so the call to
// CallThirdPartyExtensionsAsync will happen on the UI thread. We need
// this to maintain the threading guarantee we had around that method
// from pre-Roslyn days.
var findReferencesProgress = await FindReferencesWorkerAsync(
document, position, context).ConfigureAwait(true);
if (findReferencesProgress == null)
{
return;
}
// After the FAR engine is done call into any third party extensions to see
// if they want to add results.
await findReferencesProgress.CallThirdPartyExtensionsAsync().ConfigureAwait(true);
}
private async Task<ProgressAdapter> FindReferencesWorkerAsync(
Document document, int position, FindReferencesContext context)
{
var cancellationToken = context.CancellationToken;
cancellationToken.ThrowIfCancellationRequested();
......@@ -202,7 +222,7 @@ private bool TryDisplayReferences(Tuple<IEnumerable<ReferencedSymbol>, Solution>
document, position, cancellationToken).ConfigureAwait(false);
if (symbolAndProject == null)
{
return;
return null;
}
var symbol = symbolAndProject.Item1;
......@@ -217,20 +237,14 @@ private bool TryDisplayReferences(Tuple<IEnumerable<ReferencedSymbol>, Solution>
// engine will push results into the 'progress' instance passed into it.
// We'll take those results, massage them, and forward them along to the
// FindReferencesContext instance we were given.
//
// Note: we pass along ConfigureAwait(true) because we need to come back
// to the UI thread. There's more work we need to do once the FAR engine
// is done.
await SymbolFinder.FindReferencesAsync(
SymbolAndProjectId.Create(symbol, project.Id),
project.Solution,
progressAdapter,
documents: null,
cancellationToken: cancellationToken).ConfigureAwait(true);
cancellationToken: cancellationToken).ConfigureAwait(false);
// After the FAR engine is done call into any third party extensions to see
// if they want to add results.
await progressAdapter.CallThirdPartyExtensionsAsync().ConfigureAwait(true);
return progressAdapter;
}
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册