mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
annotate/fix names for icon providers/patchers
GitOrigin-RevId: 2faa3be0c1e377ffa08874a5f49d862118e83cfd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
75f080da26
commit
204f56656e
@@ -9,20 +9,21 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.IconManager;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
final class JavaExcludedFileIconPatcher implements FileIconPatcher {
|
||||
@Override
|
||||
public Icon patchIcon(Icon baseIcon, VirtualFile file, int flags, @Nullable Project project) {
|
||||
public @NotNull Icon patchIcon(@NotNull Icon icon, @NotNull VirtualFile file, int flags, @Nullable Project project) {
|
||||
if (project == null) {
|
||||
return baseIcon;
|
||||
return icon;
|
||||
}
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
if (fileIndex.isInSource(file) && CompilerManager.getInstance(project).isExcludedFromCompilation(file)) {
|
||||
return IconManager.getInstance().createLayered(LayeredIcon.layeredIcon(new Icon[]{baseIcon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON}));
|
||||
return IconManager.getInstance().createLayered(LayeredIcon.layeredIcon(new Icon[]{icon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON}));
|
||||
}
|
||||
return baseIcon;
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,17 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
public final class JavaFileIconPatcher implements FileIconPatcher {
|
||||
@Override
|
||||
public Icon patchIcon(final Icon baseIcon, final VirtualFile file, final int flags, final Project project) {
|
||||
public @NotNull Icon patchIcon(@NotNull Icon icon, @NotNull VirtualFile file, int flags, @Nullable Project project) {
|
||||
if (project == null) {
|
||||
return baseIcon;
|
||||
return icon;
|
||||
}
|
||||
|
||||
FileType fileType = file.getFileType();
|
||||
@@ -31,10 +33,10 @@ public final class JavaFileIconPatcher implements FileIconPatcher {
|
||||
PsiClass[] classes = ((PsiClassOwner)psiFile).getClasses();
|
||||
if (classes.length > 0) {
|
||||
// prefer icon of the class named after file
|
||||
final String fileName = file.getNameWithoutExtension();
|
||||
String fileName = file.getNameWithoutExtension();
|
||||
for (PsiClass aClass : classes) {
|
||||
if (aClass instanceof SyntheticElement) {
|
||||
return baseIcon;
|
||||
return icon;
|
||||
}
|
||||
if (Comparing.strEqual(aClass.getName(), fileName)) {
|
||||
return aClass.getIcon(flags);
|
||||
@@ -43,6 +45,6 @@ public final class JavaFileIconPatcher implements FileIconPatcher {
|
||||
return classes[classes.length - 1].getIcon(flags);
|
||||
}
|
||||
}
|
||||
return baseIcon;
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -31,5 +32,8 @@ import javax.swing.*;
|
||||
public interface FileIconPatcher extends DumbAware {
|
||||
ExtensionPointName<FileIconPatcher> EP_NAME = ExtensionPointName.create("com.intellij.fileIconPatcher");
|
||||
|
||||
Icon patchIcon(Icon baseIcon, VirtualFile file, @Iconable.IconFlags int flags, @Nullable Project project);
|
||||
@NotNull Icon patchIcon(@NotNull Icon icon,
|
||||
@NotNull VirtualFile file,
|
||||
@Iconable.IconFlags int flags,
|
||||
@Nullable Project project);
|
||||
}
|
||||
+3
-6
@@ -1,8 +1,5 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -15,10 +12,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
final class FileIconPatcherImpl implements FileIconProvider {
|
||||
final class PsiBasedFileIconProvider implements FileIconProvider {
|
||||
@Override
|
||||
public @Nullable Icon getIcon(@NotNull VirtualFile file, int flags, Project project) {
|
||||
public @Nullable Icon getIcon(@NotNull VirtualFile file, int flags, @Nullable Project project) {
|
||||
PsiFileSystemItem psiFile = PsiUtilCore.findFileSystemItem(project, file);
|
||||
return psiFile == null ? null : PsiIconUtil.getProvidersIcon(psiFile, flags);
|
||||
return psiFile == null ? null : PsiIconUtil.getIconFromProviders(psiFile, flags);
|
||||
}
|
||||
}
|
||||
@@ -346,11 +346,11 @@ public final class ScratchFileServiceImpl extends ScratchFileService implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon patchIcon(Icon baseIcon, VirtualFile file, int flags, @Nullable Project project) {
|
||||
if (project == null) return baseIcon;
|
||||
public @NotNull Icon patchIcon(@NotNull Icon icon, @NotNull VirtualFile file, int flags, @Nullable Project project) {
|
||||
if (project == null) return icon;
|
||||
RootType rootType = ScratchFileService.getInstance().getRootType(file);
|
||||
if (rootType == null) return baseIcon;
|
||||
return rootType.patchIcon(baseIcon, file, flags, project);
|
||||
if (rootType == null) return icon;
|
||||
return rootType.patchIcon(icon, file, flags, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -808,7 +808,7 @@
|
||||
<directoryProjectConfigurator implementation="com.intellij.platform.PlatformProjectConfigurator" order="first"
|
||||
id="PlatformProjectConfigurator"/>
|
||||
|
||||
<fileIconProvider implementation="com.intellij.ide.FileIconPatcherImpl"/>
|
||||
<fileIconProvider implementation="com.intellij.ide.PsiBasedFileIconProvider"/>
|
||||
<iconProvider implementation="com.intellij.ide.NativeIconProvider" id="native"/>
|
||||
<iconProvider implementation="com.intellij.psi.impl.file.SourceRootIconProvider$DirectoryProvider" id="directory" order="last"/>
|
||||
<iconLayerProvider implementation="com.intellij.psi.impl.file.SourceRootIconProvider$FileLayerProvider" id="sourceRoot" order="last"/>
|
||||
|
||||
+8
-6
@@ -7,20 +7,22 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import org.intellij.lang.xpath.xslt.XsltSupport;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class XsltIconProvider implements FileIconPatcher {
|
||||
public class XsltIconPatcher implements FileIconPatcher {
|
||||
|
||||
@Override
|
||||
public Icon patchIcon(Icon baseIcon, VirtualFile file, int flags, Project project) {
|
||||
if (project == null) return baseIcon;
|
||||
public @NotNull Icon patchIcon(@NotNull Icon icon, @NotNull VirtualFile file, int flags, @Nullable Project project) {
|
||||
if (project == null) return icon;
|
||||
|
||||
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
if (psiFile != null && XsltSupport.isXsltFile(psiFile)) {
|
||||
return XsltSupport.createXsltIcon(baseIcon);
|
||||
return XsltSupport.createXsltIcon(icon);
|
||||
}
|
||||
return baseIcon;
|
||||
return icon;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -156,7 +156,7 @@
|
||||
bundle="messages.XPathBundle"
|
||||
key="configurable.xslt.display.name"/>
|
||||
|
||||
<fileIconPatcher implementation="org.intellij.lang.xpath.xslt.impl.XsltIconProvider"/>
|
||||
<fileIconPatcher implementation="org.intellij.lang.xpath.xslt.impl.XsltIconPatcher"/>
|
||||
<gotoSymbolContributor implementation="org.intellij.lang.xpath.xslt.impl.XsltChooseByNameContributor"/>
|
||||
<annotator language="XPath" implementationClass="org.intellij.lang.xpath.xslt.validation.XsltAnnotator"/>
|
||||
<annotator language="XML" implementationClass="org.intellij.lang.xpath.xslt.validation.XsltXmlAnnotator"/>
|
||||
|
||||
Reference in New Issue
Block a user