Example #1
0
        private void AppendDeclaredType([NotNull] IDeclaredType declaredType, QualifierDisplays expectedQualifierDisplay, Context context)
        {
            if (declaredType.IsNullable())
            {
                IType underlyingType = declaredType.GetNullableUnderlyingType();
                if (underlyingType != null)
                {
                    AppendTypeWithoutModule(underlyingType, expectedQualifierDisplay, context);
                    AppendText("?", _highlighterIdProvider.Operator);
                    return;
                }
            }

            if (declaredType is IDynamicType)
            {
                AppendText("dynamic", _highlighterIdProvider.Keyword);
                return;
            }

            if (context.Options.UseTypeKeywords)
            {
                string typeKeyword = CSharpTypeFactory.GetTypeKeyword(declaredType.GetClrName());
                if (typeKeyword != null)
                {
                    AppendText(typeKeyword, _highlighterIdProvider.Keyword);
                    return;
                }
            }
            else if (declaredType.IsVoid())
            {
                AppendText("void", _highlighterIdProvider.Keyword);
                return;
            }

            ITypeElement typeElement = declaredType.GetTypeElement();

            if (typeElement == null || !typeElement.IsValid())
            {
                PsiLanguageType language = CSharpLanguage.Instance ?? (PsiLanguageType)UnknownLanguage.Instance;
                AppendText(declaredType.GetPresentableName(language), null);
            }
            else
            {
                AppendTypeElement(typeElement, declaredType.GetSubstitution(), expectedQualifierDisplay, context);
            }
        }
Example #2
0
        private void AppendDeclaredType([NotNull] IDeclaredType declaredType, NamespaceDisplays expectedNamespaceDisplay)
        {
            if (declaredType.IsNullable())
            {
                IType underlyingType = declaredType.GetNullableUnderlyingType();
                if (underlyingType != null)
                {
                    AppendType(underlyingType, expectedNamespaceDisplay);
                    AppendText("?", VsHighlightingAttributeIds.Operator);
                    return;
                }
            }

            if (declaredType is IDynamicType)
            {
                AppendText("dynamic", VsHighlightingAttributeIds.Keyword);
                return;
            }

            if (_options.UseTypeKeywords)
            {
                string typeKeyword = CSharpTypeFactory.GetTypeKeyword(declaredType.GetClrName());
                if (typeKeyword != null)
                {
                    AppendText(typeKeyword, VsHighlightingAttributeIds.Keyword);
                    return;
                }
            }
            else if (declaredType.IsVoid())
            {
                AppendText("void", VsHighlightingAttributeIds.Keyword);
                return;
            }

            ITypeElement typeElement = declaredType.GetTypeElement();

            if (typeElement == null || !typeElement.IsValid())
            {
                AppendText(declaredType.GetPresentableName(UnknownLanguage.Instance), null);
                return;
            }

            AppendTypeElement(typeElement, declaredType.GetSubstitution(), expectedNamespaceDisplay);
        }