private static void OnParsingFinished(object sender, CommonInterfaces.ParsingFinishedArgs args)
        {
            string lang = args.Lang;

            if (!parsedSppf.ContainsKey(lang))
            {
                parsedSppf.Add(lang, 0);
            }
            else
            {
                parsedSppf[lang]++;
            }

            Action action =
                () =>
            {
                var isEnd = false;
                while (!isEnd)
                {
                    Tuple <ITreeNode, bool> res = YcProcessor.GetNextTree(lang, parsedSppf[lang]);
                    ExistingTreeNodes.AddTree(res.Item1);
                    isEnd = res.Item2;
                }
            };

            using (TaskBarrier fibers = Process.DaemonProcess.CreateFibers())
            {
                fibers.EnqueueJob(action);
            }
        }
Beispiel #2
0
 public override ICollectUsagesPsiFileProcessor CreatePsiFileProcessor(
     CollectUsagesStageProcess collectUsagesStageProcess,
     IDaemonProcess daemonProcess, IContextBoundSettingsStore settingsStore,
     CollectUsagesStageProcess.PersistentData persistentData,
     TaskBarrier fibers, IReadOnlyList <IFile> psiFiles, IScopeProcessorFactory scopeProcessorFactory)
 {
     // TODO: We could return a no-op processor for .meta or boring assets
     return(new YamlCollectUsagesPsiFileProcessor());
 }
Beispiel #3
0
 /// <summary>
 /// Runs a measurement as specified in the method on the connected device.
 /// </summary>
 /// <param name="method">The method containing the measurement parameters.</param>
 /// <returns>A SimpleMeasurement instance containing all the data related to the measurement.</returns>
 public async Task <SimpleMeasurement> MeasureAsync(Method method, TaskBarrier taskBarrier = null)
 {
     if (method.MuxMethod == MuxMethod.Sequentially)
     {
         return(await MeasureAsync(method, method.GetNextSelectedMuxChannel(-1), taskBarrier));
     }
     else
     {
         return(await MeasureAsync(method, -1, taskBarrier));
     }
 }
        /// <summary>
        /// Do highlighting some tokens chunk.
        /// </summary>
        /// <param name="sender">Now always null</param>
        /// <param name="args"></param>
        private static void OnLexingFinished(object sender, CommonInterfaces.LexingFinishedArgs <ITreeNode> args)
        {
            IHighlightingConsumer consumer = Process.Consumer;
            var processor = new TreeNodeProcessor(consumer, Process.CSharpFile);

            string xmlPath = YcProcessor.XmlPath(args.Lang);

            ColorHelper.ParseFile(xmlPath, args.Lang);

            Action action =
                () => args.Tokens.ForEach(node => processor.ProcessAfterInterior(node));

            using (TaskBarrier fibers = Process.DaemonProcess.CreateFibers())
            {
                fibers.EnqueueJob(action);
            }

            Process.DoHighlighting(new DaemonStageResult(consumer.Highlightings));
        }
Beispiel #5
0
        /// <summary>
        /// Runs a measurement as specified in the method on the connected device.
        /// </summary>
        /// <param name="method">The method containing the measurement parameters.</param>
        /// <param name="muxChannel">The mux channel to measure on.</param>
        /// <returns>
        /// A SimpleMeasurement instance containing all the data related to the measurement.
        /// </returns>
        /// <exception cref="System.NullReferenceException">Not connected to a device.</exception>
        /// <exception cref="System.ArgumentException">Method is incompatible with the connected device.</exception>
        /// <exception cref="System.Exception">Could not start measurement.</exception>
        public async Task <SimpleMeasurement> MeasureAsync(Method method, int muxChannel, TaskBarrier taskBarrier = null)
        {
            _activeMeasurement = null;
            if (_comm == null)
            {
                throw new NullReferenceException("Not connected to a device.");
            }

            //Update the autoranging depending on the current ranges supported by the connected device
            if (Connected)
            {
                method.Ranging.SupportedCurrentRanges = Capabilities.SupportedRanges;
            }

            //Check whether method is compatible with the connected device
            ValidateMethod(method, out bool isValidMethod, out List <string> errors);
            if (!isValidMethod)
            {
                throw new ArgumentException("Method is incompatible with the connected device.");
            }

            //Init task to wait for the active measurement to be initiated by CommManager.MeasureAsync()
            _taskCompletionSource        = new TaskCompletionSource <SimpleMeasurement>();
            _comm.BeginMeasurementAsync += GetActiveMeasurementAsync;

            string error = "";

            //Start the measurement on the connected device, this triggers an event that updates _activeMeasurement
            error = await RunAsync <string>(async() =>
            {
                //Need to check again as the task can be scheduled to run at a later point after which this could have changed
                if (_comm == null)
                {
                    throw new NullReferenceException("Not connected to a device");
                }
                return(await _comm.MeasureAsync(method, muxChannel, taskBarrier));
            });

            if (!(string.IsNullOrEmpty(error)))
            {
                throw new Exception($"Could not start measurement: {error}");
            }

            return(await _taskCompletionSource.Task);
        }