private void AppendTypeWithoutModule([NotNull] IType type, QualifierDisplays expectedQualifierDisplay, Context context) { var arrayType = type as IArrayType; if (arrayType != null) { AppendArrayType(arrayType, expectedQualifierDisplay, context); return; } var pointerType = type as IPointerType; if (pointerType != null) { AppendPointerType(pointerType, expectedQualifierDisplay, context); return; } var declaredType = type as IDeclaredType; if (declaredType != null) { AppendDeclaredType(declaredType, expectedQualifierDisplay, context); return; } if (type is IAnonymousType) { AppendText("anonymous type", null); return; } AppendText(type.GetLongPresentableName(CSharpLanguage.Instance), null); }
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); } }
private void AppendTypeElement([NotNull] ITypeElement typeElement, [NotNull] ISubstitution substitution, QualifierDisplays expectedQualifierDisplay, Context context) { if (!(typeElement is ITypeParameter) && (context.Options.ShowQualifiers & expectedQualifierDisplay) != QualifierDisplays.None) { INamespace containingNamespace = typeElement.GetContainingNamespace(); AppendNamespace(containingNamespace); if (!containingNamespace.IsRootNamespace) { AppendText(".", _highlighterIdProvider.Operator); } ITypeElement containingType = typeElement.GetContainingType(); if (containingType != null && !(typeElement is IDelegate && context.Options.FormatDelegatesAsLambdas)) { AppendDeclaredType(TypeFactory.CreateType(containingType, substitution), QualifierDisplays.None, context); AppendText(".", _highlighterIdProvider.Operator); } } var deleg = typeElement as IDelegate; if (deleg != null && context.Options.FormatDelegatesAsLambdas && expectedQualifierDisplay == QualifierDisplays.Parameters) { AppendParameters(deleg.InvokeMethod, substitution, false, context); AppendText(" => ", _highlighterIdProvider.Operator); AppendTypeWithoutModule(substitution.Apply(deleg.InvokeMethod.ReturnType), expectedQualifierDisplay, context); return; } string highlighterId = _highlighterIdProvider.GetForTypeElement(typeElement); AppendText(FormatShortName(typeElement.ShortName), highlighterId); AppendTypeParameters(typeElement, substitution, context); }
private void AppendPointerType([NotNull] IPointerType pointerType, QualifierDisplays expectedQualifierDisplay, Context context) { AppendTypeWithoutModule(pointerType.ElementType, expectedQualifierDisplay, context); AppendText("*", _highlighterIdProvider.Operator); }
private void AppendArrayType([NotNull] IArrayType arrayType, QualifierDisplays expectedQualifierDisplay, Context context) { AppendTypeWithoutModule(arrayType.ElementType, expectedQualifierDisplay, context); AppendText("[" + new string(',', arrayType.Rank - 1) + "]", null); }
private void AppendElementType([NotNull] IDeclaredElement element, [NotNull] ISubstitution substitution, QualifierDisplays expectedQualifierDisplay, [CanBeNull] string before, [CanBeNull] string after, Context context) { // Use the special type first if available (eg Razor helper), colorize it as a keyword string specialTypeString = CSharpModificationUtil.GetSpecialElementType(_specialTypeStyle, element, substitution); if (!specialTypeString.IsEmpty()) { AppendText(before, null); AppendText(specialTypeString, _highlighterIdProvider.Keyword); AppendText(after, null); return; } IType elementType = GetElementType(element, substitution); if (elementType == null) { return; } AppendText(before, null); AppendTypeWithoutModule(elementType, expectedQualifierDisplay, context); AppendText(after, null); }
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("?", VsHighlightingAttributeIds.Operator); return; } } if (declaredType is IDynamicType) { AppendText("dynamic", VsHighlightingAttributeIds.Keyword); return; } if (context.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(CSharpLanguage.Instance), null); } else AppendTypeElement(typeElement, declaredType.GetSubstitution(), expectedQualifierDisplay, context); }
private void AppendTypeElement([NotNull] ITypeElement typeElement, [NotNull] ISubstitution substitution, QualifierDisplays expectedQualifierDisplay, Context context) { if (!(typeElement is ITypeParameter) && (context.Options.ShowQualifiers & expectedQualifierDisplay) != QualifierDisplays.None) { AppendNamespace(typeElement.GetContainingNamespace()); AppendText(".", VsHighlightingAttributeIds.Operator); ITypeElement containingType = typeElement.GetContainingType(); if (containingType != null && !(typeElement is IDelegate && context.Options.FormatDelegatesAsLambdas)) { AppendDeclaredType(TypeFactory.CreateType(containingType, substitution), QualifierDisplays.None, context); AppendText(".", VsHighlightingAttributeIds.Operator); } } var deleg = typeElement as IDelegate; if (deleg != null && context.Options.FormatDelegatesAsLambdas && expectedQualifierDisplay == QualifierDisplays.Parameters) { AppendParameters(deleg.InvokeMethod, substitution, false, context); AppendText(" => ", VsHighlightingAttributeIds.Operator); AppendTypeWithoutModule(substitution.Apply(deleg.InvokeMethod.ReturnType), expectedQualifierDisplay, context); return; } string highlighterId = typeElement.GetHighlightingAttributeId(_useReSharperColors); AppendText(FormatShortName(typeElement.ShortName), highlighterId); AppendTypeParameters(typeElement, substitution, context); }
private void AppendPointerType([NotNull] IPointerType pointerType, QualifierDisplays expectedQualifierDisplay, Context context) { AppendTypeWithoutModule(pointerType.ElementType, expectedQualifierDisplay, context); AppendText("*", VsHighlightingAttributeIds.Operator); }
private void AppendElementType([NotNull] IDeclaredElement element, [NotNull] ISubstitution substitution, QualifierDisplays expectedQualifierDisplay, [CanBeNull] string before, [CanBeNull] string after, Context context) { // Use the special type first if available (eg Razor helper), colorize it as a keyword string specialTypeString = CSharpModificationUtil.GetSpecialElementType(_specialTypeStyle, element, substitution); if (!specialTypeString.IsEmpty()) { AppendText(before, null); AppendText(specialTypeString, VsHighlightingAttributeIds.Keyword); AppendText(after, null); return; } IType elementType = GetElementType(element, substitution); if (elementType == null) return; AppendText(before, null); AppendTypeWithoutModule(elementType, expectedQualifierDisplay, context); AppendText(after, null); }