From d9bc116d0d65f2bf7a5d2e8a1814ffb66c5315ac Mon Sep 17 00:00:00 2001 From: UNV Date: Mon, 12 Oct 2026 18:01:45 +0300 Subject: [PATCH] Fixing compilation errors after platform localization. Some refactoring. --- .../PasModuleStructureTreeElement.java | 34 +-- .../PasStructStructureTreeElement.java | 56 ++-- .../PasStructureViewTreeElement.java | 56 ++-- .../pascal/lang/parser/PascalParserUtil.java | 283 +++++++++++------- 4 files changed, 253 insertions(+), 176 deletions(-) diff --git a/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasModuleStructureTreeElement.java b/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasModuleStructureTreeElement.java index 6c3e70d3..7eee9fc9 100644 --- a/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasModuleStructureTreeElement.java +++ b/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasModuleStructureTreeElement.java @@ -1,19 +1,21 @@ package com.siberika.idea.pascal.editor.structure; -import com.siberika.idea.pascal.PascalIcons; import com.siberika.idea.pascal.lang.psi.PasModule; +import consulo.annotation.access.RequiredReadAction; import consulo.fileEditor.structureView.StructureViewTreeElement; import consulo.language.editor.structureView.PsiTreeElementBase; +import consulo.localize.LocalizeValue; +import consulo.object.pascal.icon.ObjectPascalIconGroup; import consulo.ui.image.Image; import consulo.util.lang.StringUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; /** - * Author: George Bakhtadze - * Date: 06/05/2015 + * @author George Bakhtadze + * @since 2015-05-06 */ public class PasModuleStructureTreeElement extends PsiTreeElementBase { protected PasModuleStructureTreeElement(PasModule psiElement) { @@ -22,33 +24,31 @@ protected PasModuleStructureTreeElement(PasModule psiElement) { @NotNull @Override + @RequiredReadAction public Collection getChildrenBase() { return PasStructureViewTreeElement.collectChildren(getElement()); } @Override - public Image getIcon() { + @RequiredReadAction + public @Nullable Image getIcon() { if (getElement() != null) { - switch (getElement().getModuleType()) { - case PACKAGE: - case LIBRARY: - return PascalIcons.FILE_LIBRARY; - case PROGRAM: - return PascalIcons.FILE_PROGRAM; - case UNIT: - return PascalIcons.UNIT; - } + return switch (getElement().getModuleType()) { + case PACKAGE, LIBRARY -> ObjectPascalIconGroup.library(); + case PROGRAM -> ObjectPascalIconGroup.program(); + case UNIT -> ObjectPascalIconGroup.unit(); + }; } return null; } - @Nullable @Override - public String getPresentableText() { + @RequiredReadAction + public LocalizeValue getPresentableText() { String name = getElement() != null ? getElement().getName() : "-"; if (StringUtil.isEmpty(name)) { name = getElement().getContainingFile().getName(); } - return name; + return LocalizeValue.of(name); } } diff --git a/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructStructureTreeElement.java b/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructStructureTreeElement.java index 9fab80b4..b6ab6e18 100644 --- a/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructStructureTreeElement.java +++ b/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructStructureTreeElement.java @@ -1,20 +1,22 @@ package com.siberika.idea.pascal.editor.structure; -import com.siberika.idea.pascal.PascalIcons; import com.siberika.idea.pascal.lang.psi.*; import com.siberika.idea.pascal.lang.psi.impl.PasField; import com.siberika.idea.pascal.util.PsiUtil; +import consulo.annotation.access.RequiredReadAction; import consulo.fileEditor.structureView.StructureViewTreeElement; import consulo.language.editor.structureView.PsiTreeElementBase; +import consulo.localize.LocalizeValue; +import consulo.object.pascal.icon.ObjectPascalIconGroup; +import consulo.platform.base.icon.PlatformIconGroup; import consulo.ui.image.Image; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.Collection; /** - * Author: George Bakhtadze - * Date: 06/05/2015 + * @author George Bakhtadze + * @since 2015-05-06 */ public class PasStructStructureTreeElement extends PsiTreeElementBase { protected PasStructStructureTreeElement(PascalStructType psiElement) { @@ -23,33 +25,28 @@ protected PasStructStructureTreeElement(PascalStructType psiElement) { @NotNull @Override + @RequiredReadAction public Collection getChildrenBase() { return PasStructureViewTreeElement.collectChildren(getElement()); } @Override + @RequiredReadAction public Image getIcon() { - if (getElement() != null) { - PascalStructType el = getElement(); - if (el instanceof PasInterfaceTypeDecl) { - return PascalIcons.INTERFACE; - } else if (el instanceof PasClassTypeDecl) { - return PascalIcons.CLASS; - } else if (el instanceof PasObjectDecl) { - return PascalIcons.OBJECT; - } else if (el instanceof PasRecordDecl) { - return PascalIcons.RECORD; - } else if ((el instanceof PasClassHelperDecl) || (el instanceof PasRecordHelperDecl)) { - return PascalIcons.HELPER; - } - } - return null; + return switch (getElement()) { + case PasInterfaceTypeDecl _ -> PlatformIconGroup.nodesInterface(); + case PasClassTypeDecl _ -> PlatformIconGroup.nodesClass(); + case PasObjectDecl _ -> PlatformIconGroup.nodesAnonymousclass(); + case PasRecordDecl _ -> PlatformIconGroup.nodesRecord(); + case PasClassHelperDecl _, PasRecordHelperDecl _ -> ObjectPascalIconGroup.helper(); + case null, default -> null; + }; } - @Nullable @Override - public String getPresentableText() { - return getElement() != null ? getElement().getName() : "-"; + @RequiredReadAction + public LocalizeValue getPresentableText() { + return getElement() != null ? LocalizeValue.of(getElement().getName()) : LocalizeValue.localizeTODO("-"); } public static PascalStructType getStructElement(PasField field) { @@ -57,15 +54,20 @@ public static PascalStructType getStructElement(PasField field) { if (typeDecl != null) { if (typeDecl.getInterfaceTypeDecl() != null) { return typeDecl.getInterfaceTypeDecl(); - } if (typeDecl.getClassTypeDecl() != null) { + } + if (typeDecl.getClassTypeDecl() != null) { return typeDecl.getClassTypeDecl(); - } if (typeDecl.getObjectDecl() != null) { + } + if (typeDecl.getObjectDecl() != null) { return typeDecl.getObjectDecl(); - } if (typeDecl.getRecordDecl() != null) { + } + if (typeDecl.getRecordDecl() != null) { return typeDecl.getRecordDecl(); - } if (typeDecl.getClassHelperDecl() != null) { + } + if (typeDecl.getClassHelperDecl() != null) { return typeDecl.getClassHelperDecl(); - } if (typeDecl.getRecordHelperDecl() != null) { + } + if (typeDecl.getRecordHelperDecl() != null) { return typeDecl.getRecordHelperDecl(); } } diff --git a/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructureViewTreeElement.java b/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructureViewTreeElement.java index a3013820..60a234fa 100644 --- a/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructureViewTreeElement.java +++ b/pascal/src/main/java/com/siberika/idea/pascal/editor/structure/PasStructureViewTreeElement.java @@ -1,15 +1,17 @@ package com.siberika.idea.pascal.editor.structure; -import com.siberika.idea.pascal.PascalIcons; import com.siberika.idea.pascal.lang.psi.PasEntityScope; import com.siberika.idea.pascal.lang.psi.PascalNamedElement; import com.siberika.idea.pascal.lang.psi.PascalStructType; import com.siberika.idea.pascal.lang.psi.impl.PasField; import com.siberika.idea.pascal.util.PsiUtil; +import consulo.annotation.access.RequiredReadAction; import consulo.fileEditor.structureView.StructureViewTreeElement; import consulo.language.editor.structureView.PsiTreeElementBase; import consulo.language.psi.PsiElement; import consulo.language.psi.PsiFile; +import consulo.localize.LocalizeValue; +import consulo.platform.base.icon.PlatformIconGroup; import consulo.ui.image.Image; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,11 +21,12 @@ import java.util.Collections; /** - * Author: George Bakhtadze - * Date: 16/09/2013 + * @author George Bakhtadze + * @since 2013-09-16 */ public class PasStructureViewTreeElement extends PsiTreeElementBase implements StructureViewTreeElement { private final PasField field; + protected PasStructureViewTreeElement(PsiElement psiElement, PasField field) { super(field != null ? field.getElement() : psiElement); this.field = field; @@ -48,10 +51,12 @@ public static Collection collectChildren(@Nullable Pas PascalStructType structType = PasStructStructureTreeElement.getStructElement(field); if (structType != null) { res.add(new PasStructStructureTreeElement(structType)); - } else { + } + else { res.add(new PasStructureViewTreeElement(field.getElement(), field)); } - } else { + } + else { res.add(new PasStructureViewTreeElement(field.getElement(), field)); } } @@ -64,34 +69,35 @@ public PasField getField() { } @Override + @RequiredReadAction public Image getIcon() { if (field != null) { if (field.fieldType == PasField.FieldType.VARIABLE) { - return PascalIcons.VARIABLE; - } else if (field.fieldType == PasField.FieldType.CONSTANT) { - return PascalIcons.CONSTANT; - } else if (field.fieldType == PasField.FieldType.TYPE) { - return PascalIcons.TYPE; - } else if (field.fieldType == PasField.FieldType.PROPERTY) { - return PascalIcons.PROPERTY; - } else if (field.fieldType == PasField.FieldType.ROUTINE) { - return PascalIcons.ROUTINE; + return PlatformIconGroup.nodesVariable(); + } + else if (field.fieldType == PasField.FieldType.CONSTANT) { + return PlatformIconGroup.nodesConstant(); + } + else if (field.fieldType == PasField.FieldType.TYPE) { + return PlatformIconGroup.nodesType(); + } + else if (field.fieldType == PasField.FieldType.PROPERTY) { + return PlatformIconGroup.nodesProperty(); + } + else if (field.fieldType == PasField.FieldType.ROUTINE) { + return PlatformIconGroup.nodesFunction(); } } return super.getIcon(); } - @Nullable @Override - public String getPresentableText() { - PsiElement element = getElement(); - if (element instanceof PascalNamedElement) { - return PsiUtil.getFieldName((PascalNamedElement) element); - } else if (element instanceof PsiFile) { - return ((PsiFile) element).getName(); - } else { - return "-"; - } + @RequiredReadAction + public LocalizeValue getPresentableText() { + return switch (getElement()) { + case PascalNamedElement namedElem -> LocalizeValue.of(PsiUtil.getFieldName(namedElem)); + case PsiFile file -> LocalizeValue.of(file.getName()); + case null, default -> LocalizeValue.localizeTODO("-"); + }; } - } diff --git a/pascal/src/main/java/com/siberika/idea/pascal/lang/parser/PascalParserUtil.java b/pascal/src/main/java/com/siberika/idea/pascal/lang/parser/PascalParserUtil.java index a09fb132..e09d5208 100644 --- a/pascal/src/main/java/com/siberika/idea/pascal/lang/parser/PascalParserUtil.java +++ b/pascal/src/main/java/com/siberika/idea/pascal/lang/parser/PascalParserUtil.java @@ -1,6 +1,5 @@ package com.siberika.idea.pascal.lang.parser; -import com.siberika.idea.pascal.PascalIcons; import com.siberika.idea.pascal.PascalRTException; import com.siberika.idea.pascal.lang.compiled.CompiledFileImpl; import com.siberika.idea.pascal.lang.psi.*; @@ -11,27 +10,30 @@ import com.siberika.idea.pascal.lang.stub.PasIdentStub; import com.siberika.idea.pascal.sdk.BuiltinsParser; import com.siberika.idea.pascal.util.PsiUtil; +import consulo.annotation.access.RequiredReadAction; import consulo.language.impl.parser.GeneratedParserUtilBase; import consulo.language.parser.PsiBuilder; import consulo.language.psi.PsiElement; import consulo.language.psi.PsiFile; import consulo.language.psi.util.PsiTreeUtil; -import consulo.language.util.ModuleUtilCore; +import consulo.localize.LocalizeValue; import consulo.logging.Logger; import consulo.module.Module; import consulo.navigation.ItemPresentation; +import consulo.object.pascal.icon.ObjectPascalIconGroup; +import consulo.platform.base.icon.PlatformIconGroup; import consulo.project.Project; import consulo.ui.image.Image; import consulo.util.lang.StringUtil; import consulo.virtualFileSystem.VirtualFile; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; /** - * Author: George Bakhtadze - * Date: 12/9/12 + * @author George Bakhtadze + * @since 2012-12-09 */ @SuppressWarnings("unchecked") public class PascalParserUtil extends GeneratedParserUtilBase { @@ -49,7 +51,8 @@ public static boolean parsePascal(PsiBuilder builder_, int level, Parser parser) if (!name.startsWith("test") && !name.startsWith("$")) { // throw new PascalRTException("===*** Parse: " + name); } - } catch (PascalRTException e) { + } + catch (PascalRTException e) { // e.printStackTrace(); // System.out.println(e.getMessage()); } @@ -65,9 +68,17 @@ private static boolean isSameAffectingScope(PsiElement innerSection, PsiElement if (innerSection == outerSection) { return true; } - if ((null == innerSection) || PsiUtil.isInstanceOfAny(innerSection, - PasClassTypeDecl.class, PasClassHelperDecl.class, PasInterfaceTypeDecl.class, PasObjectDecl.class, PasRecordDecl.class, PasRecordHelperDecl.class, - PasClosureExpr.class, PascalRoutine.class)) { + if ((null == innerSection) || PsiUtil.isInstanceOfAny( + innerSection, + PasClassTypeDecl.class, + PasClassHelperDecl.class, + PasInterfaceTypeDecl.class, + PasObjectDecl.class, + PasRecordDecl.class, + PasRecordHelperDecl.class, + PasClosureExpr.class, + PascalRoutine.class + )) { return false; } innerSection = PsiUtil.getNearestAffectingDeclarationsRoot(innerSection); @@ -77,13 +88,15 @@ private static boolean isSameAffectingScope(PsiElement innerSection, PsiElement /** * add used unit interface declarations to result - * @param result list of declarations to add unit declarations to + * + * @param result list of declarations to add unit declarations to * @param current element which should be affected by a unit declaration in order to be added to result */ + @RequiredReadAction @SuppressWarnings("ConstantConditions") private static void addUsedUnitDeclarations(Collection result, PsiElement current, String name) { PsiFile file = current.getContainingFile(); - Module module = ModuleUtilCore.findModuleForPsiElement(current); + Module module = current.getModule(); List unitFiles = PasReferenceUtil.findUnitFiles(current.getProject(), module); for (PascalQualifiedIdent usedUnitName : PsiUtil.getUsedUnits(PsiUtil.getModuleInterfaceUsesClause(file))) { addUnitDeclarations(result, current.getProject(), unitFiles, usedUnitName.getName(), name); @@ -96,7 +109,14 @@ private static void addUsedUnitDeclarations(Collection resul } } - private static void addUnitDeclarations(Collection result, Project project, List unitFiles, String unitName, String name) { + @RequiredReadAction + private static void addUnitDeclarations( + Collection result, + Project project, + List unitFiles, + String unitName, + String name + ) { PascalNamedElement usedUnit = PasReferenceUtil.findUnit(project, unitFiles, unitName); if (usedUnit != null) { addDeclarations(result, PsiUtil.getModuleInterfaceSection(usedUnit), name); @@ -105,29 +125,40 @@ private static void addUnitDeclarations(Collection result, P /** * Add all declarations of entities with matching names from the specified section to result - * @param result list of declarations to add declarations to + * + * @param result list of declarations to add declarations to * @param section section containing declarations - * @param name name which a declaration should match + * @param name name which a declaration should match */ + @RequiredReadAction private static void addDeclarations(Collection result, PsiElement section, String name) { if (section != null) { - result.addAll(retrieveEntitiesFromSection(section, name, getEndOffset(section), - PasNamedIdent.class, PasNamedIdentDecl.class, PasGenericTypeIdent.class, PasNamespaceIdent.class)); + result.addAll(retrieveEntitiesFromSection( + section, + name, + getEndOffset(section), + PasNamedIdent.class, + PasNamedIdentDecl.class, + PasGenericTypeIdent.class, + PasNamespaceIdent.class + )); } } + @RequiredReadAction private static int getEndOffset(PsiElement section) { return section != null ? section.getTextRange().getEndOffset() : -1; } /** * Returns type scope from type declaration in type section - * @param typeIdent name of declaring type - * @param recursionCount to prevent infinite recursion - * @return scope if type is structured + * + * @param typeIdent name of declaring type + * @param recursionCount to prevent infinite recursion + * @return scope if type is structured */ - @Nullable - public static PasEntityScope getStructTypeByIdent(@NotNull PascalNamedElement typeIdent, int recursionCount) { + @RequiredReadAction + public static @Nullable PasEntityScope getStructTypeByIdent(@NotNull PascalNamedElement typeIdent, int recursionCount) { if (recursionCount > MAX_STRUCT_TYPE_RESOLVE_RECURSION) { return PsiUtil.getElementPasModule(typeIdent); } @@ -142,7 +173,8 @@ public static PasEntityScope getStructTypeByIdent(@NotNull PascalNamedElement ty PasEntityScope strucTypeDecl = PsiTreeUtil.findChildOfType(typeDecl, PasEntityScope.class, true); if (strucTypeDecl != null) { // structured type return strucTypeDecl; - } else { // regular type + } + else { // regular type PasFullyQualifiedIdent typeId = PsiTreeUtil.findChildOfType(typeDecl, PasFullyQualifiedIdent.class, true); return getStructTypeByTypeIdent(typeId, recursionCount); } @@ -150,12 +182,12 @@ public static PasEntityScope getStructTypeByIdent(@NotNull PascalNamedElement ty return null; } - @Nullable - private static PasEntityScope getStructTypeByTypeIdent(@Nullable PascalQualifiedIdent typeId, int recursionCount) { + @RequiredReadAction + private static @Nullable PasEntityScope getStructTypeByTypeIdent(@Nullable PascalQualifiedIdent typeId, int recursionCount) { if (typeId != null) { PsiElement section = PsiUtil.getNearestAffectingDeclarationsRoot(typeId); - Collection entities = retrieveEntitiesFromSection(section, typeId.getName(), - getEndOffset(section), PasGenericTypeIdent.class); + Collection entities = + retrieveEntitiesFromSection(section, typeId.getName(), getEndOffset(section), PasGenericTypeIdent.class); addUsedUnitDeclarations(entities, typeId, typeId.getName()); for (PascalNamedElement element : entities) { return getStructTypeByIdent(element, recursionCount + 1); @@ -165,12 +197,19 @@ private static PasEntityScope getStructTypeByTypeIdent(@Nullable PascalQualified } @NotNull - private static Collection retrieveEntitiesFromSection(PsiElement section, String key, int maxOffset, Class...classes) { - final Set result = new LinkedHashSet(); + @RequiredReadAction + private static Collection retrieveEntitiesFromSection( + PsiElement section, + String key, + int maxOffset, + Class... classes + ) { + final Set result = new LinkedHashSet<>(); if (section != null) { for (PascalNamedElement namedElement : PsiTreeUtil.findChildrenOfAnyType(section, classes)) { - if (((null == key) || key.equalsIgnoreCase(namedElement.getName()))) { - if ((namedElement.getTextRange().getStartOffset() < maxOffset) && isSameAffectingScope(PsiUtil.getNearestAffectingDeclarationsRoot(namedElement), section)) { + if (null == key || key.equalsIgnoreCase(namedElement.getName())) { + if (namedElement.getTextRange().getStartOffset() < maxOffset + && isSameAffectingScope(PsiUtil.getNearestAffectingDeclarationsRoot(namedElement), section)) { result.remove(namedElement); result.add(namedElement); } @@ -183,113 +222,143 @@ private static Collection ret public static ItemPresentation getPresentation(final PascalNamedElement element) { return new ItemPresentation() { - @Nullable @Override - public String getPresentableText() { - if ((element instanceof PascalRoutine) && (isASTAvailable(element))) { - return element.getText(); + @RequiredReadAction + public LocalizeValue getPresentableText() { + if (element instanceof PascalRoutine && isASTAvailable(element)) { + return LocalizeValue.of(element.getText()); } String typeString = ""; - if (element instanceof PascalIdentDecl) { - typeString = ((PascalIdentDecl) element).getTypeString(); + if (element instanceof PascalIdentDecl idDecl) { + typeString = idDecl.getTypeString(); if (!StringUtil.isEmpty(typeString)) { typeString = ": " + typeString; } } - return ResolveUtil.cleanupName(element.getName()) + typeString; + return LocalizeValue.of(ResolveUtil.cleanupName(element.getName()) + typeString); } - @Nullable @Override - public String getLocationString() { + @RequiredReadAction + public @Nullable String getLocationString() { return getType(element) + (element.getContainingFile() != null ? element.getContainingFile().getName() : "-"); } - @Nullable @Override - public Image getIcon(boolean unused) { - if (element instanceof PascalIdentDeclImpl) { - PasIdentStub stub = ((PascalIdentDeclImpl) element).retrieveStub(); + public @Nullable Image getIcon(boolean unused) { + if (element instanceof PascalIdentDeclImpl idDecl) { + PasIdentStub stub = idDecl.retrieveStub(); PasField.FieldType type = stub != null ? stub.getType() : PsiUtil.getFieldType(element); switch (type) { - case VARIABLE: return PascalIcons.VARIABLE; - case TYPE: return PascalIcons.TYPE; - case CONSTANT: return PascalIcons.CONSTANT; - case ROUTINE: return PascalIcons.ROUTINE; + case VARIABLE: + return PlatformIconGroup.nodesVariable(); + case TYPE: + return PlatformIconGroup.nodesType(); + case CONSTANT: + return PlatformIconGroup.nodesConstant(); + case ROUTINE: + return PlatformIconGroup.nodesFunction(); } - } else if (element instanceof PasClassTypeDecl) { - return PascalIcons.CLASS; - } else if (element instanceof PasRecordDecl) { - return PascalIcons.RECORD; - } else if (element instanceof PasInterfaceTypeDecl) { - return PascalIcons.INTERFACE; - } else if (element instanceof PasObjectDecl) { - return PascalIcons.OBJECT; - } else if (element instanceof PascalRoutine) { - return PascalIcons.ROUTINE; - } else if (element instanceof PasGenericTypeIdent) { - return PascalIcons.TYPE; - } else if (element instanceof PascalVariableDeclaration) { - return PascalIcons.VARIABLE; - } else if (element instanceof PasConstDeclaration) { - return PascalIcons.CONSTANT; - } else if ((element instanceof PasClassProperty) || (element.getParent() instanceof PasClassProperty)) { - return PascalIcons.PROPERTY; - } else if (element instanceof PasModule) { - PascalModule.ModuleType moduleType = ((PasModule) element).getModuleType(); + } + else if (element instanceof PasClassTypeDecl) { + return PlatformIconGroup.nodesClass(); + } + else if (element instanceof PasRecordDecl) { + return PlatformIconGroup.nodesRecord(); + } + else if (element instanceof PasInterfaceTypeDecl) { + return PlatformIconGroup.nodesInterface(); + } + else if (element instanceof PasObjectDecl) { + return PlatformIconGroup.nodesAnonymousclass(); + } + else if (element instanceof PascalRoutine) { + return PlatformIconGroup.nodesFunction(); + } + else if (element instanceof PasGenericTypeIdent) { + return PlatformIconGroup.nodesType(); + } + else if (element instanceof PascalVariableDeclaration) { + return PlatformIconGroup.nodesVariable(); + } + else if (element instanceof PasConstDeclaration) { + return PlatformIconGroup.nodesConstant(); + } + else if (element instanceof PasClassProperty || element.getParent() instanceof PasClassProperty) { + return PlatformIconGroup.nodesProperty(); + } + else if (element instanceof PasModule module) { + PascalModule.ModuleType moduleType = module.getModuleType(); if (moduleType == PascalModule.ModuleType.PROGRAM) { - return PascalIcons.FILE_PROGRAM; - } else if (moduleType == PascalModule.ModuleType.LIBRARY) { - return PascalIcons.FILE_LIBRARY; - } else { - return PascalIcons.UNIT; + return ObjectPascalIconGroup.program(); + } + else if (moduleType == PascalModule.ModuleType.LIBRARY) { + return ObjectPascalIconGroup.library(); + } + else { + return ObjectPascalIconGroup.unit(); } } - return PascalIcons.GENERAL; + return ObjectPascalIconGroup.pascal(); } }; } private static boolean isASTAvailable(PascalNamedElement element) { - return (!(element.getContainingFile() instanceof CompiledFileImpl)); + return !(element.getContainingFile() instanceof CompiledFileImpl); } - private static String getType(PascalNamedElement item) { - if (item instanceof PascalIdentDeclImpl) { - PasIdentStub stub = ((PascalIdentDeclImpl) item).retrieveStub(); + private static LocalizeValue getType(PascalNamedElement item) { + if (item instanceof PascalIdentDeclImpl idDecl) { + PasIdentStub stub = idDecl.retrieveStub(); PasField.FieldType type = stub != null ? stub.getType() : PsiUtil.getFieldType(item); switch (type) { - case VARIABLE: return "[var] "; - case TYPE: return "[type] "; - case CONSTANT: return "[const] "; - case ROUTINE: return "[routine] "; + case VARIABLE: + return LocalizeValue.localizeTODO("[var] "); + case TYPE: + return LocalizeValue.localizeTODO("[type] "); + case CONSTANT: + return LocalizeValue.localizeTODO("[const] "); + case ROUTINE: + return LocalizeValue.localizeTODO("[routine] "); } - } else if (item instanceof PasClassTypeDecl) { - return "[class] "; - } else if (item instanceof PasInterfaceTypeDecl) { - return "[interface] "; - } else if (item instanceof PasRecordDecl) { - return "[record] "; - } else if (item instanceof PasObjectDecl) { - return "[object] "; - } else if (item instanceof PascalRoutine) { - return "[routine] "; - } else if (item instanceof PasClassHelperDecl) { - return "[class helper] "; - } else if (item instanceof PasRecordHelperDecl) { - return "[record helper] "; - } else if (item instanceof PasVarDeclaration) { - return "[var] "; - } else if (item instanceof PasClassField) { - return "[field] "; - } else if (item instanceof PasConstDeclaration) { - return "[const] "; - } else if (item instanceof PasTypeDecl) { - return "[type] "; - } else if (item instanceof PasClassProperty) { - return "[property] "; } - return ""; + else if (item instanceof PasClassTypeDecl) { + return LocalizeValue.localizeTODO("[class] "); + } + else if (item instanceof PasInterfaceTypeDecl) { + return LocalizeValue.localizeTODO("[interface] "); + } + else if (item instanceof PasRecordDecl) { + return LocalizeValue.localizeTODO("[record] "); + } + else if (item instanceof PasObjectDecl) { + return LocalizeValue.localizeTODO("[object] "); + } + else if (item instanceof PascalRoutine) { + return LocalizeValue.localizeTODO("[routine] "); + } + else if (item instanceof PasClassHelperDecl) { + return LocalizeValue.localizeTODO("[class helper] "); + } + else if (item instanceof PasRecordHelperDecl) { + return LocalizeValue.localizeTODO("[record helper] "); + } + else if (item instanceof PasVarDeclaration) { + return LocalizeValue.localizeTODO("[var] "); + } + else if (item instanceof PasClassField) { + return LocalizeValue.localizeTODO("[field] "); + } + else if (item instanceof PasConstDeclaration) { + return LocalizeValue.localizeTODO("[const] "); + } + else if (item instanceof PasTypeDecl) { + return LocalizeValue.localizeTODO("[type] "); + } + else if (item instanceof PasClassProperty) { + return LocalizeValue.localizeTODO("[property] "); + } + return LocalizeValue.empty(); } - }