Exemplo n.º 1
0
        private void ProcessDocument(FileSystemWatcher fileWatcher,
                                     BuildContext context, ReferenceDocument document)
        {
            try
            {
                if (!document.BeginEdit(fileWatcher))
                {
                    return;
                }

                // For each configuration, retrieve the processor (visitor) and
                // process the document...
                int itemCount = _listConfigurations.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    BuildConfiguration configuration = _listConfigurations[i];

                    string configName = configuration.Name;
                    if (_dictVisitors.ContainsKey(configName))
                    {
                        ReferenceVisitor visitor = _dictVisitors[configName];
                        if (visitor != null && visitor.IsInitialized)
                        {
                            visitor.Visit(document);
                        }
                    }
                }
            }
            finally
            {
                document.EndEdit();
            }
        }
Exemplo n.º 2
0
        protected Expression ResolveReference(Expression Root, string reference)
        {
            ReferenceVisitor visitor = new ReferenceVisitor(new JsonPath(reference));

            Root.Accept(visitor);
            return(visitor.ReferencedExpression);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the button1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ReferenceScope scope = GetReferenceScope();
                lstArtefacts.Items.Clear();

                ConfigurationMode mode   = new ConfigurationMode(cbMode.Text);
                ReferenceWalker   w      = new ReferenceWalker(scope, mode);
                string            folder = null;
                if ((string)cbAction.SelectedItem == "current solution")
                {
                    folder = @"c:\[sln]\";
                }
                ReferenceVisitor rv = new ReferenceVisitor(scope, folder);
                w.Traverse(rv, _system);
//                ReferenceContext context = new ReferenceContext(mode, scope, (ReferenceContext.ReferenceSource)cbAction.SelectedItem, CandleModel.GetInstance(((ModelElement)system).Store), "project folder\\..\\");
                foreach (string item in rv.References)
                {
                    lstArtefacts.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 4
0
            /// <summary>
            ///     Constructor
            /// </summary>
            public CreateDependancy()
            {
                TheReferenceVisitor = new ReferenceVisitor();

                foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
                {
                    visit(dictionary, true);
                }
            }
Exemplo n.º 5
0
        private static void ResolveReference(ReferenceExpression reference, Expression root)
        {
            ReferenceVisitor visitor = new ReferenceVisitor(reference.Path);

            visitor.Visit(root);
            if (visitor.ReferencedExpression == null)
            {
                throw new ParseException("Unable to resolve reference to " + reference.Path);
            }
            reference.ReferencedExpression = visitor.ReferencedExpression;
        }
        public static IReadOnlyList <IntermediateNodeReference> FindDescendantReferences <TNode>(this DocumentIntermediateNode document)
            where TNode : IntermediateNode
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            var visitor = new ReferenceVisitor <TNode>();

            visitor.Visit(document);
            return(visitor.References);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Execute the command
        /// </summary>
        public void Exec()
        {
            if (!Enabled)
            {
                return;
            }

            //
            ReferenceWalker  walker  = new ReferenceWalker(ReferenceScope.All, new ConfigurationMode());
            ReferenceVisitor visitor = new ReferenceVisitor(ReferenceScope.All);

            walker.Traverse(visitor, _externalModel);
            List <CandleModel> models = new List <CandleModel>();

            foreach (CandleModel model in visitor.Models)
            {
                if (_force || model.MetaData.IsLastVersion() == false)
                {
                    models.Add(model);
                }
            }

            SelectModelForm form = new SelectModelForm(models, visitor.Models);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (CandleModel model in form.SelectedModels)
                {
                    RepositoryManager.Instance.ModelsMetadata.GetModelInLocalRepository(model.MetaData);
                }

                if (_externalComponent != null)
                {
                    using (Transaction transaction = _externalComponent.Store.TransactionManager.BeginTransaction("Update ports"))
                    {
                        if (_externalComponent.UpdateFromModel())
                        {
                            transaction.Commit();
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Liste des artifacts d'un modèle
        /// </summary>
        /// <param name="metadata"></param>
        /// <returns></returns>
        public List <string> GetArtifacts(ComponentModelMetadata metadata)
        {
            ComponentSig  sig = new ComponentSig(metadata);
            List <string> artifacts;

            if (!_artifactsCache.TryGetValue(sig, out artifacts))
            {
                ModelLoader loader = ModelLoader.GetLoader(metadata);
                if (loader != null && loader.Model != null)
                {
                    ReferenceWalker  walker  = new ReferenceWalker(ReferenceScope.Publish, new ConfigurationMode("*"));
                    ReferenceVisitor visitor = new ReferenceVisitor(ReferenceScope.Publish);
                    walker.Traverse(visitor, loader.Model);
                    artifacts = new List <string>();
                    foreach (string artifactFileName in visitor.References)
                    {
                        artifacts.Add(Path.GetFileName(artifactFileName));
                    }
                }
                _artifactsCache.Add(sig, artifacts);
            }
            return(artifacts);
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Provides the list of references for a given filter
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public List<Usage> FindReferences(BaseFilter filter)
        {
            // Find references
            ReferenceVisitor visitor = new ReferenceVisitor(filter);
            ModelElement.DontRaiseError(() =>
            {
                foreach (Dictionary dictionary in Dictionaries)
                {
                    visitor.visit(dictionary, true);
                }
                visitor.Usages.Sort();
            });

            return visitor.Usages;
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Provides the list of references of a given model element
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<Usage> FindReferences(ModelElement model)
        {
            List<Usage> retVal;

            if (model != null)
            {
                // Find references
                ReferenceVisitor visitor = new ReferenceVisitor(model);
                ModelElement.DontRaiseError(() =>
                {
                    foreach (Dictionary dictionary in Dictionaries)
                    {
                        visitor.visit(dictionary, true);
                    }
                    visitor.Usages.Sort();
                });

                retVal = visitor.Usages;
                foreach (Usage usage in retVal)
                {
                    // It has not been proven that it is something else than Read
                    // Let's consider it is read
                    if (usage.Mode == null)
                    {
                        usage.Mode = Usage.ModeEnum.Read;
                    }
                }
            }
            else
            {
                retVal = new List<Usage>();
            }

            return retVal;
        }
Exemplo n.º 11
0
        private void PrepareVisitors(BuildContext context)
        {
            if (_dictVisitors == null)
            {
                _dictVisitors = new Dictionary <string, ReferenceVisitor>();
            }

            _listConfigurations = new List <ReferenceConfiguration>();

            // List out enabled Sandcastle Assist and the Plugin configurations...
            IBuildNamedList <BuildConfiguration> dicAssistConfigs
                = _engineSettings.Configurations;

            if (dicAssistConfigs != null && dicAssistConfigs.Count != 0)
            {
                foreach (ReferenceConfiguration config in dicAssistConfigs)
                {
                    // It must be both enabled to be used and active/valid...
                    if (config.Enabled && config.IsActive &&
                        String.Equals(config.Category, "ReferenceVisitor",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        // Make sure there is a handler of this configuration...
                        ReferenceVisitor visitor = config.CreateVisitor();
                        if (visitor != null)
                        {
                            _listConfigurations.Add(config);

                            if (!_dictVisitors.ContainsKey(config.Name))
                            {
                                _dictVisitors.Add(config.Name, visitor);
                            }
                        }
                    }
                }
            }

            IBuildNamedList <BuildConfiguration> dicPluginConfigs
                = _engineSettings.PluginConfigurations;

            if (dicPluginConfigs != null && dicPluginConfigs.Count != 0)
            {
                foreach (ReferenceConfiguration config in dicPluginConfigs)
                {
                    // It must be both enabled to be used and active/valid...
                    if (config.Enabled && config.IsActive &&
                        String.Equals(config.Category, "ReferenceVisitor",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        // Make sure there is a handler of this configuration...
                        ReferenceVisitor visitor = config.CreateVisitor();
                        if (visitor != null)
                        {
                            _listConfigurations.Add(config);

                            if (!_dictVisitors.ContainsKey(config.Name))
                            {
                                _dictVisitors.Add(config.Name, visitor);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
            /// <summary>
            ///     Constructor
            /// </summary>
            public CreateDependancy()
            {
                TheReferenceVisitor = new ReferenceVisitor();

                foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
                {
                    visit(dictionary, true);
                }
            }
 /// <summary>
 /// Computes whether this APPLY statement has side effects
 /// </summary>
 /// <returns></returns>
 private void ComputeSideEffects()
 {
     SideEffectOnVariable = false;
     ReferenceVisitor visitor = new ReferenceVisitor(IteratorVariable);
     visitor.ConsiderInterpreterTreeNode(AppliedStatement);
     foreach (Usage usage in visitor.Usages)
     {
         // Simplification : we don't know if the procedure changes the value of the variable
         if (usage.Mode == Usage.ModeEnum.Parameter ||
             usage.Mode == Usage.ModeEnum.ReadAndWrite ||
             usage.Mode == Usage.ModeEnum.Write)
         {
             SideEffectOnVariable = true;
         }
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Provides the mode for the typed element provided
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public Usage.ModeEnum GetModeForTypedElement(ITypedElement element)
        {
            Usage.ModeEnum retVal = Usage.ModeEnum.Read;

            ReferenceVisitor visitor = new ReferenceVisitor(element);
            visitor.ConsiderInterpreterTreeNode(Statement);
            foreach (Usage usage in visitor.Usages)
            {
                if (usage.Mode != null && usage.Mode != Usage.ModeEnum.Read)
                {
                    retVal = (Usage.ModeEnum) usage.Mode;
                    break;
                }
            }

            return retVal;
        }
Exemplo n.º 15
0
            /// <summary>
            ///     Constructor
            /// </summary>
            /// <param name="system"></param>
            public CreateDependancy(EFSSystem system)
            {
                TheReferenceVisitor = new ReferenceVisitor();

                foreach (Dictionary dictionary in system.Dictionaries)
                {
                    visit(dictionary, true);
                }
            }