Example #1
0
		public static AbstractType LookupIdRawly(Misc.ParseCacheView parseCache, ISyntaxRegion o, DModule oContext)
		{
			if (parseCache == null)
				throw new ArgumentNullException ("parseCache");
			if (o == null)
				throw new ArgumentNullException ("o");

			var ctxt = new ResolutionContext (parseCache, null, oContext, o.Location);

			/*
			 * Stuff like std.stdio.someSymbol should be covered by this already
			 */
			ctxt.ContextIndependentOptions = 
				ResolutionOptions.DontResolveBaseTypes | 
				ResolutionOptions.IgnoreAllProtectionAttributes | 
				ResolutionOptions.IgnoreDeclarationConditions | 
				ResolutionOptions.NoTemplateParameterDeduction | 
				ResolutionOptions.ReturnMethodReferencesOnly;

			AbstractType res;

			var td = o as ITypeDeclaration;
			var x = o as IExpression;

			if (td != null)
				res = TypeDeclarationResolver.ResolveSingle (td, ctxt, false);
			else if (x != null)
				res = ExpressionTypeEvaluation.EvaluateType (x, ctxt, false);
			else
				return null;

			if(res != null)
				return res;


			IntermediateIdType id;

			if (td != null)
				id = td.InnerMost as IntermediateIdType;
			else
				id = x as IntermediateIdType;

			if (id == null)
				return null;

			var l = new List<AbstractType> ();

			foreach (var pack in parseCache.EnumRootPackagesSurroundingModule(oContext)) {
				if (pack == null)
					continue;
				
				foreach (DModule mod in pack) {
					if (mod == null)
						continue;

					var children = mod [id.IdHash];
					if (children != null)
						foreach (var n in children)
							l.Add (TypeDeclarationResolver.HandleNodeMatch (n, ctxt, null, id));
				}
			}

			return AmbiguousType.Get(l);
		}
Example #2
0
		public static void SearchNodesByName(int idToFind, DModule parseCacheContext, Misc.ParseCacheView pcw, out List<ModulePackage> foundPackages, out List<INode> foundItems)
		{
			foundItems = new List<INode>();
			foundPackages = new List<ModulePackage>();

			if(idToFind == 0)
				return;

			var currentList = new List<IBlockNode>();
			var nextList = new List<IBlockNode>();

			var currentPackageList = new List<ModulePackage>();
			var nextPackageList = new List<ModulePackage>();

			currentPackageList.AddRange(pcw.EnumRootPackagesSurroundingModule(parseCacheContext));

			while(currentPackageList.Count != 0)
			{
				foreach(var pack in currentPackageList)
				{
					currentList.AddRange (pack.GetModules());

					if(pack.NameHash == idToFind)
						foundPackages.Add(pack);

					nextPackageList.AddRange(pack);
				}

				if(nextPackageList.Count == 0)
					break;

				currentPackageList.Clear();
				currentPackageList.AddRange(nextPackageList);
				nextPackageList.Clear();
			}


			while (currentList.Count != 0) {

				foreach (var i in currentList) {
					var items = i[idToFind];
					if (items != null)
						foundItems.AddRange (items);

					foreach (var k in i)
						if (k is IBlockNode && !foundItems.Contains (k))
							nextList.Add (k as IBlockNode);
				}

				currentList.Clear ();
				currentList.AddRange (nextList);
				nextList.Clear ();
			}
		}