Beispiel #1
0
 public TreeWalker(INode root, FilterSettings settings, NodeFilter filter)
 {
     _root = root;
     _settings = settings;
     _filter = filter ?? (m => FilterResult.Accept);
     _current = _root;
 }
Beispiel #2
0
		/// <summary> Creates an OrFilter that accepts nodes acceptable to either filter.</summary>
		/// <param name="left">One filter.
		/// </param>
		/// <param name="right">The other filter.
		/// </param>
		public OrFilter(NodeFilter left, NodeFilter right)
		{
			NodeFilter[] predicates;
			
			predicates = new NodeFilter[2];
			predicates[0] = left;
			predicates[1] = right;
			Predicates = predicates;
		}
 public NodeIterator(INode root, FilterSettings settings, NodeFilter filter)
 {
     _root = root;
     _settings = settings;
     _filter = filter ?? (m => FilterResult.Accept);
     _beforeNode = true;
     _iterator = _root.GetElements<INode>(settings);
     _reference = _iterator.First();
 }
        internal NodeIterator(Node root, WhatToShow whatToShow, NodeFilter filter)
        {
            Root = root;

            ReferenceNode = root;
            PointerBeforeReferenceNode = true;

            WhatToShow = whatToShow;
            Filter = filter;
        }
Beispiel #5
0
        /// <summary>
        /// Finds child nodes uner the parent node and places them in the currentList.
        /// </summary>
        /// <param name="currentList">List to be populated with the nodes.</param>
        /// <param name="parent">Parent node under which the nodes should be searched.</param>
        /// <param name="filter">Filter to be used while selecting the node.</param>
        /// <param name="criteria">Criteria to be used by the filter.</param>
        internal static void FindNodes(
            IList<HierarchyNode> currentList, HierarchyNode parent, NodeFilter filter, object criteria)
        {
            ErrorHelper.ThrowIsNull(currentList, "currentList");
            ErrorHelper.ThrowIsNull(parent, "parent");
            ErrorHelper.ThrowIsNull(filter, "filter");

            for (HierarchyNode child = parent.FirstChild; child != null; child = child.NextSibling)
            {
                if (filter(child, criteria))
                    currentList.Add(child);

                FindNodes(currentList, child, filter, criteria);
            }
        }
Beispiel #6
0
		/// <summary> Creates a new instance of HasChildFilter that accepts nodes
		/// with a child acceptable to the filter.
		/// Of necessity, this applies only to composite tags, i.e. those that can
		/// contain other nodes, for example &lt;HTML&gt;&lt;/HTML&gt;.
		/// </summary>
		/// <param name="filter">The filter to apply to children.
		/// </param>
		/// <param name="recursive">If <code>true</code>, any enclosed node acceptable
		/// to the given filter causes the node being tested to be accepted
		/// (i.e. a recursive scan through the child nodes down the node
		/// heirarchy is performed).
		/// </param>
		public HasChildFilter(NodeFilter filter, bool recursive)
		{
			ChildFilter = filter;
			Recursive = recursive;
		}
Beispiel #7
0
		/// <summary> Filter the list with the given filter non-recursively.</summary>
		/// <param name="filter">The filter to use.
		/// </param>
		/// <returns> A new node array containing the nodes accepted by the filter.
		/// This is a linear list and preserves the nested structure of the returned
		/// nodes only.
		/// </returns>
		public virtual NodeList ExtractAllNodesThatMatch(NodeFilter filter)
		{
			return (ExtractAllNodesThatMatch(filter, false));
		}
Beispiel #8
0
		/// <summary> Creates a new instance of HasSiblingFilter that accepts nodes
		/// with sibling acceptable to the filter.
		/// </summary>
		/// <param name="filter">The filter to apply to the sibling.
		/// </param>
		public HasSiblingFilter(NodeFilter filter)
		{
			SiblingFilter = filter;
		}
Beispiel #9
0
 public INodeIterator CreateNodeIterator(INode root, FilterSettings settings = FilterSettings.All, NodeFilter filter = null)
 {
     throw new NotImplementedException();
 }
 /// <summary> Creates a new instance of HasParentFilter that accepts nodes with
 /// the direct parent acceptable to the filter.
 /// </summary>
 /// <param name="filter">The filter to apply to the parent.
 /// </param>
 public HasParentFilter(NodeFilter filter) : this(filter, false)
 {
 }
Beispiel #11
0
 public INodeIterator CreateNodeIterator(INode root, FilterSettings settings = FilterSettings.All, NodeFilter filter = null)
 {
     return(null);
 }
 /// <summary> Creates a new instance of HasChildFilter that accepts nodes
 /// with a child acceptable to the filter.
 /// Of necessity, this applies only to composite tags, i.e. those that can
 /// contain other nodes, for example &lt;HTML&gt;&lt;/HTML&gt;.
 /// </summary>
 /// <param name="filter">The filter to apply to children.
 /// </param>
 /// <param name="recursive">If <code>true</code>, any enclosed node acceptable
 /// to the given filter causes the node being tested to be accepted
 /// (i.e. a recursive scan through the child nodes down the node
 /// heirarchy is performed).
 /// </param>
 public HasChildFilter(NodeFilter filter, bool recursive)
 {
     ChildFilter = filter;
     Recursive   = recursive;
 }
Beispiel #13
0
		/// <summary> Extract all nodes matching the given filter.</summary>
		/// <param name="filter">The filter to be applied to the nodes.
		/// </param>
		/// <throws>  ParserException If a parse error occurs. </throws>
		/// <returns> A list of nodes matching the filter criteria,
		/// i.e. for which the filter's accept method
		/// returned <code>true</code>.
		/// </returns>
		public virtual NodeList ExtractAllNodesThatMatch(NodeFilter filter)
		{
			INodeIterator e;
			NodeList ret;
			
			ret = new NodeList();
			for (e = Elements(); e.HasMoreNodes(); )
				e.NextNode().CollectInto(ret, filter);
			
			return (ret);
		}
Beispiel #14
0
 public SpiderManager(NodeFilter nodefilter, String needValue)
 {
     this.nodefilter = nodefilter;
     this.needValue  = needValue;
 }
 /// <summary> Creates a new instance of HasChildFilter that accepts nodes
 /// with a direct child acceptable to the filter.
 /// </summary>
 /// <param name="filter">The filter to apply to the children.
 /// </param>
 public HasChildFilter(NodeFilter filter) : this(filter, false)
 {
 }
Beispiel #16
0
 public TreeWalker CreateTreeWalker(XmlNode root, NodeFilter whatToShow, INodeFilter filter)
 {
     return(default(TreeWalker));
 }
Beispiel #17
0
 public NodeIterator CreateNodeIterator(XmlNode root, NodeFilter whatToShow, INodeFilter filter)
 {
     return(default(NodeIterator));
 }
Beispiel #18
0
		/// <summary> Collect this node and its child nodes (if-applicable) into the list parameter,
		/// provided the node satisfies the filtering criteria.
		/// <p>This mechanism allows powerful filtering code to be written very easily,
		/// without bothering about collection of embedded tags separately.
		/// e.g. when we try to get all the links on a page, it is not possible to
		/// get it at the top-level, as many tags (like form tags), can contain
		/// links embedded in them. We could get the links out by checking if the
		/// current node is a {@link CompositeTag}, and going through its children.
		/// So this method provides a convenient way to do this.</p>
		/// <p>Using collectInto(), programs get a lot shorter. Now, the code to
		/// extract all links from a page would look like:
		/// <pre>
		/// NodeList list = new NodeList();
		/// NodeFilter filter = new TagNameFilter ("A");
		/// for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
		/// e.nextNode().collectInto(list, filter);
		/// </pre>
		/// Thus, <code>list</code> will hold all the link nodes, irrespective of how
		/// deep the links are embedded.</p>
		/// <p>Another way to accomplish the same objective is:
		/// <pre>
		/// NodeList list = new NodeList();
		/// NodeFilter filter = new TagClassFilter (LinkTag.class);
		/// for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
		/// e.nextNode().collectInto(list, filter);
		/// </pre>
		/// This is slightly less specific because the LinkTag class may be
		/// registered for more than one node name, e.g. &lt;LINK&gt; tags too.</p>
		/// </summary>
		/// <param name="list">The list to add nodes to.
		/// </param>
		/// <param name="filter">The filter to apply.
		/// </param>
		public override void CollectInto(NodeList list, NodeFilter filter)
		{
			base.CollectInto(list, filter);
			for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes(); )
				e.NextNode().CollectInto(list, filter);
			if ((null != GetEndTag()) && (this != GetEndTag()))
				// 2nd guard handles <tag/>
				GetEndTag().CollectInto(list, filter);
		}
Beispiel #19
0
		/// <summary> Remove nodes not matching the given filter non-recursively.</summary>
		/// <param name="filter">The filter to use.
		/// </param>
		public virtual void KeepAllNodesThatMatch(NodeFilter filter)
		{
			KeepAllNodesThatMatch(filter, false);
		}
Beispiel #20
0
		/// <summary> Creates an XorFilter that accepts nodes acceptable an odd number of the given filters.</summary>
		/// <param name="predicates">The list of filters. 
		/// </param>
		public XorFilter(NodeFilter[] predicates)
		{
			Predicates = predicates;
		}
 public NodeFilterState(NodeFilter _filter)
 {
     filter = _filter;
 }
Beispiel #22
0
 /// <summary>
 /// Creates a <see cref="NodeIterator"/> object.
 /// </summary>
 /// <param name="root">The node at which to begin traversal.</param>
 /// <param name="whatToShow">A NodeFilter constant indicating which nodes to iterate over.</param>
 /// <param name="filter">An object inheriting the <see cref="NodeFilter"/> class.</param>
 /// <returns>A node iterator object.</returns>
 public NodeIterator createNodeIterator(Node root, int whatToShow = NodeFilter.SHOW_ALL, NodeFilter filter = null)
 {
     return null;
 }
Beispiel #23
0
 public static NodeIterator CreateNodeIterator(XmlNode root, NodeFilter whatToShow, INodeFilter filter)
 {
     return default(NodeIterator);
 }
Beispiel #24
0
 /// <summary>
 /// Creates a <see cref="TreeWalker"/> object.
 /// </summary>
 /// <param name="root">The node at which to begin traversal.</param>
 /// <param name="whatToShow">A NodeFilter constant indicating which nodes to iterate over.</param>
 /// <param name="filter">An object inheriting the <see cref="NodeFilter"/> class.</param>
 /// <returns>A tree walker object.</returns>
 public TreeWalker createTreeWalker(Node root, int whatToShow = NodeFilter.SHOW_ALL, NodeFilter filter = null)
 {
     return null;
 }
Beispiel #25
0
 public TreeWalker createTreeWalker(INode root, ulong whatToShow = 4294967295uL, NodeFilter filter = null)
 {
     throw new NotImplementedException();
 }
Beispiel #26
0
 public HTMLButtonElement(Document document, string localName) : base(document, localName)
 {
     labelFilter = new FilterLabelFor(this);
 }
Beispiel #27
0
 public ITreeWalker CreateTreeWalker(INode root, FilterSettings settings = FilterSettings.All, NodeFilter filter = null)
 {
     return(null);
 }
Beispiel #28
0
 /// <summary>
 /// Returns a new NodeIterator object.
 /// </summary>
 /// <param name="root">The root node at which to begin the NodeIterator's traversal.</param>
 /// <param name="whatToShow">Bitwise OR'd list of Filter specification constants from the NodeFilter DOM interface, indicating which nodes to iterate over.</param>
 /// <param name="filter">An object implementing the NodeFilter interface; its acceptNode() method will be called for each node in the subtree based at root which is accepted as included by the whatToShow flag to determine whether or not to include it in the list of iterable nodes (a simple callback function may also be used instead). The method should return one of NodeFilter.FILTER_ACCEPT, NodeFilter.FILTER_REJECT, or NodeFilter.FILTER_SKIP.</param>
 /// <returns></returns>
 public virtual NodeIterator CreateNodeIterator(Node root, NodeFilter whatToShow, INodeFilter filter)
 {
     return(null);
 }
Beispiel #29
0
        /// <summary>
        /// Writes this instance to the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        internal void Write(BinaryWriter writer)
        {
            // Make sure system marshaller is used.
            Debug.Assert(writer.Marshaller == BinaryUtils.Marshaller);

            writer.WriteInt((int)AtomicityMode);
            writer.WriteInt(Backups);
            writer.WriteInt((int)CacheMode);
            writer.WriteBoolean(CopyOnRead);
            writer.WriteBoolean(EagerTtl);
            writer.WriteBoolean(Invalidate);
            writer.WriteBoolean(KeepBinaryInStore);
            writer.WriteBoolean(LoadPreviousValue);
            writer.WriteLong((long)LockTimeout.TotalMilliseconds);
#pragma warning disable 618
            writer.WriteLong((long)LongQueryWarningTimeout.TotalMilliseconds);
#pragma warning restore 618
            writer.WriteInt(MaxConcurrentAsyncOperations);
            writer.WriteString(Name);
            writer.WriteBoolean(ReadFromBackup);
            writer.WriteInt(RebalanceBatchSize);
            writer.WriteLong((long)RebalanceDelay.TotalMilliseconds);
            writer.WriteInt((int)RebalanceMode);
            writer.WriteLong((long)RebalanceThrottle.TotalMilliseconds);
            writer.WriteLong((long)RebalanceTimeout.TotalMilliseconds);
            writer.WriteBoolean(SqlEscapeAll);
            writer.WriteInt(WriteBehindBatchSize);
            writer.WriteBoolean(WriteBehindEnabled);
            writer.WriteLong((long)WriteBehindFlushFrequency.TotalMilliseconds);
            writer.WriteInt(WriteBehindFlushSize);
            writer.WriteInt(WriteBehindFlushThreadCount);
            writer.WriteBoolean(WriteBehindCoalescing);
            writer.WriteInt((int)WriteSynchronizationMode);
            writer.WriteBoolean(ReadThrough);
            writer.WriteBoolean(WriteThrough);
            writer.WriteBoolean(EnableStatistics);
            writer.WriteString(DataRegionName);
            writer.WriteInt((int)PartitionLossPolicy);
            writer.WriteString(GroupName);
            writer.WriteObject(CacheStoreFactory);
            writer.WriteInt(SqlIndexMaxInlineSize);
            writer.WriteBoolean(OnheapCacheEnabled);
            writer.WriteInt(StoreConcurrentLoadAllThreshold);
            writer.WriteInt(RebalanceOrder);
            writer.WriteLong(RebalanceBatchesPrefetchCount);
            writer.WriteInt(MaxQueryIteratorsCount);
            writer.WriteInt(QueryDetailMetricsSize);
            writer.WriteInt(QueryParallelism);
            writer.WriteString(SqlSchema);
            writer.WriteBoolean(EncryptionEnabled);

            writer.WriteCollectionRaw(QueryEntities);

            if (NearConfiguration != null)
            {
                writer.WriteBoolean(true);
                NearConfiguration.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            EvictionPolicyBase.Write(writer, EvictionPolicy);
            AffinityFunctionSerializer.Write(writer, AffinityFunction);
            ExpiryPolicySerializer.WritePolicyFactory(writer, ExpiryPolicyFactory);

            if (NodeFilter != null)
            {
                writer.WriteBoolean(true);

                var attributeNodeFilter = NodeFilter as AttributeNodeFilter;
                if (attributeNodeFilter == null)
                {
                    throw new NotSupportedException(string.Format(
                                                        "Unsupported CacheConfiguration.NodeFilter: '{0}'. " +
                                                        "Only predefined implementations are supported: '{1}'",
                                                        NodeFilter.GetType().Name, typeof(AttributeNodeFilter).Name));
                }

                attributeNodeFilter.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            writer.WriteCollectionRaw(KeyConfiguration);

            if (PlatformCacheConfiguration != null)
            {
                writer.WriteBoolean(true);
                PlatformCacheConfiguration.Write(writer);
            }
            else
            {
                writer.WriteBoolean(false);
            }

            if (PluginConfigurations != null)
            {
                writer.WriteInt(PluginConfigurations.Count);

                foreach (var cachePlugin in PluginConfigurations)
                {
                    if (cachePlugin == null)
                    {
                        throw new InvalidOperationException("Invalid cache configuration: " +
                                                            "ICachePluginConfiguration can't be null.");
                    }

                    if (cachePlugin.CachePluginConfigurationClosureFactoryId != null)
                    {
                        writer.WriteBoolean(true);
                        writer.WriteInt(cachePlugin.CachePluginConfigurationClosureFactoryId.Value);

                        int pos = writer.Stream.Position;
                        writer.WriteInt(0);  // Reserve size.

                        cachePlugin.WriteBinary(writer);

                        writer.Stream.WriteInt(pos, writer.Stream.Position - pos - 4);  // Write size.
                    }
                    else
                    {
                        writer.WriteBoolean(false);
                        writer.WriteObject(cachePlugin);
                    }
                }
            }
            else
            {
                writer.WriteInt(0);
            }
        }
Beispiel #30
0
 /// <summary>
 /// The Document.createTreeWalker() creator method returns a newly created TreeWalker object.
 /// </summary>
 /// <param name="root">Is the root Node of this TreeWalker traversal. Typically this will be an element owned by the document.</param>
 /// <param name="whatToShow">Is an optionale unsigned long representing a bitmask created by combining the constant properties of NodeFilter. It is a convenient way of filtering for certain types of node. It defaults to 0xFFFFFFFF representing the SHOW_ALL constant.</param>
 /// <param name="filter">Is an optional NodeFilter, that is an object with a method acceptNode, which is called by the TreeWalker to determine whether or not to accept a node that has passed the whatToShow check.</param>
 /// <returns></returns>
 public virtual TreeWalker CreateTreeWalker(Node root, NodeFilter whatToShow, INodeFilter filter)
 {
     return(null);
 }
Beispiel #31
0
		/// <summary> Creates a new instance of HasChildFilter that accepts nodes
		/// with a direct child acceptable to the filter.
		/// </summary>
		/// <param name="filter">The filter to apply to the children.
		/// </param>
		public HasChildFilter(NodeFilter filter):this(filter, false)
		{
		}
        /// <summary>
        ///     TODO separate
        /// </summary>
        /// <param name="node"></param>
        /// <param name="possibleDelegateSymbol"></param>
        /// <param name="map"></param>
        /// <param name="nodeFilter"></param>
        public static void CreateMethodCallEdgeFromDelegatePointer(InvocationExpressionSyntax node,
                                                                   INamedTypeSymbol possibleDelegateSymbol, Dictionary <CSharpSyntaxNode, uint> map,
                                                                   NodeFilter nodeFilter = null)
        {
            //var isNeedToFilter = false;
            Scope @class;

            if (possibleDelegateSymbol.IsGenericType)
            {
                @class = SymbolBuilder.BuildDispatch <ClassGeneric, INamedTypeSymbol>(possibleDelegateSymbol);
            }
            else
            {
                @class = SymbolBuilder.BuildDispatch <Class, INamedTypeSymbol>(possibleDelegateSymbol);
            }

            @class.IsCompilerGenerated = true;
            Commons.Common.ChangeRealizationLevel(@class);
            MainDeclaration.Instance.LimOrigin.addCompIdCsharpIdLimIdToMap(MainDeclaration.Instance.Component.Id,
                                                                           map[node], @class.Id);

            var    member = possibleDelegateSymbol.DelegateInvokeMethod;
            Member calledMethod;

            if (member.IsGenericMethod)
            {
                calledMethod = SymbolBuilder.BuildDispatch <MethodGeneric, IMethodSymbol>(member);
            }
            else
            {
                calledMethod = SymbolBuilder.BuildDispatch <Method, IMethodSymbol>(member);
            }
            calledMethod.IsCompilerGenerated = true;

            Commons.Common.ChangeRealizationLevel(( Scope )calledMethod);
            Commons.Common.Safe_Edge(@class, "HasMember", calledMethod.Id);

            possibleDelegateSymbol.DeclaringSyntaxReferences[0].GetSyntax( )
            .CreateCommentNode(possibleDelegateSymbol);
            possibleDelegateSymbol.DeclaringSyntaxReferences[0].GetSyntax( )
            .CreateCommentNode(possibleDelegateSymbol.DelegateInvokeMethod);

            if (MainDeclaration.Instance.MethodStack.Count > 1)
            {
                Commons.Common.FillFromMethodStack(MainDeclaration.Instance.MethodStack.Pop( ));
            }
            if (MainDeclaration.Instance.ClassStack.Count > 1)
            {
                Commons.Common.FillFromClassStack( );
            }
            (( Method )calledMethod).NumberOfBranches = 0;

            //if ( isNeedToFilter ) nodeFilter( calledMethod.Id );
            var methodCall = MainDeclaration.Instance.LimFactory.createMethodCall(calledMethod.Id);

            //if ( isNeedToFilter ) nodeFilter( methodCall.Id );
            MainDeclaration.Instance.MethodStack.Peek( )
            .Calls.Add(new KeyValuePair <uint, bool>(methodCall.Id, false));
            var id = possibleDelegateSymbol.GetLimType( ).Id;

            //if ( isNeedToFilter ) nodeFilter( id );
            MainDeclaration.Instance.MethodStack.Peek( )
            .Instantiates.Add(new KeyValuePair <uint, bool>(id, false));
        }
 /// <summary> Creates a new instance of HasParentFilter that accepts nodes with
 /// a parent acceptable to the filter.
 /// </summary>
 /// <param name="filter">The filter to apply to the parent.
 /// </param>
 /// <param name="recursive">If <code>true</code>, any enclosing node acceptable
 /// to the given filter causes the node being tested to be accepted
 /// (i.e. a recursive scan through the parent nodes up the node
 /// heirarchy is performed).
 /// </param>
 public HasParentFilter(NodeFilter filter, bool recursive)
 {
     ParentFilter = filter;
     Recursive    = recursive;
 }
Beispiel #34
0
		/// <summary> Creates a NotFilter that accepts nodes not acceptable to the predicate.</summary>
		/// <param name="predicate">The filter to consult.
		/// </param>
		public NotFilter(NodeFilter predicate)
		{
			Predicate = predicate;
		}
Beispiel #35
0
		/// <summary> Filter the list with the given filter.</summary>
		/// <param name="filter">The filter to use.
		/// </param>
		/// <param name="recursive">If <code>true<code> digs into the children recursively.
		/// </param>
		/// <returns> A new node array containing the nodes accepted by the filter.
		/// This is a linear list and preserves the nested structure of the returned
		/// nodes only.
		/// </returns>
		public virtual NodeList ExtractAllNodesThatMatch(NodeFilter filter, bool recursive)
		{
			INode node;
			NodeList children;
			NodeList ret;
			
			ret = new NodeList();
			for (int i = 0; i < m_iSize; i++)
			{
				node = nodeData[i];
				if (filter.Accept(node))
					ret.Add(node);
				if (recursive)
				{
					children = node.Children;
					if (null != children)
						ret.Add(children.ExtractAllNodesThatMatch(filter, recursive));
				}
			}
			
			return (ret);
		}
Beispiel #36
0
 public ITreeWalker CreateTreeWalker(INode root, FilterSettings settings = FilterSettings.All, NodeFilter filter = null)
 {
     throw new NotImplementedException();
 }
Beispiel #37
0
		/// <summary> Remove nodes not matching the given filter.</summary>
		/// <param name="filter">The filter to use.
		/// </param>
		/// <param name="recursive">If <code>true<code> digs into the children recursively.
		/// </param>
		public virtual void KeepAllNodesThatMatch(NodeFilter filter, bool recursive)
		{
			INode node;
			NodeList children;
			
			for (int i = 0; i < m_iSize; )
			{
				node = nodeData[i];
				if (!filter.Accept(node))
					Remove(i);
				else
				{
					if (recursive)
					{
						children = node.Children;
						if (null != children)
							children.KeepAllNodesThatMatch(filter, recursive);
					}
					i++;
				}
			}
		}
Beispiel #38
0
 /// <summary>
 /// Creates a new TreeWalker object.
 /// </summary>
 /// <param name="root">
 /// Is the root Node of this TreeWalker traversal.
 /// </param>
 /// <param name="settings">
 /// Indicates which nodes to iterate over.
 /// </param>
 /// <param name="filter">
 /// An optional callback function for filtering.
 /// </param>
 /// <returns>The created node TreeWalker.</returns>
 public ITreeWalker CreateTreeWalker(INode root, FilterSettings settings = FilterSettings.All, NodeFilter filter = null)
 {
     return new TreeWalker(root, settings, filter);
 }
        /// <summary>
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="calledSymbol"></param>
        /// <param name="nodeFilter"></param>
        public static void CreateMethodCallEdge(ISymbol symbol, ISymbol calledSymbol, NodeFilter nodeFilter = null)
        {
            var  isNeedToFilter = nodeFilter != null;
            var  methodSymbol   = symbol as IMethodSymbol;
            Base node;

            if (methodSymbol != null && methodSymbol.IsGenericMethod)
            {
                node = methodSymbol.GetMGI(calledSymbol as IMethodSymbol);
                var id = MainDeclaration.Instance.LimFactory.createTypeFormerType(node.Id).Id;
                MainDeclaration.Instance.LimFactory.addTypeFormer(id);
                var type = MainDeclaration.Instance.LimFactory.endType( );
                if (isNeedToFilter)
                {
                    nodeFilter(id);
                    nodeFilter(type.Id);
                }
            }
            else
            {
                if (isNeedToFilter)
                {
                    node = SymbolBuilder.BuildDispatch <Method, IMethodSymbol>(( IMethodSymbol )calledSymbol);
                    (( Member )node).IsCompilerGenerated = true;
                    Commons.Common.FillFromMethodStack(MainDeclaration.Instance.MethodStack.Pop( ));
                }
                else
                {
                    node = calledSymbol.ConvertToLimNode( );
                }
            }
            if (isNeedToFilter)
            {
                nodeFilter(node.Id);
            }
            var methodCall = MainDeclaration.Instance.LimFactory.createMethodCall(node.Id);

            if (isNeedToFilter)
            {
                nodeFilter(methodCall.Id);
            }
            MainDeclaration.Instance.MethodStack.Peek( )
            .Calls.Add(new KeyValuePair <uint, bool>(methodCall.Id, isNeedToFilter));
        }
Beispiel #40
0
		/// <summary> Parse the given resource, using the filter provided.
		/// This can be used to extract information from specific nodes.
		/// When used with a <code>null</code> filter it returns an
		/// entire page which can then be modified and converted back to HTML
		/// (Note: the synthesis use-case is not handled very well; the parser
		/// is more often used to extract information from a web page).
		/// <p>For example, to replace the entire contents of the HEAD with a
		/// single TITLE tag you could do this:
		/// <pre>
		/// NodeList nl = parser.parse (null); // here is your two node list
		/// NodeList heads = nl.extractAllNodesThatMatch (new TagNameFilter ("HEAD"))
		/// if (heads.size () > 0) // there may not be a HEAD tag
		/// {
		/// Head head = heads.elementAt (0); // there should be only one
		/// head.removeAll (); // clean out the contents
		/// Tag title = new TitleTag ();
		/// title.setTagName ("title");
		/// title.setChildren (new NodeList (new TextNode ("The New Title")));
		/// Tag title_end = new TitleTag ();
		/// title_end.setTagName ("/title");
		/// title.setEndTag (title_end);
		/// head.add (title);
		/// }
		/// System.out.println (nl.toHtml ()); // output the modified HTML
		/// </pre>
		/// </p>
		/// </summary>
		/// <returns> The list of matching nodes (for a <code>null</code>
		/// filter this is all the top level nodes).
		/// </returns>
		/// <param name="filter">The filter to apply to the parsed nodes,
		/// or <code>null</code> to retrieve all the top level nodes.
		/// </param>
		/// <throws>  ParserException If a parsing error occurs. </throws>
		public virtual NodeList Parse(NodeFilter filter)
		{
			INodeIterator e;
			INode node;
			NodeList ret;
			
			ret = new NodeList();
			for (e = Elements(); e.HasMoreNodes(); )
			{
				node = e.NextNode();
				if (null != filter)
					node.CollectInto(ret, filter);
				else
					ret.Add(node);
			}
			
			return (ret);
		}
 internal TreeWalker(Node root, WhatToShow whatToShow, NodeFilter filter)
 {
     Root = root;
     WhatToShow = whatToShow;
     Filter = filter;
 }
Beispiel #42
0
 protected HTMLCollection(HTMLElement root, NodeFilter CollectionFilter) : this(root)
 {
     this.CollectionFilter = CollectionFilter;
 }
Beispiel #43
0
 /// <summary>
 /// Creates a new NodeIterator object.
 /// </summary>
 /// <param name="root">
 /// The root node at which to begin the NodeIterator's traversal.
 /// </param>
 /// <param name="settings">
 /// Indicates which nodes to iterate over.
 /// </param>
 /// <param name="filter">
 /// An optional callback function for filtering.
 /// </param>
 /// <returns>The created node NodeIterator.</returns>
 public INodeIterator CreateNodeIterator(INode root, FilterSettings settings = FilterSettings.All, NodeFilter filter = null)
 {
     return new NodeIterator(root, settings, filter);
 }
Beispiel #44
0
		/// <summary> Collect this node and its child nodes (if-applicable) into the collectionList parameter, provided the node
		/// satisfies the filtering criteria.<P>
		/// 
		/// This mechanism allows powerful filtering code to be written very easily,
		/// without bothering about collection of embedded tags separately.
		/// e.g. when we try to get all the links on a page, it is not possible to
		/// get it at the top-level, as many tags (like form tags), can contain
		/// links embedded in them. We could get the links out by checking if the
		/// current node is a <see cref="CompositeTag"></see>, and going through its children.
		/// So this method provides a convenient way to do this.<P>
		/// 
		/// Using collectInto(), programs get a lot shorter. Now, the code to
		/// extract all links from a page would look like:
		/// <pre>
		/// NodeList collectionList = new NodeList();
		/// NodeFilter filter = new TagNameFilter ("A");
		/// for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
		/// e.nextNode().collectInto(collectionList, filter);
		/// </pre>
		/// Thus, collectionList will hold all the link nodes, irrespective of how
		/// deep the links are embedded.<P>
		/// 
		/// Another way to accomplish the same objective is:
		/// <pre>
		/// NodeList collectionList = new NodeList();
		/// NodeFilter filter = new TagClassFilter (LinkTag.class);
		/// for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
		/// e.nextNode().collectInto(collectionList, filter);
		/// </pre>
		/// This is slightly less specific because the LinkTag class may be
		/// registered for more than one node name, e.g. &lt;LINK&gt; tags too.
		/// </summary>
		/// <param name="list">The node list to collect acceptable nodes into.
		/// </param>
		/// <param name="filter">The filter to determine which nodes are retained.
		/// </param>
		public virtual void CollectInto(NodeList list, NodeFilter filter)
		{
			if (filter.Accept(this))
			{
				list.Add(this);
			}
		}
Beispiel #45
0
 public ElementInternals(HTMLElement targetElement)
 {
     TargetElement = targetElement;
     labelFilter   = new FilterLabelFor(TargetElement);
 }
Beispiel #46
0
 public NodeIterator createNodeIterator(INode root, ulong whatToShow = 4294967295uL, NodeFilter filter = null)
 {
     throw new NotImplementedException();
 }
Beispiel #47
0
 public static TreeWalker CreateTreeWalker(XmlNode root, NodeFilter whatToShow, INodeFilter filter)
 {
     return default(TreeWalker);
 }
Beispiel #48
0
        public void Write(string file, Solution solution)
        {
            var output = new StringBuilder();

            output.AppendLine("<graphviz dot>");
            output.AppendLine("digraph sample {");

            var existingNodes = new List <string>();

            foreach (var project in solution.Projects)
            {
                var normalizedProjectName = NodeFilter.NormalizeReference(project.ProjectName);
                InitReference(output, existingNodes, normalizedProjectName, Path.GetFileName(project.ProjectName), "box");

                foreach (var reference in project.BinaryReferences.Where(NodeFilter.BinaryParticipateInGraph))
                {
                    var normalizedReference = NodeFilter.NormalizeReference(reference);
                    InitReference(output, existingNodes, normalizedReference, reference, "box");
                }

                foreach (var reference in project.ProjectReferences)
                {
                    var normalizedReference = NodeFilter.NormalizeReference(reference);
                    InitReference(output, existingNodes, normalizedReference, Path.GetFileNameWithoutExtension(reference), "box");
                }

                foreach (var reference in project.PackageReferences.Where(NodeFilter.PackageParticipateInGraph))
                {
                    var normalizedReference = NodeFilter.NormalizeReference(reference);
                    InitReference(output, existingNodes, normalizedReference, reference, "ellipse");
                }
            }

            foreach (var project in solution.Projects)
            {
                foreach (var reference in project.BinaryReferences.Where(NodeFilter.BinaryParticipateInGraph))
                {
                    output.AppendLine($"{NodeFilter.NormalizeReference(project.ProjectName)} -> {NodeFilter.NormalizeReference(reference)} [color=red]");
                }

                foreach (var reference in project.ProjectReferences)
                {
                    output.AppendLine($"{NodeFilter.NormalizeReference(project.ProjectName)} -> {NodeFilter.NormalizeReference(reference)} [color=black]");
                }

                foreach (var reference in project.PackageReferences.Where(NodeFilter.PackageParticipateInGraph))
                {
                    output.AppendLine($"{NodeFilter.NormalizeReference(project.ProjectName)} -> {NodeFilter.NormalizeReference(reference)} [color=blue]");
                }
            }

            output.AppendLine("}");
            output.AppendLine("</graphviz>");
            File.WriteAllText(file, output.ToString());
        }