コード例 #1
0
        public IClassificationType CreateTransientClassificationType(IEnumerable <IClassificationType> baseTypes)
        {
            if (baseTypes == null)
            {
                throw new ArgumentNullException(nameof(baseTypes));
            }
            var bts = baseTypes.ToArray();

            if (bts.Length == 0)
            {
                throw new InvalidOperationException();
            }

            Array.Sort(bts, (a, b) => a.Classification.CompareTo(b.Classification));
            var name = GetTransientName(bts);

            if (transientNameToType.TryGetValue(name, out var ct))
            {
                return(ct);
            }

            ct = new ClassificationType(name, baseTypes);
            transientNameToType.Add(name, ct);
            return(ct);
        }
コード例 #2
0
#pragma warning restore CS0169

        public IClassificationType CreateClassificationType(string type, IEnumerable <IClassificationType> baseTypes)
        {
            if (baseTypes == null)
            {
                throw new ArgumentNullException(nameof(baseTypes));
            }
            if (toClassificationType.ContainsKey(type))
            {
                throw new InvalidOperationException();
            }
            var ct = new ClassificationType(type, baseTypes);

            toClassificationType.Add(type, ct);
            return(ct);
        }
コード例 #3
0
            IClassificationType?TryCreate(string type, int recurse)
            {
                var ct = TryGet(type);

                if (!(ct is null))
                {
                    return(ct);
                }

                const int MAX_RECURSE = 1000;

                Debug.Assert(recurse <= MAX_RECURSE);
                if (recurse > MAX_RECURSE)
                {
                    return(null);
                }

                bool b = rawClassificationTypes.TryGetValue(type, out var rawCt);

                Debug.Assert(b);
                if (!b)
                {
                    return(null);
                }
                Debug.Assert(!(rawCt is null));
                b = rawClassificationTypes.Remove(rawCt.Type);
                Debug.Assert(b);

                var baseTypes = new IClassificationType[rawCt.BaseTypes.Length];

                for (int i = 0; i < baseTypes.Length; i++)
                {
                    var btClassificationType = TryCreate(rawCt.BaseTypes[i], recurse + 1);
                    if (btClassificationType is null)
                    {
                        return(null);
                    }
                    baseTypes[i] = btClassificationType;
                }

                ct = new ClassificationType(rawCt.Type, baseTypes);
                owner.toClassificationType.Add(ct.Classification, ct);
                return(ct);
            }
コード例 #4
0
			IClassificationType TryCreate(string type, int recurse) {
				var ct = TryGet(type);
				if (ct != null)
					return ct;

				const int MAX_RECURSE = 1000;
				Debug.Assert(recurse <= MAX_RECURSE);
				if (recurse > MAX_RECURSE)
					return null;

				RawClassificationType rawCt;
				bool b = rawClassificationTypes.TryGetValue(type, out rawCt);
				Debug.Assert(b);
				if (!b)
					return null;
				b = rawClassificationTypes.Remove(rawCt.Type);
				Debug.Assert(b);

				var baseTypes = new IClassificationType[rawCt.BaseTypes.Length];
				for (int i = 0; i < baseTypes.Length; i++) {
					var btClassificationType = TryCreate(rawCt.BaseTypes[i], recurse + 1);
					if (btClassificationType == null)
						return null;
					baseTypes[i] = btClassificationType;
				}

				ct = new ClassificationType(rawCt.Type, baseTypes);
				owner.toClassificationType.Add(ct.Classification, ct);
				return ct;
			}
コード例 #5
0
		public IClassificationType CreateTransientClassificationType(IEnumerable<IClassificationType> baseTypes) {
			if (baseTypes == null)
				throw new ArgumentNullException(nameof(baseTypes));
			var bts = baseTypes.ToArray();
			if (bts.Length == 0)
				throw new InvalidOperationException();

			Array.Sort(bts, (a, b) => a.Classification.CompareTo(b.Classification));
			var name = GetTransientName(bts);
			IClassificationType ct;
			if (transientNameToType.TryGetValue(name, out ct))
				return ct;

			ct = new ClassificationType(name, baseTypes);
			transientNameToType.Add(name, ct);
			return ct;
		}
コード例 #6
0
#pragma warning restore 0169

		public IClassificationType CreateClassificationType(string type, IEnumerable<IClassificationType> baseTypes) {
			if (baseTypes == null)
				throw new ArgumentNullException(nameof(baseTypes));
			if (toClassificationType.ContainsKey(type))
				throw new InvalidOperationException();
			var ct = new ClassificationType(type, baseTypes);
			toClassificationType.Add(type, ct);
			return ct;
		}