var sn = expr as SimpleName;
const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type;
- //
- // Resolve the expression with flow analysis turned off, we'll do the definite
- // assignment checks later. This is because we don't know yet what the expression
- // will resolve to - it may resolve to a FieldExpr and in this case we must do the
- // definite assignment check on the actual field and not on the whole struct.
- //
- using (rc.Set (ResolveContext.Options.OmitStructFlowAnalysis)) {
- if (sn != null) {
+ if (sn != null) {
+ var errors_printer = new SessionReportPrinter ();
+ var old = rc.Report.SetPrinter (errors_printer);
+ try {
expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);
+ } finally {
+ rc.Report.SetPrinter (old);
+ }
+
+ if (errors_printer.ErrorsCount != 0)
+ return null;
- //
- // Resolve expression which does have type set as we need expression type
- // with disable flow analysis as we don't know whether left side expression
- // is used as variable or type
- //
- if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess) {
- using (rc.With (ResolveContext.Options.DoFlowAnalysis, false)) {
- expr = expr.Resolve (rc);
- }
- } else if (expr is TypeParameterExpr) {
- expr.Error_UnexpectedKind (rc, flags, sn.Location);
- expr = null;
- }
- } else {
- expr = expr.Resolve (rc, flags);
+ //
+ // Resolve expression which does have type set as we need expression type
+ // with disable flow analysis as we don't know whether left side expression
+ // is used as variable or type
+ //
+ if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess) {
+ expr = expr.Resolve (rc);
+ } else if (expr is TypeParameterExpr) {
+ expr.Error_UnexpectedKind (rc, flags, sn.Location);
+ expr = null;
}
+ } else {
+ expr = expr.Resolve (rc, flags);
}
if (expr == null)
}
if (targs != null) {
- if (!targs.Resolve (rc))
+ if (!targs.Resolve (rc, true))
return null;
}
var results = new List<string> ();
- if (expr is Namespace) {
- Namespace nexpr = expr as Namespace;
+ var nexpr = expr as NamespaceExpression;
+ if (nexpr != null) {
string namespaced_partial;
if (partial_name == null)
- namespaced_partial = nexpr.Name;
+ namespaced_partial = nexpr.Namespace.Name;
else
- namespaced_partial = nexpr.Name + "." + partial_name;
+ namespaced_partial = nexpr.Namespace.Name + "." + partial_name;
rc.CurrentMemberDefinition.GetCompletionStartingWith (namespaced_partial, results);
if (partial_name != null)
// Nothing
}
}
+
+ public class EmptyCompletion : CompletingExpression
+ {
+ protected override void CloneTo (CloneContext clonectx, Expression target)
+ {
+ }
+
+ protected override Expression DoResolve (ResolveContext rc)
+ {
+ throw new CompletionResult ("", new string [0]);
+ }
+ }
}