diff --git a/csharp-impl/src/main/java/consulo/csharp/impl/ide/findUsage/CSharpFindUsagesProvider.java b/csharp-impl/src/main/java/consulo/csharp/impl/ide/findUsage/CSharpFindUsagesProvider.java index 405e9baf8..a425db069 100644 --- a/csharp-impl/src/main/java/consulo/csharp/impl/ide/findUsage/CSharpFindUsagesProvider.java +++ b/csharp-impl/src/main/java/consulo/csharp/impl/ide/findUsage/CSharpFindUsagesProvider.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package consulo.csharp.impl.ide.findUsage; import consulo.annotation.access.RequiredReadAction; @@ -37,211 +36,169 @@ import consulo.navigation.NavigationItem; import consulo.util.lang.StringUtil; - /** * @author VISTALL - * @since 21.12.13. + * @since 2013-12-21 */ @ExtensionImpl -public class CSharpFindUsagesProvider implements FindUsagesProvider -{ - @Override - public boolean canFindUsagesFor(PsiElement element) - { - return element instanceof DotNetNamedElement; - } - - @Override - @RequiredReadAction - public String getType(PsiElement element) - { - if(element instanceof CSharpTypeDeclaration) - { - return "type"; - } - else if(element instanceof CSharpLocalVariableDeclarationStatement) - { - return "local variable statement"; - } - else if(element instanceof CSharpConstructorDeclaration) - { - return ((CSharpConstructorDeclaration) element).isDeConstructor() ? "deconstructor" : "constructor"; - } - else if(element instanceof CSharpIndexMethodDeclaration) - { - return "index method"; - } - else if(element instanceof CSharpTupleVariable || element instanceof CSharpTupleElementImpl) - { - return "tuple variable"; - } - else if(element instanceof CSharpMethodDeclaration) - { - return "method"; - } - else if(element instanceof DotNetNamespaceAsElement) - { - return "namespace"; - } - else if(element instanceof CSharpEventDeclaration) - { - return "event"; - } - else if(element instanceof CSharpTypeDefStatement) - { - return "type alias"; - } - else if(element instanceof CSharpPropertyDeclaration) - { - return "property"; - } - else if(element instanceof CSharpLambdaParameter) - { - return "lambda parameter"; - } - else if(element instanceof DotNetParameter) - { - return "parameter"; - } - else if(element instanceof CSharpLocalVariable) - { - return "local variable"; - } - else if(element instanceof CSharpLinqVariable) - { - return "linq local variable"; - } - else if(element instanceof CSharpOutRefVariableImpl) - { - CSharpOutRefVariableExpressionImpl parent = (CSharpOutRefVariableExpressionImpl) element.getParent(); - return parent.getExpressionType() + " local variable"; - } - else if(element instanceof CSharpIsVariableImpl) - { - return "is variable"; - } - else if(element instanceof CSharpCaseVariableImpl) - { - return "case variable"; - } - else if(element instanceof DotNetGenericParameter) - { - return "generic parameter"; - } - else if(element instanceof CSharpFieldDeclaration) - { - return "field"; - } - else if(element instanceof CSharpEnumConstantDeclarationImpl) - { - return "enum constant"; - } - else if(element instanceof CSharpLabeledStatementImpl) - { - return "label"; - } - return debugText("getType", element); - } - - @Override - @RequiredReadAction - public String getDescriptiveName(PsiElement element) - { - if(element instanceof DotNetNamedElement) - { - String name = ((DotNetNamedElement) element).getName(); - return name == null ? "null" : name; - } - if(element instanceof CSharpLocalVariableDeclarationStatement) - { - return StringUtil.join(((CSharpLocalVariableDeclarationStatement) element).getVariables(), PsiNamedElement::getName, ", "); - } - return debugText("getDescriptiveName", element); - } - - @Override - @RequiredReadAction - public String getNodeText(PsiElement element, boolean useFullName) - { - if(element instanceof CSharpPreprocessorVariable) - { - return ((CSharpPreprocessorVariable) element).getName(); - } - - CSharpMethodDeclaration original = element.getUserData(CSharpResolveUtil.EXTENSION_METHOD_WRAPPER); - if(original != null) - { - return getNodeText(original, useFullName); - } - - DotNetQualifiedElement accessorValueVariableOwner = element.getUserData(CSharpResolveUtil.ACCESSOR_VALUE_VARIABLE_OWNER); - if(accessorValueVariableOwner != null) - { - return getNodeText(accessorValueVariableOwner, useFullName); - } - - if(element instanceof CSharpTypeDefStatement) - { - String name = ((CSharpTypeDefStatement) element).getName(); - - DotNetTypeRef dotNetTypeRef = ((CSharpTypeDefStatement) element).toTypeRef(); - - StringBuilder builder = new StringBuilder(); - builder.append(name); - - if(dotNetTypeRef != DotNetTypeRef.ERROR_TYPE) - { - builder.append(" = "); - builder.append(CSharpTypeRefPresentationUtil.buildText(dotNetTypeRef)); - } - return builder.toString(); - } - - ItemPresentation itemPresentation = ItemPresentationProvider.getItemPresentation((NavigationItem) element); - if(itemPresentation != null) - { - String presentableText = itemPresentation.getPresentableText(); - assert presentableText != null : element.getClass().getName(); - return presentableText; - } - - if(element instanceof DotNetVariable) - { - String name = ((DotNetVariable) element).getName(); - - DotNetTypeRef dotNetTypeRef = ((DotNetVariable) element).toTypeRef(false); - - StringBuilder builder = new StringBuilder(); - builder.append(CSharpTypeRefPresentationUtil.buildText(dotNetTypeRef)).append(" ").append(name); - return builder.toString(); - } - - if(element instanceof DotNetXAccessor) - { - PsiElement parent = element.getParent(); - - String nodeText = getNodeText(parent, useFullName); - PsiElement accessorElement = ((DotNetXAccessor) element).getAccessorElement(); - if(accessorElement == null) - { - return nodeText; - } - return nodeText + "." + accessorElement.getText(); - } - - return debugText("getNodeText", element); - } - - private String debugText(String prefix, PsiElement element) - { - IElementType type = PsiUtilCore.getElementType(element); - String suffix = type == null ? element.getClass().getSimpleName() : type.toString(); - return prefix + " : " + suffix; - } - - @Override - public Language getLanguage() - { - return CSharpLanguage.INSTANCE; - } +public class CSharpFindUsagesProvider implements FindUsagesProvider { + @Override + public boolean canFindUsagesFor(PsiElement element) { + return element instanceof DotNetNamedElement; + } + + @Override + @RequiredReadAction + public String getType(PsiElement element) { + if (element instanceof CSharpTypeDeclaration) { + return "type"; + } + else if (element instanceof CSharpLocalVariableDeclarationStatement) { + return "local variable statement"; + } + else if (element instanceof CSharpConstructorDeclaration) { + return ((CSharpConstructorDeclaration) element).isDeConstructor() ? "deconstructor" : "constructor"; + } + else if (element instanceof CSharpIndexMethodDeclaration) { + return "index method"; + } + else if (element instanceof CSharpTupleVariable || element instanceof CSharpTupleElementImpl) { + return "tuple variable"; + } + else if (element instanceof CSharpMethodDeclaration) { + return "method"; + } + else if (element instanceof DotNetNamespaceAsElement) { + return "namespace"; + } + else if (element instanceof CSharpEventDeclaration) { + return "event"; + } + else if (element instanceof CSharpTypeDefStatement) { + return "type alias"; + } + else if (element instanceof CSharpPropertyDeclaration) { + return "property"; + } + else if (element instanceof CSharpLambdaParameter) { + return "lambda parameter"; + } + else if (element instanceof DotNetParameter) { + return "parameter"; + } + else if (element instanceof CSharpLocalVariable) { + return "local variable"; + } + else if (element instanceof CSharpLinqVariable) { + return "linq local variable"; + } + else if (element instanceof CSharpOutRefVariableImpl) { + CSharpOutRefVariableExpressionImpl parent = (CSharpOutRefVariableExpressionImpl) element.getParent(); + return parent.getExpressionType() + " local variable"; + } + else if (element instanceof CSharpIsVariableImpl) { + return "is variable"; + } + else if (element instanceof CSharpCaseVariableImpl) { + return "case variable"; + } + else if (element instanceof DotNetGenericParameter) { + return "generic parameter"; + } + else if (element instanceof CSharpFieldDeclaration) { + return "field"; + } + else if (element instanceof CSharpEnumConstantDeclarationImpl) { + return "enum constant"; + } + else if (element instanceof CSharpLabeledStatementImpl) { + return "label"; + } + return debugText("getType", element); + } + + @Override + @RequiredReadAction + public String getDescriptiveName(PsiElement element) { + if (element instanceof DotNetNamedElement) { + String name = ((DotNetNamedElement) element).getName(); + return name == null ? "null" : name; + } + if (element instanceof CSharpLocalVariableDeclarationStatement) { + return StringUtil.join(((CSharpLocalVariableDeclarationStatement) element).getVariables(), PsiNamedElement::getName, ", "); + } + return debugText("getDescriptiveName", element); + } + + @Override + @RequiredReadAction + public String getNodeText(PsiElement element, boolean useFullName) { + if (element instanceof CSharpPreprocessorVariable preprocessorVar) { + return preprocessorVar.getName(); + } + + CSharpMethodDeclaration original = element.getUserData(CSharpResolveUtil.EXTENSION_METHOD_WRAPPER); + if (original != null) { + return getNodeText(original, useFullName); + } + + DotNetQualifiedElement accessorValueVariableOwner = element.getUserData(CSharpResolveUtil.ACCESSOR_VALUE_VARIABLE_OWNER); + if (accessorValueVariableOwner != null) { + return getNodeText(accessorValueVariableOwner, useFullName); + } + + if (element instanceof CSharpTypeDefStatement typeDef) { + String name = typeDef.getName(); + + DotNetTypeRef dotNetTypeRef = typeDef.toTypeRef(); + + StringBuilder builder = new StringBuilder(); + builder.append(name); + + if (dotNetTypeRef != DotNetTypeRef.ERROR_TYPE) { + builder.append(" = "); + builder.append(CSharpTypeRefPresentationUtil.buildText(dotNetTypeRef)); + } + return builder.toString(); + } + + ItemPresentation itemPresentation = ItemPresentationProvider.getItemPresentation((NavigationItem) element); + if (itemPresentation != null) { + return itemPresentation.getPresentableText().get(); + } + + if (element instanceof DotNetVariable dotNetVar) { + String name = dotNetVar.getName(); + + DotNetTypeRef dotNetTypeRef = dotNetVar.toTypeRef(false); + + StringBuilder builder = new StringBuilder(); + builder.append(CSharpTypeRefPresentationUtil.buildText(dotNetTypeRef)).append(" ").append(name); + return builder.toString(); + } + + if (element instanceof DotNetXAccessor xAccessor) { + PsiElement parent = element.getParent(); + + String nodeText = getNodeText(parent, useFullName); + PsiElement accessorElement = xAccessor.getAccessorElement(); + if (accessorElement == null) { + return nodeText; + } + return nodeText + "." + accessorElement.getText(); + } + + return debugText("getNodeText", element); + } + + private String debugText(String prefix, PsiElement element) { + IElementType type = PsiUtilCore.getElementType(element); + String suffix = type == null ? element.getClass().getSimpleName() : type.toString(); + return prefix + " : " + suffix; + } + + @Override + public Language getLanguage() { + return CSharpLanguage.INSTANCE; + } } diff --git a/csharp-impl/src/main/java/consulo/csharp/impl/ide/presentation/CSharpElementPresentationProviderBase.java b/csharp-impl/src/main/java/consulo/csharp/impl/ide/presentation/CSharpElementPresentationProviderBase.java index edc01ddd5..b207b1de7 100644 --- a/csharp-impl/src/main/java/consulo/csharp/impl/ide/presentation/CSharpElementPresentationProviderBase.java +++ b/csharp-impl/src/main/java/consulo/csharp/impl/ide/presentation/CSharpElementPresentationProviderBase.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package consulo.csharp.impl.ide.presentation; +import consulo.annotation.access.RequiredReadAction; import consulo.component.util.Iconable; import consulo.csharp.impl.ide.CSharpElementPresentationUtil; import consulo.csharp.lang.psi.CSharpConstructorDeclaration; @@ -23,6 +23,7 @@ import consulo.csharp.lang.psi.CSharpMethodDeclaration; import consulo.dotnet.psi.*; import consulo.language.icon.IconDescriptorUpdaters; +import consulo.localize.LocalizeValue; import consulo.navigation.ItemPresentation; import consulo.navigation.ItemPresentationProvider; import consulo.navigation.NavigationItem; @@ -34,71 +35,58 @@ /** * @author VISTALL - * @since 21.12.13. + * @since 2013-12-21 */ -public abstract class CSharpElementPresentationProviderBase implements ItemPresentationProvider -{ - public static class ItemPresentationImpl implements ItemPresentation - { - private final DotNetQualifiedElement myDeclaration; +public abstract class CSharpElementPresentationProviderBase implements ItemPresentationProvider { + public static class ItemPresentationImpl implements ItemPresentation { + private final DotNetQualifiedElement myDeclaration; - public ItemPresentationImpl(DotNetQualifiedElement declaration) - { - myDeclaration = declaration; - } + public ItemPresentationImpl(DotNetQualifiedElement declaration) { + myDeclaration = declaration; + } - @Nullable - @Override - @RequiredUIAccess - public String getPresentableText() - { - if(myDeclaration instanceof DotNetTypeDeclaration) - { - return DotNetElementPresentationUtil.formatTypeWithGenericParameters((DotNetTypeDeclaration) myDeclaration); - } - else if(myDeclaration instanceof DotNetMethodDeclaration) - { - if(myDeclaration instanceof CSharpMethodDeclaration && ((CSharpMethodDeclaration) myDeclaration).isDelegate()) - { - return DotNetElementPresentationUtil.formatTypeWithGenericParameters((CSharpMethodDeclaration) myDeclaration); - } - return CSharpElementPresentationUtil.formatMethod((DotNetLikeMethodDeclaration) myDeclaration, 0); - } - else if(myDeclaration instanceof CSharpConstructorDeclaration) - { - return CSharpElementPresentationUtil.formatMethod((CSharpConstructorDeclaration) myDeclaration, 0); - } - else if(myDeclaration instanceof CSharpIndexMethodDeclaration) - { - return CSharpElementPresentationUtil.formatMethod((DotNetLikeMethodDeclaration) myDeclaration, 0); - } - return myDeclaration.getName(); - } + @Override + @RequiredReadAction + public LocalizeValue getPresentableText() { + if (myDeclaration instanceof DotNetTypeDeclaration typeDecl) { + return LocalizeValue.of(DotNetElementPresentationUtil.formatTypeWithGenericParameters(typeDecl)); + } + else if (myDeclaration instanceof DotNetMethodDeclaration dotNetMethodDecl) { + if (myDeclaration instanceof CSharpMethodDeclaration methodDecl && methodDecl.isDelegate()) { + return LocalizeValue.of(DotNetElementPresentationUtil.formatTypeWithGenericParameters(methodDecl)); + } + return LocalizeValue.of(CSharpElementPresentationUtil.formatMethod(dotNetMethodDecl, 0)); + } + else if (myDeclaration instanceof CSharpConstructorDeclaration constructorDecl) { + return LocalizeValue.of(CSharpElementPresentationUtil.formatMethod(constructorDecl, 0)); + } + else if (myDeclaration instanceof CSharpIndexMethodDeclaration indexMethodDecl) { + return LocalizeValue.of(CSharpElementPresentationUtil.formatMethod(indexMethodDecl, 0)); + } + return LocalizeValue.ofNullable(myDeclaration.getName()); + } - @Nullable - @Override - @RequiredUIAccess - public String getLocationString() - { - String presentableParentQName = myDeclaration.getPresentableParentQName(); - if(StringUtil.isEmpty(presentableParentQName)) - { - return null; - } - return "(" + presentableParentQName + ")"; - } + @Nullable + @Override + @RequiredUIAccess + public String getLocationString() { + String presentableParentQName = myDeclaration.getPresentableParentQName(); + if (StringUtil.isEmpty(presentableParentQName)) { + return null; + } + return "(" + presentableParentQName + ")"; + } - @Nullable - @Override - public Image getIcon() - { - return IconDescriptorUpdaters.getIcon(myDeclaration, Iconable.ICON_FLAG_VISIBILITY); - } - } + @Nullable + @Override + @RequiredReadAction + public Image getIcon() { + return IconDescriptorUpdaters.getIcon(myDeclaration, Iconable.ICON_FLAG_VISIBILITY); + } + } - @Override - public ItemPresentation getPresentation(T qualifiedElement) - { - return new ItemPresentationImpl(qualifiedElement); - } + @Override + public ItemPresentation getPresentation(T qualifiedElement) { + return new ItemPresentationImpl(qualifiedElement); + } } diff --git a/csharp-impl/src/main/java/consulo/csharp/impl/ide/refactoring/rename/CSharpElementDescriptionProvider.java b/csharp-impl/src/main/java/consulo/csharp/impl/ide/refactoring/rename/CSharpElementDescriptionProvider.java index fbcf7e828..0dad2c8f9 100644 --- a/csharp-impl/src/main/java/consulo/csharp/impl/ide/refactoring/rename/CSharpElementDescriptionProvider.java +++ b/csharp-impl/src/main/java/consulo/csharp/impl/ide/refactoring/rename/CSharpElementDescriptionProvider.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package consulo.csharp.impl.ide.refactoring.rename; import consulo.annotation.access.RequiredReadAction; @@ -22,25 +21,21 @@ import consulo.language.psi.ElementDescriptionLocation; import consulo.language.psi.ElementDescriptionProvider; import consulo.language.psi.PsiElement; +import consulo.localize.LocalizeValue; import consulo.usage.UsageViewShortNameLocation; -import org.jspecify.annotations.Nullable; /** * @author VISTALL - * @since 14-Nov-17 + * @since 2017-11-14 */ @ExtensionImpl -public class CSharpElementDescriptionProvider implements ElementDescriptionProvider -{ - @Nullable - @Override - @RequiredReadAction - public String getElementDescription(PsiElement element, ElementDescriptionLocation location) - { - if(location == UsageViewShortNameLocation.INSTANCE && element instanceof CSharpNamedElement) - { - return ((CSharpNamedElement) element).getNameWithAt(); - } - return null; - } +public class CSharpElementDescriptionProvider implements ElementDescriptionProvider { + @Override + @RequiredReadAction + public LocalizeValue getElementDescription(PsiElement element, ElementDescriptionLocation location) { + if (location == UsageViewShortNameLocation.INSTANCE && element instanceof CSharpNamedElement named) { + return LocalizeValue.ofNullable(named.getNameWithAt()); + } + return LocalizeValue.empty(); + } } diff --git a/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpLambdaTreeElement.java b/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpLambdaTreeElement.java index e4fec5bd3..08715d993 100644 --- a/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpLambdaTreeElement.java +++ b/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpLambdaTreeElement.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package consulo.csharp.impl.ide.structureView; -import consulo.application.AllIcons; +import consulo.annotation.access.RequiredReadAction; import consulo.language.editor.structureView.PsiTreeElementBase; import consulo.csharp.lang.impl.psi.source.CSharpAnonymousMethodExpression; import consulo.csharp.lang.impl.psi.source.CSharpDelegateExpressionImpl; import consulo.fileEditor.structureView.StructureViewTreeElement; +import consulo.localize.LocalizeValue; +import consulo.platform.base.icon.PlatformIconGroup; import consulo.ui.image.Image; -import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.Collections; @@ -31,34 +31,28 @@ * @author VISTALL * @since 2020-06-28 */ -public class CSharpLambdaTreeElement extends PsiTreeElementBase -{ - public CSharpLambdaTreeElement(CSharpAnonymousMethodExpression psiElement) - { - super(psiElement); - } +public class CSharpLambdaTreeElement extends PsiTreeElementBase { + public CSharpLambdaTreeElement(CSharpAnonymousMethodExpression psiElement) { + super(psiElement); + } - @Override - public Collection getChildrenBase() - { - return Collections.emptyList(); - } + @Override + public Collection getChildrenBase() { + return Collections.emptyList(); + } - @Override - public Image getIcon() - { - return AllIcons.Nodes.Lambda; - } + @Override + public Image getIcon() { + return PlatformIconGroup.nodesLambda(); + } - @Nullable - @Override - public String getPresentableText() - { - CSharpAnonymousMethodExpression value = getValue(); - if(value instanceof CSharpDelegateExpressionImpl) - { - return "Delegate"; - } - return "Lambda"; - } + @Override + @RequiredReadAction + public LocalizeValue getPresentableText() { + CSharpAnonymousMethodExpression value = getValue(); + if (value instanceof CSharpDelegateExpressionImpl) { + return LocalizeValue.localizeTODO("Delegate"); + } + return LocalizeValue.localizeTODO("Lambda"); + } } diff --git a/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpNamedTreeElement.java b/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpNamedTreeElement.java index a06e6fe0c..c51963986 100644 --- a/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpNamedTreeElement.java +++ b/csharp-impl/src/main/java/consulo/csharp/impl/ide/structureView/CSharpNamedTreeElement.java @@ -13,76 +13,70 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package consulo.csharp.impl.ide.structureView; +import consulo.annotation.access.RequiredReadAction; import consulo.csharp.impl.ide.CSharpElementPresentationUtil; import consulo.dotnet.psi.*; import consulo.fileEditor.structureView.StructureViewTreeElement; import consulo.language.editor.structureView.PsiTreeElementBase; import consulo.language.psi.PsiElement; import consulo.language.psi.PsiNamedElement; +import consulo.localize.LocalizeValue; import consulo.ui.annotation.RequiredUIAccess; -import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * @author VISTALL - * @since 31.12.13. + * @since 2013-12-31 */ -public class CSharpNamedTreeElement extends PsiTreeElementBase -{ - public CSharpNamedTreeElement(PsiNamedElement psiElement) - { - super(psiElement); - } +public class CSharpNamedTreeElement extends PsiTreeElementBase { + public CSharpNamedTreeElement(PsiNamedElement psiElement) { + super(psiElement); + } - @Override - public Collection getChildrenBase() - { - List list = new ArrayList<>(); - for(PsiElement psiElement : getValue().getChildren()) - { - if(psiElement instanceof DotNetQualifiedElement) - { - list.add(new CSharpNamedTreeElement((DotNetQualifiedElement) psiElement)); - } - } - return list; - } + @Override + @RequiredReadAction + public Collection getChildrenBase() { + List list = new ArrayList<>(); + for (PsiElement psiElement : getValue().getChildren()) { + if (psiElement instanceof DotNetQualifiedElement qElem) { + list.add(new CSharpNamedTreeElement(qElem)); + } + } + return list; + } - @Nullable - @Override - @RequiredUIAccess - public String getPresentableText() - { - PsiNamedElement value = getValue(); - if(value instanceof DotNetLikeMethodDeclaration) - { - return CSharpElementPresentationUtil.formatMethod((DotNetLikeMethodDeclaration) value, CSharpElementPresentationUtil.METHOD_SCALA_LIKE_FULL); - } - else if(value instanceof DotNetTypeDeclaration) - { - return DotNetElementPresentationUtil.formatTypeWithGenericParameters((DotNetTypeDeclaration)value); - } - else if(value instanceof DotNetFieldDeclaration) - { - return CSharpElementPresentationUtil.formatField((DotNetFieldDeclaration) value); - } - else if(value instanceof DotNetPropertyDeclaration) - { - return CSharpElementPresentationUtil.formatProperty((DotNetPropertyDeclaration) value, CSharpElementPresentationUtil.PROPERTY_SCALA_LIKE_FULL); - } - else if(value instanceof DotNetNamespaceDeclaration) - { - return ((DotNetNamespaceDeclaration) value).getPresentableQName(); - } - else - { - return value.getName(); - } - } + @Override + @RequiredReadAction + public LocalizeValue getPresentableText() { + PsiNamedElement value = getValue(); + if (value instanceof DotNetLikeMethodDeclaration methodDecl) { + return LocalizeValue.of(CSharpElementPresentationUtil.formatMethod( + methodDecl, + CSharpElementPresentationUtil.METHOD_SCALA_LIKE_FULL + )); + } + else if (value instanceof DotNetTypeDeclaration typeDecl) { + return LocalizeValue.of(DotNetElementPresentationUtil.formatTypeWithGenericParameters(typeDecl)); + } + else if (value instanceof DotNetFieldDeclaration fieldDecl) { + return LocalizeValue.of(CSharpElementPresentationUtil.formatField(fieldDecl)); + } + else if (value instanceof DotNetPropertyDeclaration propDecl) { + return LocalizeValue.of(CSharpElementPresentationUtil.formatProperty( + propDecl, + CSharpElementPresentationUtil.PROPERTY_SCALA_LIKE_FULL + )); + } + else if (value instanceof DotNetNamespaceDeclaration nsDecl) { + return LocalizeValue.ofNullable(nsDecl.getPresentableQName()); + } + else { + return LocalizeValue.ofNullable(value.getName()); + } + } } diff --git a/csharp-spellchecker/pom.xml b/csharp-spellchecker/pom.xml index 4c4b36356..2b2c00933 100644 --- a/csharp-spellchecker/pom.xml +++ b/csharp-spellchecker/pom.xml @@ -1,6 +1,4 @@ - - - - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - consulo + + consulo arch.bind.java 3-SNAPSHOT - - + + - - - consulo - https://maven.consulo.dev/repository/snapshots/ - - true - interval:60 - - - + + + consulo + https://maven.consulo.dev/repository/snapshots/ + + true + interval:60 + + + - consulo.plugin - consulo.csharp-csharp.spellchecker - 3-SNAPSHOT - jar + consulo.plugin + consulo.csharp-csharp.spellchecker + 3-SNAPSHOT + jar - - - ${project.groupId} - consulo.csharp-csharp.psi.impl - ${project.version} - - - ${project.groupId} + + + ${project.groupId} + consulo.csharp-csharp.psi.impl + ${project.version} + + + ${project.groupId} consulo.dotnet-dotnet.psi.impl ${project.version} - provided - - + provided + + \ No newline at end of file