Pytocs.TypeInference.AnalyzerImpl.Finish C# (CSharp) Method

Finish() public method

public Finish ( ) : void
return void
        public void Finish()
        {
            msg("\nFinished loading files. " + nCalled + " functions were called.");
            msg("Analyzing uncalled functions");
            ApplyUncalled();

            // mark unused variables
            foreach (Binding b in allBindings)
            {
                if (!(b.type is ClassType) &&
                        !(b.type is FunType) &&
                        !(b.type is ModuleType)
                        && b.refs.Count == 0)
                {
                    putProblem(b.node, "Unused variable: " + b.name);
                }
            }
            msg(getAnalysisSummary());
        }

Usage Example

Beispiel #1
0
        public void TypeAn_FuncDef_Globals()
        {
            fs.Dir("foo")
            .File("test.py",
                  @"
x = 'default'
def crunk(a):
    global x
    if x != 'default':
        print 'Yo'
    print a
    x = ''
    return 'fun'
");
            an.Analyze(@"\foo");
            an.Finish();
            var sExp =
                @"(binding:kind=MODULE:node=(module:\foo\test.py):type=test:qname=.foo.test:refs=[])" + nl +
                @"(binding:kind=SCOPE:node=x:type=str:qname=.foo.test.x:refs=[x,x,x])" + nl +
                @"(binding:kind=FUNCTION:node=crunk:type=? -> str:qname=.foo.test.crunk:refs=[])" + nl +
                @"(binding:kind=PARAMETER:node=a:type=?:qname=.foo.test.crunk.a:refs=[a])" + nl;

            Console.WriteLine(BindingsToString());

            Assert.Equal(sExp, BindingsToString());
        }