public void TestLambdaInMethodCall2() { var tree = Utils.ParseLines("class C", "{", " void Main()", " {", " someMethod(42, \"test\", false, x => {", " return x;", " });", " }", "}"); var lambdaExpression = tree.Root.FindFirstNodeOfType <SimpleLambdaExpressionSyntax>(); var actualRegion = GetRegion(tree, lambdaExpression); var expectedRegion = new OutliningRegion( Span.FromBounds(71, 98), CSharpOutliningHelpers.Ellipsis, autoCollapse: false); AssertRegion(expectedRegion, actualRegion); }
public void TestLambda() { var tree = Utils.ParseLines("class C", "{", " void Main()", " {", " f => {", " x();", " };", " }", "}"); var lambdaExpression = tree.Root.FindFirstNodeOfType <SimpleLambdaExpressionSyntax>(); var actualRegion = GetRegion(tree, lambdaExpression); var expectedRegion = new OutliningRegion( Span.FromBounds(41, 62), CSharpOutliningHelpers.Ellipsis, autoCollapse: false); AssertRegion(expectedRegion, actualRegion); }
bool ComputeOutliningRegions(Dafny.Program program, ITextSnapshot snapshot) { Contract.Requires(snapshot != null); if (program == _program) { return(false); // no new regions } List <OutliningRegion> newRegions = new List <OutliningRegion>(); foreach (var module in program.Modules) { if (!module.IsDefaultModule) { var nm = "module"; if (module.IsAbstract) { nm = "abstract " + nm; } OutliningRegion.Add(newRegions, program, module, nm); } foreach (Dafny.TopLevelDecl d in module.TopLevelDecls) { if (!HasBodyTokens(d) && !(d is Dafny.ClassDecl)) { continue; } if (d is Dafny.OpaqueTypeDecl) { OutliningRegion.Add(newRegions, program, d, "type"); } else if (d is Dafny.CoDatatypeDecl) { OutliningRegion.Add(newRegions, program, d, "codatatype"); } else if (d is Dafny.DatatypeDecl) { OutliningRegion.Add(newRegions, program, d, "datatype"); } else if (d is Dafny.ModuleDecl) { // do nothing here, since the outer loop handles modules } else { var cl = (Dafny.ClassDecl)d; if (cl.IsDefaultClass) { // do nothing } else if (cl is Dafny.IteratorDecl) { OutliningRegion.Add(newRegions, program, cl, "iterator"); } else { OutliningRegion.Add(newRegions, program, cl, "class"); } // do the class members (in particular, functions and methods) foreach (Dafny.MemberDecl m in cl.Members) { if (!HasBodyTokens(m)) { continue; } if (m is Dafny.Function && ((Dafny.Function)m).Body != null) { var nm = m is Dafny.InductivePredicate ? "inductive predicate" : m is Dafny.CoPredicate ? "copredicate" : // m is Dafny.PrefixPredicate ? "prefix predicate" : // this won't ever occur here m is Dafny.Predicate ? "predicate" : "function"; if (!m.IsGhost) { nm += " method"; } OutliningRegion.Add(newRegions, program, m, nm); } else if (m is Dafny.Method && ((Dafny.Method)m).Body != null) { var nm = m is Dafny.Constructor ? "constructor" : m is Dafny.CoLemma ? "colemma" : m is Dafny.Lemma ? "lemma" : // m is Dafny.PrefixLemma ? "prefix lemma" : // this won't ever occur here "method"; if (m.IsGhost && !(m is Dafny.CoLemma)) { nm = "ghost " + nm; } OutliningRegion.Add(newRegions, program, m, nm); } } } } } _snapshot = snapshot; _regions = newRegions; _program = program; return(true); }