mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+64
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.deadCode;
|
||||
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
@@ -26,11 +27,19 @@ import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -39,8 +48,8 @@ import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
|
||||
import com.intellij.ui.HyperlinkAdapter;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
@@ -54,10 +63,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
public class UnusedDeclarationPresentation extends DefaultInspectionToolPresentation {
|
||||
@@ -529,14 +545,60 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
|
||||
|
||||
@Override
|
||||
public JComponent getCustomPreviewPanel(RefEntity entity) {
|
||||
JEditorPane htmlView = new JEditorPane();
|
||||
final Project project = entity.getRefManager().getProject();
|
||||
JEditorPane htmlView = new JEditorPane() {
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent evt) {
|
||||
int pos = viewToModel(evt.getPoint());
|
||||
if (pos >= 0) {
|
||||
HTMLDocument hdoc = (HTMLDocument) getDocument();
|
||||
javax.swing.text.Element e = hdoc.getCharacterElement(pos);
|
||||
AttributeSet a = e.getAttributes();
|
||||
|
||||
SimpleAttributeSet value = (SimpleAttributeSet) a.getAttribute(HTML.Tag.A);
|
||||
if (value != null) {
|
||||
String objectPackage = (String) value.getAttribute("qualifiedname");
|
||||
if (objectPackage != null) {
|
||||
return objectPackage;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
htmlView.setContentType(UIUtil.HTML_MIME);
|
||||
htmlView.setEditable(false);
|
||||
htmlView.setOpaque(false);
|
||||
htmlView.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(HyperlinkEvent e) {
|
||||
URL url = e.getURL();
|
||||
if (url == null) {
|
||||
return;
|
||||
}
|
||||
@NonNls String ref = url.getRef();
|
||||
|
||||
int offset = Integer.parseInt(ref);
|
||||
String fileURL = url.toExternalForm();
|
||||
fileURL = fileURL.substring(0, fileURL.indexOf('#'));
|
||||
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(fileURL);
|
||||
if (vFile == null) {
|
||||
vFile = VfsUtil.findFileByURL(url);
|
||||
}
|
||||
if (vFile != null) {
|
||||
final OpenFileDescriptor descriptor = new OpenFileDescriptor(project, vFile, offset);
|
||||
FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
final StyleSheet css = ((HTMLEditorKit)htmlView.getEditorKit()).getStyleSheet();
|
||||
css.addRule("p.problem-description-group {text-indent: " + JBUI.scale(12) + "px;font-weight:bold;}");
|
||||
css.addRule("div.problem-description {margin-left: " + JBUI.scale(10) + "px;}");
|
||||
css.addRule("ul {margin-left:" + JBUI.scale(10) + "px;text-indent: 0}");
|
||||
//TODO Dmitry Batkovich: it's hack to hide tags in JEditorPane (any standard methods (display...) are unsupported in java)
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
UIUtil.appendColor(UIUtil.getLabelBackground(), sb);
|
||||
css.addRule(".package {color: #" + sb.toString() + ";}");
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
getComposer().compose(buf, entity, false);
|
||||
final String text = buf.toString();
|
||||
|
||||
@@ -273,6 +273,7 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
|
||||
public void appendReferencePresentation(RefEntity refElement, final StringBuffer buf, final boolean isPackageIncluded) {
|
||||
if (refElement instanceof RefImplicitConstructor) {
|
||||
buf.append(InspectionsBundle.message("inspection.export.results.implicit.constructor"));
|
||||
buf.append(" ");
|
||||
refElement = ((RefImplicitConstructor)refElement).getOwnerClass();
|
||||
}
|
||||
|
||||
@@ -304,7 +305,15 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
|
||||
buf.append(myComposer.myExporter.getURL(refElement));
|
||||
}
|
||||
|
||||
buf.append("\">");
|
||||
buf.append("\"");
|
||||
|
||||
if (isPackageIncluded) {
|
||||
buf.append(" qualifiedname=\"");
|
||||
buf.append(refElement.getQualifiedName());
|
||||
buf.append("\"");
|
||||
}
|
||||
|
||||
buf.append(">");
|
||||
|
||||
if (refElement instanceof RefClass && ((RefClass)refElement).isAnonymous()) {
|
||||
buf.append(InspectionsBundle.message("inspection.reference.anonymous"));
|
||||
@@ -336,7 +345,7 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
|
||||
myComposer.appendElementReference(buf, ((RefElement)refElement.getOwner()), isPackageIncluded);
|
||||
}
|
||||
else if (isPackageIncluded) {
|
||||
buf.append(" ").append(HTMLComposerImpl.CODE_OPENING).append("(");
|
||||
buf.append(" ").append("<code class=\"package\">").append("(");
|
||||
myComposer.appendQualifiedName(buf, refElement.getOwner());
|
||||
// buf.append(RefUtil.getPackageName(refElement));
|
||||
buf.append(")").append(HTMLComposerImpl.CODE_CLOSING);
|
||||
|
||||
+1
-4
@@ -26,7 +26,6 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Version;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.BrowserHyperlinkListener;
|
||||
import com.intellij.ui.JBColor;
|
||||
@@ -243,8 +242,6 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
|
||||
}
|
||||
|
||||
protected static String formatVersion(String versionString, String build) {
|
||||
Version version = Version.parseVersion(versionString);
|
||||
String formattedVersion = version != null ? version.toString() : versionString;
|
||||
return IdeBundle.message("updates.version.info", formattedVersion, build);
|
||||
return IdeBundle.message("updates.version.info", versionString, build);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.intellij.plugins.intelliLang.inject.InjectorUtils;
|
||||
import org.intellij.plugins.intelliLang.inject.LanguageInjectionSupport;
|
||||
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
|
||||
import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -228,6 +229,7 @@ public class GroovyLanguageInjectionSupport extends AbstractLanguageInjectionSup
|
||||
};
|
||||
}
|
||||
|
||||
@Contract("null -> false")
|
||||
private static boolean isStringLiteral(@Nullable PsiLanguageInjectionHost element) {
|
||||
if (element instanceof GrStringContent) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user