Пример #1
0
		string GetShortType (IType type, CppResolver state)
		{
			var builder = new TypeSystemAstBuilder (state);
			var dt = state.CurrentTypeDefinition;
			var declaring = type.DeclaringType != null ? type.DeclaringType.GetDefinition () : null;
			if (declaring != null) {
				while (dt != null) {
					if (dt.Equals (declaring)) {
						builder.AlwaysUseShortTypeNames = true;
						break;
					}
					dt = dt.DeclaringTypeDefinition;
				}
			}
			var shortType = builder.ConvertType (type);
			using (var w = new System.IO.StringWriter ()) {
				var visitor = new CppOutputVisitor (w, FormattingPolicy);
				shortType.AcceptVisitor (visitor, null);
				return w.ToString ();
			}
		}
Пример #2
0
		TypeSystemAstBuilder CreateAstBuilder()
		{
			TypeSystemAstBuilder astBuilder = new TypeSystemAstBuilder();
			astBuilder.ShowModifiers = (ConversionFlags & ConversionFlags.ShowModifiers) == ConversionFlags.ShowModifiers;
			astBuilder.ShowAccessibility = (ConversionFlags & ConversionFlags.ShowAccessibility) == ConversionFlags.ShowAccessibility;
			astBuilder.AlwaysUseShortTypeNames = (ConversionFlags & ConversionFlags.UseFullyQualifiedTypeNames) != ConversionFlags.UseFullyQualifiedTypeNames;
			return astBuilder;
		}
Пример #3
0
        public static ICSharpCode.NRefactory.Cpp.AstType ConvertToAstType(this IType type)
        {
            var builder = new TypeSystemAstBuilder();

            return(builder.ConvertType(type));
        }