mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+7
@@ -973,6 +973,13 @@ public class GenericsHighlightUtil {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, ref, JavaErrorMessages.message("generics.cannot.instanceof.type.parameters"));
|
||||
}
|
||||
|
||||
if (resolved instanceof PsiClass) {
|
||||
final PsiClass containingClass = ((PsiClass)resolved).getContainingClass();
|
||||
if (containingClass != null && ref.getQualifier() == null && containingClass.getTypeParameters().length > 0) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, typeElement, JavaErrorMessages.message("illegal.generic.type.for.instanceof"));
|
||||
}
|
||||
}
|
||||
|
||||
final PsiType[] parameters = ref.getTypeParameters();
|
||||
for (PsiType parameterType : parameters) {
|
||||
if (parameterType != null &&
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class A<T> {
|
||||
public void foo(Object object) {
|
||||
if (object instanceof <error descr="Illegal generic type for instanceof">B</error>) {}
|
||||
if (object instanceof A.B) {}
|
||||
if (object instanceof A<?>.B) {}
|
||||
if (object instanceof A<?>) {}
|
||||
if (object instanceof <error descr="Illegal generic type for instanceof">A<String></error>) {}
|
||||
if (object instanceof A) {}
|
||||
if (object instanceof A[]) {}
|
||||
if (object instanceof <error descr="Illegal generic type for instanceof">B[]</error>) {}
|
||||
if (object instanceof A.B[]) {}
|
||||
}
|
||||
|
||||
private class B {
|
||||
}
|
||||
}
|
||||
|
||||
class A1 {
|
||||
public void foo(Object object) {
|
||||
if (object instanceof B1) {}
|
||||
if (object instanceof A1.B1) {}
|
||||
if (object instanceof B1[]) {}
|
||||
}
|
||||
|
||||
private class B1 {
|
||||
}
|
||||
}
|
||||
+27
@@ -1,3 +1,4 @@
|
||||
import java.lang.Override;
|
||||
import java.util.*;
|
||||
class GenericsTest<T> {
|
||||
|
||||
@@ -91,4 +92,30 @@ class GenericsTest2<T> {
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
class Example {
|
||||
private static <T> void assertThat(T actual, Matcher<? super T> matcher) {
|
||||
assert actual != null;
|
||||
assert matcher != null;
|
||||
}
|
||||
|
||||
private static <E> Matcher<? super Collection<? extends E>> hasSize(int size) {
|
||||
assert size >=0;
|
||||
return new Matcher<Collection<? extends E>>() {
|
||||
@Override
|
||||
public void foo(Collection<? extends E> es) {
|
||||
System.out.println(es);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Boolean> list = <warning descr="Unchecked assignment: 'java.util.ArrayList' to 'java.util.List<java.lang.Boolean>'">new ArrayList()</warning>;
|
||||
System.out.println(list);
|
||||
assertThat(new ArrayList<Boolean>(), hasSize(0));
|
||||
}
|
||||
|
||||
private interface Matcher<T> {
|
||||
void foo(T t);
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA74899() throws Exception {doTest(false);}
|
||||
public void testIDEA63291() throws Exception {doTest(false);}
|
||||
public void testIDEA72912() throws Exception {doTest(false);}
|
||||
public void testIllegalGenericTypeInInstanceof() throws Exception {doTest(false);}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
|
||||
@@ -17,11 +17,14 @@ package com.intellij.codeInsight.lookup.impl;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.ui.HeavyweightHint;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -36,6 +39,17 @@ public class CompletionExtender extends HeavyweightHint {
|
||||
myElement = element;
|
||||
myLookup = lookup;
|
||||
myIndex = myLookup.getList().getSelectedIndex();
|
||||
myLookup.getComponent().addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
recalculateLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
recalculateLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public LookupElement getLookupElement() {
|
||||
@@ -74,6 +88,18 @@ public class CompletionExtender extends HeavyweightHint {
|
||||
return false;
|
||||
}
|
||||
|
||||
void recalculateLocation() {
|
||||
if (!isVisible()) return;
|
||||
final JList list = myLookup.getList();
|
||||
final Point p = list.getLocationOnScreen();
|
||||
p.y += list.indexToLocation(list.getSelectedIndex()).y;
|
||||
final JComponent rootPane = UIUtil.getRootPane(myLookup.getEditor().getContentComponent());
|
||||
if (rootPane != null) {
|
||||
SwingUtilities.convertPointFromScreen(p, rootPane);
|
||||
setLocation(new RelativePoint(rootPane, p));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
super.hide();
|
||||
|
||||
@@ -91,7 +91,7 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx
|
||||
return addRangeHighlighterAndChangeAttributes(offset, offset, layer, textAttributes, HighlighterTargetArea.LINES_IN_RANGE, true, null);
|
||||
}
|
||||
|
||||
static int getFirstNonspaceCharOffset(@NotNull Document doc, int lineNumber) {
|
||||
private static int getFirstNonspaceCharOffset(@NotNull Document doc, int lineNumber) {
|
||||
int lineStart = doc.getLineStartOffset(lineNumber);
|
||||
int lineEnd = doc.getLineEndOffset(lineNumber);
|
||||
CharSequence text = doc.getCharsSequence();
|
||||
|
||||
+8
-8
@@ -134,23 +134,23 @@ public class VirtualFilePointerManagerImpl extends VirtualFilePointerManager imp
|
||||
}
|
||||
|
||||
private static boolean startsWith(final String url, final String pointerUrl) {
|
||||
String urlSuffix = stripSuffix(url);
|
||||
String pointerPrefix = stripToJarPrefix(pointerUrl);
|
||||
if (urlSuffix.length() > 0) {
|
||||
return Comparing.equal(stripToJarPrefix(url), pointerPrefix, SystemInfo.isFileSystemCaseSensitive) &&
|
||||
StringUtil.startsWith(urlSuffix, stripSuffix(pointerUrl));
|
||||
String urlSuffix = substringAfterJarSeparator(url);
|
||||
String pointerPrefix = substringBeforeJarSeparator(pointerUrl);
|
||||
if (!urlSuffix.isEmpty()) {
|
||||
return Comparing.equal(substringBeforeJarSeparator(url), pointerPrefix, SystemInfo.isFileSystemCaseSensitive) &&
|
||||
StringUtil.startsWith(urlSuffix, substringAfterJarSeparator(pointerUrl));
|
||||
}
|
||||
|
||||
return FileUtil.startsWith(pointerPrefix, stripToJarPrefix(url));
|
||||
return FileUtil.startsWith(pointerPrefix, substringBeforeJarSeparator(url));
|
||||
}
|
||||
|
||||
private static String stripToJarPrefix(String url) {
|
||||
private static String substringBeforeJarSeparator(String url) {
|
||||
int separatorIndex = url.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
if (separatorIndex < 0) return url;
|
||||
return url.substring(0, separatorIndex);
|
||||
}
|
||||
|
||||
private static String stripSuffix(String url) {
|
||||
private static String substringAfterJarSeparator(String url) {
|
||||
int separatorIndex = url.indexOf(JarFileSystem.JAR_SEPARATOR);
|
||||
if (separatorIndex < 0) return "";
|
||||
return url.substring(separatorIndex + JarFileSystem.JAR_SEPARATOR.length());
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
|
||||
@@ -76,11 +77,10 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
|
||||
|
||||
String[] jarPaths;
|
||||
synchronized (LOCK) {
|
||||
if (jarPathsCache == null) {
|
||||
Set<String> jarPathsSet = myHandlers.keySet();
|
||||
jarPathsCache = jarPathsSet.toArray(new String[jarPathsSet.size()]);
|
||||
}
|
||||
jarPaths = jarPathsCache;
|
||||
if (jarPaths == null) {
|
||||
jarPathsCache = jarPaths = ArrayUtil.toStringArray(myHandlers.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
for (String jarPath : jarPaths) {
|
||||
|
||||
@@ -164,7 +164,7 @@ public class GitVcsPanel {
|
||||
!crlfPolicyItem(settings).equals(myConvertTextFilesComboBox.getSelectedItem()) ||
|
||||
!settings.autoUpdateIfPushRejected() == myAutoUpdateIfPushRejected.isSelected() ||
|
||||
((settings.getSyncSetting() == GitBranchSyncSetting.SYNC) != mySyncBranchControl.isSelected() ||
|
||||
settings.isAutoCommitOnCherryPick() == myAutoCommitOnCherryPick.isSelected());
|
||||
settings.isAutoCommitOnCherryPick() != myAutoCommitOnCherryPick.isSelected());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,8 +43,8 @@ public class CreateHtmlFileAction extends CreateFileFromTemplateAction implement
|
||||
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
|
||||
builder
|
||||
.setTitle(XmlBundle.message("new.html.file.action"))
|
||||
.addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME)
|
||||
.addKind("HTML5 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME)
|
||||
.addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME)
|
||||
.addKind("HTML4 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME)
|
||||
.addKind("XHTML file", StdFileTypes.XHTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,8 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDefaultHtmlDoctype(@NotNull Project project) {
|
||||
return getProjectResources(project).myDefaultHtmlDoctype;
|
||||
final String doctype = getProjectResources(project).myDefaultHtmlDoctype;
|
||||
return XmlUtil.XHTML_URI.equals(doctype) ? XmlUtil.XHTML4_SCHEMA_LOCATION : doctype;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,7 +80,7 @@ public class HtmlLanguageLevelForm {
|
||||
}
|
||||
|
||||
public void resetFromDoctype(String doctype) {
|
||||
if (doctype == null || doctype.length() == 0 || doctype.equals(XmlUtil.XHTML_URI)) {
|
||||
if (doctype == null || doctype.length() == 0 || doctype.equals(XmlUtil.XHTML4_SCHEMA_LOCATION)) {
|
||||
myHtml4RadioButton.setSelected(true);
|
||||
myDoctypeTextField.setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import com.intellij.xml.Html5SchemaProvider;
|
||||
import com.intellij.xml.XmlExtension;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.util.XmlNSDescriptorSequence;
|
||||
@@ -207,12 +208,19 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
|
||||
if (nsDescriptor == null) {
|
||||
String htmlns = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(getProject());
|
||||
if (htmlns == null || htmlns.length() == 0) {
|
||||
htmlns = XmlUtil.XHTML_URI;
|
||||
htmlns = Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
nsDescriptor = getDefaultNSDescriptor(htmlns, false);
|
||||
}
|
||||
return new HtmlNSDescriptorImpl(nsDescriptor);
|
||||
}
|
||||
else if (XmlUtil.XHTML_URI.equals(namespace)) {
|
||||
String xhtmlNamespace = XmlUtil.getDefaultXhtmlNamespace(getProject());
|
||||
if (xhtmlNamespace == null || xhtmlNamespace.length() == 0) {
|
||||
xhtmlNamespace = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
return getDefaultNSDescriptor(xhtmlNamespace, false);
|
||||
}
|
||||
else if (namespace != null && namespace != XmlUtil.EMPTY_URI) {
|
||||
if (doctype == null || !namespace.equals(XmlUtil.getDtdUri(doctype))) {
|
||||
boolean documentIsSchemaThatDefinesNs = namespace.equals(XmlUtil.getTargetSchemaNsFromTag(getRootTag()));
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.completion.CompletionUtil;
|
||||
import com.intellij.codeInsight.daemon.Validator;
|
||||
import com.intellij.javaee.ExternalResourceManager;
|
||||
import com.intellij.javaee.ExternalResourceManagerEx;
|
||||
import com.intellij.javaee.ExternalResourceManagerImpl;
|
||||
import com.intellij.javaee.UriUtil;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
@@ -35,9 +36,11 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.patterns.StandardPatterns;
|
||||
import com.intellij.patterns.StringPattern;
|
||||
@@ -74,6 +77,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -152,10 +156,16 @@ public class XmlUtil {
|
||||
@NonNls public static final String WSDL_SCHEMA_URI = "http://schemas.xmlsoap.org/wsdl/";
|
||||
public static final Key<PsiAnchor> ORIGINAL_ELEMENT = Key.create("ORIGINAL_ELEMENT");
|
||||
|
||||
public static final String XHTML4_SCHEMA_LOCATION;
|
||||
|
||||
private XmlUtil() {
|
||||
}
|
||||
|
||||
static {
|
||||
final URL xhtml4SchemaLocationUrl = XmlUtil.class.getResource(ExternalResourceManagerImpl.STANDARD_SCHEMAS + "xhtml1-transitional.xsd");
|
||||
XHTML4_SCHEMA_LOCATION = VfsUtil.urlToPath(VfsUtil.fixURLforIDEA(FileUtil.unquote(xhtml4SchemaLocationUrl.toExternalForm())));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getSchemaLocation(XmlTag tag, String namespace) {
|
||||
final String uri = ExternalResourceManagerEx.getInstanceEx().getResourceLocation(namespace, tag.getProject());
|
||||
@@ -604,11 +614,10 @@ public class XmlUtil {
|
||||
}
|
||||
|
||||
public static String getDefaultXhtmlNamespace(Project project) {
|
||||
String defaultHtmlDoctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project);
|
||||
if (Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(defaultHtmlDoctype)) {
|
||||
defaultHtmlDoctype = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
return defaultHtmlDoctype;
|
||||
final String doctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project);
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(doctype)
|
||||
? Html5SchemaProvider.XHTML5_SCHEMA_LOCATION
|
||||
: doctype;
|
||||
}
|
||||
//
|
||||
//public static void expandTag(@NotNull XmlTag tag) {
|
||||
|
||||
Reference in New Issue
Block a user