Beispiel #1
0
        protected void TestPerformance(string code, [CallerMemberName] string testName = "")
        {
            ConfigureProjectReferences();

            //get calling method info
            StackTrace stackTrace    = new StackTrace();
            var        callingMethod = stackTrace.GetFrame(1).GetMethod();
            var        testAttribute = (PerformanceTestAttribute)callingMethod.GetCustomAttributes(typeof(PerformanceTestAttribute), true)[0];

            var caret    = GetCaret(ref code);
            var filePath = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory()) / new FileName(testName);

            var log         = new DummyLogger();
            var context     = Context.CreateContext(filePath, code, caret, new DummySourcePackage());
            var mainPackage = PackageCache.GetPackage(new Log(log.TextWriter), _project);

            mainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(mainPackage.CacheDirectory) / new DirectoryName("UxCompletion")).NativePath);

            var build = new CodeNinjaBuild(log, _project, _editors, mainPackage, mainPackage.References.ToList(), code, filePath);

            build.Execute();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            SuggestionParser.GetSuggestions(build.Compiler, context, caret, new DummyReader());
            sw.Stop();

            if (_context == null)
            {
                throw new ArgumentNullException("_context");
            }

            _context.Logger.LogTimeEvent(testName, testAttribute.Description, sw.ElapsedMilliseconds / 1000f);
        }
Beispiel #2
0
        public void AssertUX(string code, [CallerMemberName] string path = "")
        {
            int caret = 0;
            var assertCodeSnippets = GetAsserts(ref code, ref caret);
            var filePath           = AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory()) / new FileName(path);

            var log         = new DummyLogger();
            var context     = Context.CreateContext(filePath, code, caret, new DummySourcePackage());
            var mainPackage = PackageCache.GetPackage(new Log(log.TextWriter), _project);

            mainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(mainPackage.CacheDirectory) / new DirectoryName("UxCompletion")).NativePath);

            var build = new CodeNinjaBuild(log, _project, _editors, mainPackage, mainPackage.References.ToList(), code, filePath);

            build.Execute();

            var suggestions = SuggestionParser.GetSuggestions(build.Compiler, context, caret, new DummyReader());

            if (assertCodeSnippets != null)
            {
                foreach (var codeSnippet in assertCodeSnippets)
                {
                    OnAssert(code, codeSnippet, suggestions, log);
                }
            }
        }
Beispiel #3
0
        bool ChangeProject(string projectPath)
        {
            _currentProject = Project.Load(projectPath);

            new Shell()
            .Watch(AbsoluteFilePath.Parse(projectPath).ContainingDirectory, "*.unoproj")
            .Where(e => e.Event == FileSystemEvent.Changed || e.Event == FileSystemEvent.Removed)
            .Subscribe(f => _currentProject = null);

            MainPackage = PackageCache.GetPackage(Log.Default, _currentProject);
            MainPackage.SetCacheDirectory((AbsoluteDirectoryPath.Parse(MainPackage.CacheDirectory) / new DirectoryName("CodeCompletion")).NativePath);

            TriggerBuild();

            return(true);
        }
Beispiel #4
0
        public FuseJS(PackageCache packages)
            : base(packages.Log)
        {
            var upk    = packages.GetPackage("FuseJS.Transpiler");
            var script = Path.Combine(upk.SourceDirectory, "server.min.js");

            _task = new Shell(packages.Log).Start(
                "node",
                script.QuoteSpace(),
                outputReceived: (sender, args) => {
                string port;
                if (TryMatchPort(args.Data, out port))
                {
                    _url = "http://127.0.0.1:" + port;
                }

                _output.AppendLine(args.Data);
            },
                errorReceived: (sender, args) => {
                _output.AppendLine(args.Data);
            });
        }
Beispiel #5
0
 SourcePackage GetPackage()
 {
     using (Log.StartProfiler(_cache))
         return(_cache.GetPackage(_project));
 }