mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+106
-149
@@ -2,13 +2,13 @@
|
||||
package com.intellij.codeInspection.javaDoc;
|
||||
|
||||
import com.intellij.ToolExtensionPoints;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.javadoc.*;
|
||||
import com.intellij.psi.util.PropertyUtilBase;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -171,187 +171,144 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
}
|
||||
|
||||
private void checkFile(PsiJavaFile file, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
PsiDocComment docComment = PsiTreeUtil.getChildOfType(file, PsiDocComment.class);
|
||||
PsiPackage pkg = JavaDirectoryService.getInstance().getPackage(file.getContainingDirectory());
|
||||
boolean required = pkg != null && JavadocHighlightUtil.isJavaDocRequired(this, pkg);
|
||||
if (IGNORE_DEPRECATED &&
|
||||
(AnnotationUtil.findAnnotation(pkg, CommonClassNames.JAVA_LANG_DEPRECATED) != null ||
|
||||
docComment != null && docComment.findTagByName("deprecated") != null)) {
|
||||
if (pkg == null) return;
|
||||
|
||||
PsiDocComment docComment = PsiTreeUtil.getChildOfType(file, PsiDocComment.class);
|
||||
if (IGNORE_DEPRECATED && isDeprecated(pkg, docComment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, pkg);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
if (docComment == null) {
|
||||
if (required) {
|
||||
PsiElement toHighlight = notNull(file.getPackageStatement(), file);
|
||||
JavadocHighlightUtil.reportMissingTag(toHighlight, holder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (docComment != null) {
|
||||
PsiDocTag[] tags = docComment.getTags();
|
||||
|
||||
if (required) {
|
||||
Predicate<String> tagChecker = tag -> isTagRequired(pkg, tag);
|
||||
JavadocHighlightUtil.checkRequiredTags(tags, tagChecker, docComment.getFirstChild(), holder);
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkRequiredTagDescriptions(tags, holder);
|
||||
|
||||
JavadocHighlightUtil.checkTagValues(tags, pkg, holder);
|
||||
|
||||
JavadocHighlightUtil.checkInlineTags(docComment.getDescriptionElements(), holder);
|
||||
|
||||
if (!IGNORE_JAVADOC_PERIOD) {
|
||||
JavadocHighlightUtil.checkForPeriod(docComment, pkg, holder);
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkForBadCharacters(docComment, holder);
|
||||
checkBasics(docComment, tags, pkg, required, holder);
|
||||
}
|
||||
else if (required) {
|
||||
PsiElement toHighlight = notNull(file.getPackageStatement(), file);
|
||||
JavadocHighlightUtil.reportMissingTag(toHighlight, holder);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkClass(PsiClass psiClass, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
if (psiClass instanceof PsiAnonymousClass || psiClass instanceof PsiSyntheticClass || psiClass instanceof PsiTypeParameter) {
|
||||
private static boolean isDeprecated(PsiPackage pkg, PsiDocComment docComment) {
|
||||
return PsiImplUtil.isDeprecatedByAnnotation(pkg) || docComment != null && docComment.findTagByName("deprecated") != null;
|
||||
}
|
||||
|
||||
private void checkClass(PsiClass aClass, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
if (aClass instanceof PsiAnonymousClass || aClass instanceof PsiSyntheticClass || aClass instanceof PsiTypeParameter) {
|
||||
return;
|
||||
}
|
||||
if (IGNORE_DEPRECATED && psiClass.isDeprecated()) {
|
||||
if (IGNORE_DEPRECATED && aClass.isDeprecated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiDocComment docComment = psiClass.getDocComment();
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, psiClass);
|
||||
PsiDocComment docComment = aClass.getDocComment();
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, aClass);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
|
||||
if (docComment == null) {
|
||||
if (required) {
|
||||
PsiElement toHighlight = notNull(psiClass.getNameIdentifier(), psiClass);
|
||||
JavadocHighlightUtil.reportMissingTag(toHighlight, holder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (docComment != null) {
|
||||
PsiDocTag[] tags = docComment.getTags();
|
||||
|
||||
if (required) {
|
||||
Predicate<String> tagChecker = tag -> isTagRequired(psiClass, tag);
|
||||
JavadocHighlightUtil.checkRequiredTags(tags, tagChecker, docComment.getFirstChild(), holder);
|
||||
checkBasics(docComment, tags, aClass, required, holder);
|
||||
|
||||
if (required && isTagRequired(aClass, "param")) {
|
||||
JavadocHighlightUtil.checkMissingTypeParamTags(aClass, tags, docComment.getFirstChild(), holder);
|
||||
}
|
||||
}
|
||||
else if (required) {
|
||||
PsiElement toHighlight = notNull(aClass.getNameIdentifier(), aClass);
|
||||
JavadocHighlightUtil.reportMissingTag(toHighlight, holder);
|
||||
}
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkRequiredTagDescriptions(tags, holder);
|
||||
private void checkField(PsiField field, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
if (IGNORE_DEPRECATED && isDeprecated(field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkTagValues(tags, psiClass, holder);
|
||||
PsiDocComment docComment = field.getDocComment();
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, field);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
|
||||
if (!IGNORE_JAVADOC_PERIOD) {
|
||||
JavadocHighlightUtil.checkForPeriod(docComment, psiClass, holder);
|
||||
if (docComment != null) {
|
||||
PsiDocTag[] tags = docComment.getTags();
|
||||
checkBasics(docComment, tags, field, required, holder);
|
||||
}
|
||||
else if (required) {
|
||||
JavadocHighlightUtil.reportMissingTag(field.getNameIdentifier(), holder);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMethod(PsiMethod method, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
if (method instanceof SyntheticElement) {
|
||||
return;
|
||||
}
|
||||
if (IGNORE_DEPRECATED && isDeprecated(method)) {
|
||||
return;
|
||||
}
|
||||
if (myIgnoreSimpleAccessors && PropertyUtilBase.isSimplePropertyAccessor(method)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiDocComment docComment = method.getDocComment();
|
||||
boolean hasSupers = method.findSuperMethods().length > 0;
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, method);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
|
||||
if (docComment != null) {
|
||||
if (!isInherited(docComment, method)) {
|
||||
PsiDocTag[] tags = docComment.getTags();
|
||||
|
||||
if (required && !hasSupers) {
|
||||
if (isTagRequired(method, "return")) {
|
||||
JavadocHighlightUtil.checkMissingReturnTag(tags, method, docComment.getFirstChild(), holder);
|
||||
}
|
||||
if (isTagRequired(method, "param")) {
|
||||
JavadocHighlightUtil.checkMissingParamTags(tags, method, docComment.getFirstChild(), holder);
|
||||
}
|
||||
if (isTagRequired(method, "throws")) {
|
||||
JavadocHighlightUtil.checkMissingThrowsTags(tags, method, docComment.getFirstChild(), holder);
|
||||
}
|
||||
}
|
||||
|
||||
if (!myIgnoreEmptyDescriptions) {
|
||||
JavadocHighlightUtil.checkEmptyMethodTagsDescription(tags, holder);
|
||||
}
|
||||
|
||||
checkBasics(docComment, tags, method, false, holder);
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkInlineTags(docComment.getDescriptionElements(), holder);
|
||||
|
||||
JavadocHighlightUtil.checkForBadCharacters(docComment, holder);
|
||||
|
||||
JavadocHighlightUtil.checkDuplicateTags(tags, holder);
|
||||
|
||||
if (required && isTagRequired(psiClass, "param")) {
|
||||
JavadocHighlightUtil.checkMissingTypeParamTags(psiClass, tags, docComment.getFirstChild(), holder);
|
||||
}
|
||||
else if (required && !hasSupers) {
|
||||
PsiIdentifier nameIdentifier = method.getNameIdentifier();
|
||||
if (nameIdentifier != null) {
|
||||
ExtensionPoint<Condition<PsiMember>> ep = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.JAVADOC_LOCAL);
|
||||
if (Stream.of(ep.getExtensions()).noneMatch(condition -> condition.value(method))) {
|
||||
JavadocHighlightUtil.reportMissingTag(nameIdentifier, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkField(PsiField psiField, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
if (IGNORE_DEPRECATED && isDeprecated(psiField)) {
|
||||
return;
|
||||
private void checkBasics(PsiDocComment docComment, PsiDocTag[] tags, PsiElement context, boolean required, ProblemHolderImpl holder) {
|
||||
if (required) {
|
||||
Predicate<String> tagChecker = tag -> isTagRequired(context, tag);
|
||||
JavadocHighlightUtil.checkRequiredTags(tags, tagChecker, docComment.getFirstChild(), holder);
|
||||
}
|
||||
|
||||
PsiDocComment docComment = psiField.getDocComment();
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, psiField);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
JavadocHighlightUtil.checkRequiredTagDescriptions(tags, holder);
|
||||
|
||||
if (docComment == null) {
|
||||
if (required) {
|
||||
JavadocHighlightUtil.reportMissingTag(psiField.getNameIdentifier(), holder);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JavadocHighlightUtil.checkTagValues(docComment.getTags(), psiField, holder);
|
||||
JavadocHighlightUtil.checkTagValues(tags, context, holder);
|
||||
|
||||
JavadocHighlightUtil.checkInlineTags(docComment.getDescriptionElements(), holder);
|
||||
|
||||
if (!IGNORE_JAVADOC_PERIOD) {
|
||||
JavadocHighlightUtil.checkForPeriod(docComment, psiField, holder);
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkDuplicateTags(docComment.getTags(), holder);
|
||||
|
||||
JavadocHighlightUtil.checkForBadCharacters(docComment, holder);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMethod(PsiMethod psiMethod, ProblemsHolder delegate, boolean isOnTheFly) {
|
||||
if (psiMethod instanceof SyntheticElement) {
|
||||
return;
|
||||
}
|
||||
if (IGNORE_DEPRECATED && isDeprecated(psiMethod)) {
|
||||
return;
|
||||
}
|
||||
if (myIgnoreSimpleAccessors && PropertyUtilBase.isSimplePropertyAccessor(psiMethod)) {
|
||||
return;
|
||||
if (!IGNORE_JAVADOC_PERIOD) {
|
||||
JavadocHighlightUtil.checkForPeriod(docComment, context, holder);
|
||||
}
|
||||
|
||||
PsiDocComment docComment = psiMethod.getDocComment();
|
||||
boolean hasSupers = psiMethod.findSuperMethods().length > 0;
|
||||
boolean required = JavadocHighlightUtil.isJavaDocRequired(this, psiMethod);
|
||||
ProblemHolderImpl holder = new ProblemHolderImpl(delegate, isOnTheFly);
|
||||
JavadocHighlightUtil.checkInlineTags(docComment.getDescriptionElements(), holder);
|
||||
|
||||
if (docComment == null) {
|
||||
if (!required || hasSupers) {
|
||||
return;
|
||||
}
|
||||
JavadocHighlightUtil.checkForBadCharacters(docComment, holder);
|
||||
|
||||
PsiIdentifier nameIdentifier = psiMethod.getNameIdentifier();
|
||||
if (nameIdentifier == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExtensionPoint<Condition<PsiMember>> ep = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.JAVADOC_LOCAL);
|
||||
if (Stream.of(ep.getExtensions()).anyMatch(condition -> condition.value(psiMethod))) {
|
||||
return;
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.reportMissingTag(nameIdentifier, holder);
|
||||
}
|
||||
else {
|
||||
PsiElement[] descriptionElements = docComment.getDescriptionElements();
|
||||
if (isInherited(docComment, descriptionElements, psiMethod)) {
|
||||
return;
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkInlineTags(descriptionElements, holder);
|
||||
|
||||
PsiDocTag[] tags = docComment.getTags();
|
||||
if (required && !hasSupers) {
|
||||
if (isTagRequired(psiMethod, "return")) {
|
||||
JavadocHighlightUtil.checkMissingReturnTag(tags, psiMethod, docComment.getFirstChild(), holder);
|
||||
}
|
||||
if (isTagRequired(psiMethod, "param")) {
|
||||
JavadocHighlightUtil.checkMissingParamTags(tags, psiMethod, docComment.getFirstChild(), holder);
|
||||
}
|
||||
if (isTagRequired(psiMethod, "throws")) {
|
||||
JavadocHighlightUtil.checkMissingThrowsTags(tags, psiMethod, docComment.getFirstChild(), holder);
|
||||
}
|
||||
}
|
||||
|
||||
if (!myIgnoreEmptyDescriptions) {
|
||||
JavadocHighlightUtil.checkEmptyMethodTagsDescription(tags, holder);
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkTagValues(tags, psiMethod, holder);
|
||||
|
||||
if (!IGNORE_JAVADOC_PERIOD) {
|
||||
JavadocHighlightUtil.checkForPeriod(docComment, psiMethod, holder);
|
||||
}
|
||||
|
||||
JavadocHighlightUtil.checkForBadCharacters(docComment, holder);
|
||||
|
||||
JavadocHighlightUtil.checkDuplicateTags(tags, holder);
|
||||
}
|
||||
JavadocHighlightUtil.checkDuplicateTags(tags, holder);
|
||||
}
|
||||
|
||||
private boolean isTagRequired(PsiElement context, String tag) {
|
||||
@@ -383,8 +340,8 @@ public class JavaDocLocalInspectionBase extends LocalInspectionTool {
|
||||
return element.isDeprecated() || element.getContainingClass() != null && element.getContainingClass().isDeprecated();
|
||||
}
|
||||
|
||||
private static boolean isInherited(PsiDocComment docComment, PsiElement[] descriptionElements, PsiMethod psiMethod) {
|
||||
for (PsiElement descriptionElement : descriptionElements) {
|
||||
private static boolean isInherited(PsiDocComment docComment, PsiMethod psiMethod) {
|
||||
for (PsiElement descriptionElement : docComment.getDescriptionElements()) {
|
||||
if (descriptionElement instanceof PsiInlineDocTag && "inheritDoc".equals(((PsiInlineDocTag)descriptionElement).getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-3
@@ -27,7 +27,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,8 +40,7 @@ public class PackageViewModuleGroupNode extends ModuleGroupNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractTreeNode createModuleNode(Module module)
|
||||
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
|
||||
protected AbstractTreeNode createModuleNode(Module module) {
|
||||
return new PackageViewModuleNode(module.getProject(), module, getSettings());
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ public class PluginManagerCore {
|
||||
|
||||
private static class Holder {
|
||||
private static final BuildNumber ourBuildNumber = calcBuildNumber();
|
||||
private static final boolean ourIsRunningFromSources = new File(PathManager.getHomePath(), ".idea").isDirectory();
|
||||
|
||||
private static BuildNumber calcBuildNumber() {
|
||||
BuildNumber ourBuildNumber = BuildNumber.fromString(System.getProperty("idea.plugins.compatible.build"));
|
||||
@@ -461,7 +462,7 @@ public class PluginManagerCore {
|
||||
PluginId pluginId = pluginDescriptor.getPluginId();
|
||||
File pluginRoot = pluginDescriptor.getPath();
|
||||
|
||||
if (isUnitTestMode()) return null;
|
||||
if (isRunningFromSources()) return null;
|
||||
|
||||
try {
|
||||
final List<URL> urls = new ArrayList<>(classPath.length);
|
||||
@@ -519,7 +520,8 @@ public class PluginManagerCore {
|
||||
|
||||
@NotNull
|
||||
private static ClassLoader[] getParentLoaders(@NotNull Map<PluginId, ? extends IdeaPluginDescriptor> idToDescriptorMap, @NotNull PluginId[] pluginIds) {
|
||||
if (isUnitTestMode()) return new ClassLoader[0];
|
||||
if (isRunningFromSources()) return new ClassLoader[0];
|
||||
|
||||
LinkedHashSet<ClassLoader> loaders = new LinkedHashSet<>(pluginIds.length);
|
||||
for (final PluginId id : pluginIds) {
|
||||
IdeaPluginDescriptor pluginDescriptor = idToDescriptorMap.get(id);
|
||||
@@ -536,6 +538,10 @@ public class PluginManagerCore {
|
||||
return loaders.toArray(new ClassLoader[loaders.size()]);
|
||||
}
|
||||
|
||||
public static boolean isRunningFromSources() {
|
||||
return Holder.ourIsRunningFromSources;
|
||||
}
|
||||
|
||||
private static int countPlugins(@NotNull String pluginsPath) {
|
||||
File configuredPluginsDir = new File(pluginsPath);
|
||||
if (configuredPluginsDir.exists()) {
|
||||
|
||||
+1
-3
@@ -29,7 +29,6 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectViewModuleGroupNode extends ModuleGroupNode {
|
||||
@@ -42,8 +41,7 @@ public class ProjectViewModuleGroupNode extends ModuleGroupNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractTreeNode createModuleNode(Module module)
|
||||
throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
protected AbstractTreeNode createModuleNode(Module module) {
|
||||
final VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
|
||||
if (roots.length == 1) {
|
||||
final PsiDirectory psi = PsiManager.getInstance(myProject).findDirectory(roots[0]);
|
||||
|
||||
@@ -53,16 +53,18 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class HelpTooltip {
|
||||
private static Color BACKGROUND_COLOR = new JBColor(Gray.xF7, new Color(0x46484a));
|
||||
private static Color FONT_COLOR = new JBColor(Gray.x33, Gray.xBF);
|
||||
private static Color BACKGROUND_COLOR = new JBColor(Gray.xF7, new Color(0x474a4c));
|
||||
private static Color FONT_COLOR = new JBColor(() -> UIUtil.isUnderDarcula() ? Gray.xBF : SystemInfo.isMac ? Gray.x33 : Gray.x1A);
|
||||
private static Color SHORTCUT_COLOR = new JBColor(Gray.x78, Gray.x87);
|
||||
private static Color BORDER_COLOR = new JBColor(Gray.xAD, new Color(0x616366));
|
||||
private static Color BORDER_COLOR = new JBColor(Gray.xAD, new Color(0x636569));
|
||||
|
||||
private static Border DEFAULT_BORDER = JBUI.Borders.empty(SystemInfo.isWindows ? 7 : 10, 10, 10, 16);
|
||||
private static Border SMALL_BORDER = JBUI.Borders.empty(SystemInfo.isMac ? 3 : (SystemInfo.isWindows ? 2 : 5),
|
||||
8,
|
||||
SystemInfo.isMac ? 5 : 4,
|
||||
8);
|
||||
private static Border DEFAULT_BORDER = SystemInfo.isMac ? JBUI.Borders.empty(9, 10, 11, 16) :
|
||||
SystemInfo.isWindows ? JBUI.Borders.empty(7, 10, 10, 16):
|
||||
JBUI.Borders.empty(10, 10, 10, 16);
|
||||
|
||||
private static Border SMALL_BORDER = SystemInfo.isMac ? JBUI.Borders.empty(4, 8, 5, 8) :
|
||||
SystemInfo.isWindows ? JBUI.Borders.empty(4, 8, 6, 8) :
|
||||
JBUI.Borders.empty(5, 8, 4, 8);
|
||||
|
||||
private static final int VGAP = JBUI.scale(UIUtil.DEFAULT_VGAP);
|
||||
private static final int HGAP = JBUI.scale(UIUtil.DEFAULT_HGAP);
|
||||
@@ -71,6 +73,8 @@ public class HelpTooltip {
|
||||
private static final String DOTS = "...";
|
||||
private static final String PARAGRAPH_SPLITTER = "<p/?>";
|
||||
|
||||
private static final String TOOLTIP_PROPERTY = "JComponent.helpTooltip";
|
||||
|
||||
private String title;
|
||||
private String shortcut;
|
||||
private String description;
|
||||
@@ -79,6 +83,7 @@ public class HelpTooltip {
|
||||
private Alignment alignment = Alignment.BOTTOM;
|
||||
|
||||
private JComponent owner;
|
||||
private Object masterPopup; // can be JPopupMenu or JBPopup which don't belong to one hierarchy
|
||||
private ComponentPopupBuilder myPopupBuilder;
|
||||
private JBPopup myPopup;
|
||||
private Alarm popupAlarm = new Alarm();
|
||||
@@ -198,6 +203,8 @@ public class HelpTooltip {
|
||||
neverHide = neverHide || DarculaButtonUI.isHelpButton(component);
|
||||
|
||||
owner = component;
|
||||
owner.putClientProperty(TOOLTIP_PROPERTY, this);
|
||||
|
||||
myPopupBuilder = JBPopupFactory.getInstance().
|
||||
createComponentPopupBuilder(tipPanel, null).
|
||||
setBorderColor(BORDER_COLOR).setShowShadow(false);
|
||||
@@ -228,7 +235,9 @@ public class HelpTooltip {
|
||||
owner.removeMouseListener(myMouseListener);
|
||||
owner.removeMouseMotionListener(myMouseListener);
|
||||
owner.removePropertyChangeListener(myPropertyChangeListener);
|
||||
owner.putClientProperty(TOOLTIP_PROPERTY, null);
|
||||
owner = null;
|
||||
masterPopup = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -238,15 +247,35 @@ public class HelpTooltip {
|
||||
owner.addPropertyChangeListener("ancestor", myPropertyChangeListener);
|
||||
}
|
||||
|
||||
public static void onShowMasterPopup(@NotNull JComponent owner, @NotNull Object master) {
|
||||
HelpTooltip instance = (HelpTooltip)owner.getClientProperty(TOOLTIP_PROPERTY);
|
||||
if (instance != null) {
|
||||
instance.hidePopup(true);
|
||||
instance.masterPopup = master;
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleShow(int delay) {
|
||||
popupAlarm.cancelAllRequests();
|
||||
popupAlarm.addRequest(() -> {
|
||||
myPopup = myPopupBuilder.createPopup();
|
||||
myPopup.show(new RelativePoint(owner, alignment.getPointFor(owner)));
|
||||
if (!neverHide) {
|
||||
scheduleHide(true, myDismissDelay);
|
||||
}
|
||||
}, delay);
|
||||
popupAlarm.addRequest(() -> {
|
||||
if (canShow()) {
|
||||
myPopup = myPopupBuilder.createPopup();
|
||||
myPopup.show(new RelativePoint(owner, alignment.getPointFor(owner)));
|
||||
if (!neverHide) {
|
||||
scheduleHide(true, myDismissDelay);
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
private boolean canShow() {
|
||||
if (masterPopup instanceof JPopupMenu) {
|
||||
return !((JPopupMenu)masterPopup).isVisible();
|
||||
} else if (masterPopup instanceof JBPopup) {
|
||||
return !((JBPopup)masterPopup).isVisible();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleHide(boolean force, int delay) {
|
||||
|
||||
@@ -60,19 +60,11 @@ public class DarculaUIUtil {
|
||||
private static final Color MAC_INACTIVE_ERROR_COLOR = new Color(0x80f7bcbc, true);
|
||||
private static final Color DEFAULT_INACTIVE_ERROR_COLOR = new JBColor(0xebbcbc, 0x725252);
|
||||
|
||||
@SuppressWarnings("UseJBColor")
|
||||
private static final Color MAC_ACTIVE_WARNING_COLOR = new Color(0x80f5f510, true);
|
||||
private static final Color DEFAULT_ACTIVE_WARNING_COLOR = JBColor.YELLOW;
|
||||
|
||||
@SuppressWarnings("UseJBColor")
|
||||
private static final Color MAC_INACTIVE_WARNING_COLOR = new Color(0x80f7f770, true);
|
||||
private static final Color DEFAULT_INACTIVE_WARNING_COLOR = JBColor.YELLOW.brighter();
|
||||
|
||||
public static final Color ACTIVE_ERROR_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_ACTIVE_ERROR_COLOR : DEFAULT_ACTIVE_ERROR_COLOR);
|
||||
public static final Color INACTIVE_ERROR_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_INACTIVE_ERROR_COLOR : DEFAULT_INACTIVE_ERROR_COLOR);
|
||||
|
||||
public static final Color ACTIVE_WARNING_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_ACTIVE_WARNING_COLOR : DEFAULT_ACTIVE_WARNING_COLOR);
|
||||
public static final Color INACTIVE_WARNING_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_INACTIVE_WARNING_COLOR : DEFAULT_INACTIVE_WARNING_COLOR);
|
||||
@SuppressWarnings("UseJBColor")
|
||||
public static final Color WARNING_COLOR = new Color(0xf6ebbc, true);
|
||||
|
||||
@SuppressWarnings("UseJBColor")
|
||||
private static final Color MAC_REGULAR_COLOR = new Color(0x80479cfc, true);
|
||||
@@ -89,7 +81,8 @@ public class DarculaUIUtil {
|
||||
|
||||
warning {
|
||||
public void setGraphicsColor(Graphics2D g, boolean focused) {
|
||||
g.setColor(focused ? ACTIVE_WARNING_COLOR : INACTIVE_WARNING_COLOR);
|
||||
g.setColor(WARNING_COLOR);
|
||||
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, focused ? 1f : 0.5f));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -177,6 +177,11 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
|
||||
}
|
||||
});
|
||||
popupMenu.setDataContextProvider(() -> this.getDataContext());
|
||||
|
||||
if (Registry.is("ide.helptooltip.enabled")) {
|
||||
HelpTooltip.onShowMasterPopup(this, popupMenu.getComponent());
|
||||
}
|
||||
|
||||
if (event.isFromActionToolbar()) {
|
||||
popupMenu.getComponent().show(this, 0, getHeight());
|
||||
}
|
||||
|
||||
@@ -304,13 +304,6 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
return myCommandLineMode;
|
||||
}
|
||||
|
||||
private static class Holder {
|
||||
private static final boolean ourIsRunningFromSources = new File(PathManager.getHomePath(), ".idea").isDirectory();
|
||||
}
|
||||
public static boolean isRunningFromSources() {
|
||||
return Holder.ourIsRunningFromSources;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Future<?> executeOnPooledThread(@NotNull final Runnable action) {
|
||||
|
||||
@@ -17,10 +17,7 @@ package com.intellij.ui.popup;
|
||||
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.UiActivity;
|
||||
import com.intellij.ide.UiActivityMonitor;
|
||||
import com.intellij.ide.*;
|
||||
import com.intellij.ide.actions.WindowAction;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
@@ -470,7 +467,11 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
@Override
|
||||
public void show(@NotNull RelativePoint aPoint) {
|
||||
final Point screenPoint = aPoint.getScreenPoint();
|
||||
if (Registry.is("ide.helptooltip.enabled")) {
|
||||
HelpTooltip.onShowMasterPopup((JComponent)aPoint.getOriginalComponent(), this);
|
||||
}
|
||||
|
||||
Point screenPoint = aPoint.getScreenPoint();
|
||||
show(aPoint.getComponent(), screenPoint.x, screenPoint.y, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,6 @@ public class RelativePoint {
|
||||
|
||||
public RelativePoint(@NotNull MouseEvent event) {
|
||||
init(event.getComponent(), event.getPoint());
|
||||
|
||||
myOriginalComponent = event.getComponent();
|
||||
myOriginalPoint = event.getPoint();
|
||||
}
|
||||
|
||||
public RelativePoint(@NotNull Component aComponent, Point aPointOnComponent) {
|
||||
@@ -69,9 +66,8 @@ public class RelativePoint {
|
||||
myComponent = aComponent;
|
||||
myPointOnComponent = aPointOnComponent;
|
||||
}
|
||||
|
||||
myOriginalComponent = myComponent;
|
||||
myOriginalPoint = myPointOnComponent;
|
||||
myOriginalComponent = aComponent;
|
||||
myOriginalPoint = aPointOnComponent;
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
@@ -151,7 +147,7 @@ public class RelativePoint {
|
||||
return new RelativePoint(component, point);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NotNull @SuppressWarnings("unused")
|
||||
public static RelativePoint getNorthEastOf(@NotNull JComponent component) {
|
||||
final Rectangle visibleRect = component.getVisibleRect();
|
||||
final Point point = new Point(visibleRect.x + visibleRect.width, visibleRect.y);
|
||||
@@ -169,6 +165,7 @@ public class RelativePoint {
|
||||
return myOriginalComponent;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Point getOriginalPoint() {
|
||||
return myOriginalPoint;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user