Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vladimir.Orlov
2016-03-01 16:25:51 +03:00
35 changed files with 327 additions and 244 deletions
+45 -127
View File
@@ -3,42 +3,6 @@
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="JAVA_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="8" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</value>
</option>
<option name="JSP_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</value>
</option>
<option name="XML_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</value>
</option>
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
@@ -51,47 +15,27 @@
<option name="USE_RELATIVE_INDENTS" value="false" />
</value>
</option>
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="FIELD_NAME_PREFIX" value="my" />
<option name="STATIC_FIELD_NAME_PREFIX" value="our" />
<option name="PREFER_LONGER_NAMES" value="false" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value>
<package name="java.awt" withSubpackages="false" static="false" />
<package name="javax.tools" withSubpackages="true" static="false" />
<package name="javax.swing" withSubpackages="false" static="false" />
</value>
</option>
<option name="STATIC_METHODS_ORDER_WEIGHT" value="5" />
<option name="METHODS_ORDER_WEIGHT" value="4" />
<option name="RIGHT_MARGIN" value="140" />
<option name="FORMATTER_TAGS_ENABLED" value="true" />
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="THROWS_LIST_WRAP" value="5" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="THROWS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="1" />
<option name="DOWHILE_BRACE_FORCE" value="1" />
<option name="WHILE_BRACE_FORCE" value="1" />
<option name="FOR_BRACE_FORCE" value="1" />
<option name="FIELD_ANNOTATION_WRAP" value="0" />
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="CFML">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
@@ -108,7 +52,6 @@
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="ECMA Script Level 4">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
@@ -133,13 +76,8 @@
<option name="FOR_BRACE_FORCE" value="1" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="GSP">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Groovy">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
@@ -168,6 +106,8 @@
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="8" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="HTML">
@@ -180,7 +120,8 @@
<codeStyleSettings language="JAVA">
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="BLOCK_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
@@ -192,6 +133,7 @@
<option name="ALIGN_MULTILINE_THROWS_LIST" value="true" />
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION" value="true" />
<option name="SPACE_WITHIN_BRACES" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
@@ -218,19 +160,7 @@
<option name="TAB_SIZE" value="8" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JSON">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="JSP">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JavaScript">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
@@ -251,38 +181,35 @@
<option name="WHILE_BRACE_FORCE" value="1" />
<option name="FOR_BRACE_FORCE" value="1" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="PHP">
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="CLASS_BRACE_STYLE" value="1" />
<option name="METHOD_BRACE_STYLE" value="1" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="IF_BRACE_FORCE" value="1" />
<option name="DOWHILE_BRACE_FORCE" value="1" />
<option name="WHILE_BRACE_FORCE" value="1" />
<option name="FOR_BRACE_FORCE" value="1" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="Python">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="SQL">
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="TypeScript">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="EXTENDS_LIST_WRAP" value="1" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" />
<option name="ASSIGNMENT_WRAP" value="1" />
<option name="IF_BRACE_FORCE" value="1" />
<option name="DOWHILE_BRACE_FORCE" value="1" />
<option name="WHILE_BRACE_FORCE" value="1" />
<option name="FOR_BRACE_FORCE" value="1" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="XML">
@@ -303,15 +230,6 @@
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="ruby">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="8" />
<option name="TAB_SIZE" value="4" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</indentOptions>
</codeStyleSettings>
</value>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
@@ -186,7 +186,7 @@ public class DebugProcessEvents extends DebugProcessImpl {
// check if there is already one request with policy SUSPEND_ALL
for (SuspendContextImpl context : getSuspendManager().getEventContexts()) {
if (context.getSuspendPolicy() == EventRequest.SUSPEND_ALL) {
if (isResumeOnlyCurrentThread() && locatableEvent != null) {
if (isResumeOnlyCurrentThread() && locatableEvent != null && !context.isEvaluating()) {
// if step event is present - switch context
getSuspendManager().resume(context);
//((SuspendManagerImpl)getSuspendManager()).popContext(context);
@@ -69,7 +69,7 @@ public class SameParameterValueInspection extends SameParameterValueInspectionBa
@Override
@NotNull
public String getFamilyName() {
return getName();
return InspectionsBundle.message("inspection.same.parameter.fix.family.name");
}
@Override
@@ -119,7 +119,8 @@ public class AssignableFromFilter implements ElementFilter{
expectedType,
false,
PsiUtil.getLanguageLevel(place));
if (substitutionForParameter != PsiType.NULL && !(substitutionForParameter instanceof PsiIntersectionType)) {
if (substitutionForParameter != PsiType.NULL && !(substitutionForParameter instanceof PsiIntersectionType) &&
PsiUtil.resolveClassInClassTypeOnly(substitutionForParameter) != parameter) {
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 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.
@@ -17,18 +17,12 @@ package com.intellij.ide.highlighter;
import com.intellij.ide.structureView.StructureViewBuilder;
import com.intellij.ide.structureView.StructureViewBuilderProvider;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.ide.structureView.impl.java.JavaFileTreeModel;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageStructureViewBuilder;
import com.intellij.lang.PsiStructureViewFactory;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.PsiCompiledFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.annotations.NotNull;
@@ -41,28 +35,21 @@ public class JavaClsStructureViewBuilderProvider implements StructureViewBuilder
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull FileType fileType, @NotNull VirtualFile file, @NotNull Project project) {
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (fileType == JavaClassFileType.INSTANCE) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (fileType == JavaClassFileType.INSTANCE && psiFile != null) {
Language language = psiFile.getLanguage();
if (language != JavaLanguage.INSTANCE) {
PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
if (psiFile instanceof PsiCompiledFile) {
psiFile = ((PsiCompiledFile)psiFile).getDecompiledPsiFile();
}
if (psiFile != null) {
PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage());
if (factory != null) {
return factory.getStructureViewBuilder(psiFile);
}
}
}
if (psiFile instanceof PsiClassOwner) {
return new TreeBasedStructureViewBuilder() {
@Override
@NotNull
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
return new JavaFileTreeModel((PsiClassOwner)psiFile, editor);
}
};
}
return null;
}
}
@@ -0,0 +1,13 @@
class A {
{
Func2<String,String> f = ge<caret>x
}
<T,V> Func1<T,V> get1() {}
<T,V> Func2<T,V> get2() {}
}
interface Func1<T, V> {}
interface Func2<T, V> {}
@@ -175,4 +175,9 @@ public void testConvertToObjectStream() {
}
checkResultByFile("/" + getTestName(false) + "-out.java");
}
public void testOnlyCompatibleTypes() {
configureByTestName();
assertOrderedEquals(myFixture.getLookupElementStrings(), "get2");
}
}
@@ -1232,4 +1232,9 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
private CommonCodeStyleSettings getCodeStyleSettings() {
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
}
public void testOnlyCompatibleTypes() {
configureByTestName();
assertOrderedEquals(myFixture.getLookupElementStrings(), "get2");
}
}
@@ -71,7 +71,6 @@ import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.InputEvent;
@@ -399,16 +398,16 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
TreePath pathSelected = myTree.getSelectionModel().getLeadSelectionPath();
if (pathSelected != null) {
final InspectionTreeNode node = (InspectionTreeNode)pathSelected.getLastPathComponent();
if (node instanceof RefElementNode) {
final RefElementNode refElementNode = (RefElementNode)node;
final RefEntity refSelected = refElementNode.getElement();
showInRightPanel(refSelected);
}
else if (node instanceof ProblemDescriptionNode) {
if (node instanceof ProblemDescriptionNode) {
final ProblemDescriptionNode problemNode = (ProblemDescriptionNode)node;
showInRightPanel(problemNode.getElement());
}
else if (node instanceof InspectionNode || node instanceof InspectionPackageNode || node instanceof InspectionModuleNode) {
else if (node instanceof InspectionPackageNode ||
node instanceof InspectionModuleNode ||
node instanceof RefElementNode) {
showInRightPanel(node.getContainingFileLocalEntity());
}
else if (node instanceof InspectionNode) {
showInRightPanel(null);
}
else if (node instanceof InspectionRootNode || node instanceof InspectionGroupNode || node instanceof InspectionSeverityGroupNode) {
@@ -499,7 +498,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
myPreviewEditor.getCaretModel().moveToOffset(finalSelectedElement.getTextOffset());
myPreviewEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}, ModalityState.NON_MODAL);
}, ModalityState.any());
}
return myPreviewEditor.getComponent();
}
@@ -16,6 +16,7 @@
package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.vcs.FileStatus;
import org.jetbrains.annotations.Nullable;
@@ -109,4 +110,17 @@ public abstract class InspectionTreeNode extends DefaultMutableTreeNode {
}
}
public RefEntity getContainingFileLocalEntity() {
final Enumeration children = children();
RefEntity current = null;
while (children.hasMoreElements()) {
InspectionTreeNode child = (InspectionTreeNode)children.nextElement();
final RefEntity entity = child.getContainingFileLocalEntity();
if (entity == null || current != null) {
return null;
}
current = entity;
}
return current;
}
}
@@ -18,6 +18,7 @@ package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.CommonProblemDescriptor;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.reference.RefDirectory;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefEntity;
import com.intellij.openapi.util.Computable;
@@ -124,4 +125,11 @@ public class RefElementNode extends InspectionTreeNode {
return mySingleDescriptor;
}
@Override
public RefEntity getContainingFileLocalEntity() {
final RefEntity element = getElement();
return element instanceof RefElement && !(element instanceof RefDirectory)
? element
: super.getContainingFileLocalEntity();
}
}
@@ -81,7 +81,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
}
public static boolean newEnabled() {
return Registry.is("ide.new.notification.enabled", false);
return ApplicationManager.getApplication().isInternal() && Registry.is("ide.new.notification.enabled", false);
}
@Override
@@ -227,7 +227,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
final ProjectManager projectManager = ProjectManager.getInstance();
final boolean noProjects = projectManager.getOpenProjects().length == 0;
final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
Ref<Object> layoutDataRef = newEnabled() && notification.getIcon() != null ? new Ref<Object>() : null;
Ref<Object> layoutDataRef = newEnabled() ? new Ref<Object>() : null;
final Balloon balloon = createBalloon((IdeFrame)window, notification, false, false, layoutDataRef);
Disposer.register(project != null ? project : ApplicationManager.getApplication(), balloon);
@@ -298,6 +298,10 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
return myStatusBar;
}
public int getStatusBarHeight() {
return myStatusBar.isVisible() ? myStatusBar.getHeight() : 0;
}
private void updateToolbarVisibility(){
myToolbar.setVisible(myUISettings.SHOW_MAIN_TOOLBAR && !UISettings.getInstance().PRESENTATION_MODE);
}
@@ -445,6 +445,10 @@ public final class ToolWindowsPane extends JBLayeredPane implements Disposable {
}
}
public int getBottomHeight() {
return myBottomStripe.isVisible() ? myBottomStripe.getHeight() : 0;
}
@Nullable
Stripe getStripeFor(String id) {
ToolWindow window = myManager.getToolWindow(id);
@@ -37,9 +37,6 @@ public interface DirectoryProjectGenerator<T> {
@Nls
String getName();
@Nullable
T showGenerationSettings(final VirtualFile baseDir) throws ProcessCanceledException;
/**
* @return 16x16 icon or null, if no icon is available
*/
@@ -57,18 +57,6 @@ public abstract class WebProjectGenerator<T> implements DirectoryProjectGenerato
return null;
}
@Override
@NotNull
public final T showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
GeneratorPeer<T> peer = createPeer();
DialogWrapper dialog = new MyDialogWrapper(peer);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
throw new ProcessCanceledException();
}
return peer.getSettings();
}
@Override
public abstract void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull T settings, @NotNull Module module);
@@ -17,9 +17,11 @@ package com.intellij.ui;
import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.LafManagerListener;
import com.intellij.notification.impl.NotificationsManagerImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.wm.impl.IdeRootPane;
import com.intellij.openapi.wm.impl.ToolWindowsPane;
import com.intellij.util.Alarm;
import com.intellij.util.ui.JBInsets;
@@ -162,7 +164,7 @@ public class BalloonLayoutImpl implements BalloonLayout {
private void calculateSize() {
myWidth = null;
if (myLayoutData.isEmpty()) {
if (myLayoutData.isEmpty() && !NotificationsManagerImpl.newEnabled()) {
return;
}
@@ -199,6 +201,11 @@ public class BalloonLayoutImpl implements BalloonLayout {
JComponent layeredPane = pane != null ? pane.getMyLayeredPane() : null;
int eachColumnX = (layeredPane == null ? myLayeredPane.getWidth() : layeredPane.getX() + layeredPane.getWidth()) - 4;
if (NotificationsManagerImpl.newEnabled()) {
newLayout(columns.get(0), eachColumnX + 4, (int)myLayeredPane.getBounds().getMaxY());
return;
}
if (myLayoutData.isEmpty()) {
for (int i = 0; i < columns.size(); i++) {
final ArrayList<Balloon> eachColumn = columns.get(i);
@@ -282,6 +289,24 @@ public class BalloonLayoutImpl implements BalloonLayout {
}
}
private void newLayout(List<Balloon> balloons, int startX, int bottomY) {
int y = bottomY;
ToolWindowsPane pane = UIUtil.findComponentOfType(myParent, ToolWindowsPane.class);
if (pane != null) {
y -= pane.getBottomHeight();
}
if (myParent instanceof IdeRootPane) {
y -= ((IdeRootPane)myParent).getStatusBarHeight();
}
for (Balloon balloon : balloons) {
Rectangle bounds = new Rectangle(getSize(balloon));
y -= bounds.height;
bounds.setLocation(startX - bounds.width, y);
balloon.setBounds(bounds);
}
}
private List<Integer> computeWidths(List<ArrayList<Balloon>> columns) {
List<Integer> columnWidths = new ArrayList<Integer>();
for (ArrayList<Balloon> eachColumn : columns) {
@@ -672,6 +672,7 @@ unused.library.roots.problem.descriptor=Unused roots {0} from library ''{1}''
unused.library.backward.analysis.job.description=Perform backward analysis
inspection.duplicates.option.report.propertykey.expressions=&Ignore @PropertyKey expressions
inspection.same.parameter.fix.name=Inline value ''{1}'' for parameter ''{0}''
inspection.same.parameter.fix.family.name=Inline parameter as constant value
fix.all.inspection.problems.in.file=Fix all ''{0}'' problems in file
cleanup.in.file=Cleanup code
cleanup.in.scope=Cleanup code on...
@@ -385,8 +385,15 @@ public class PlatformTestUtil {
return print(tree, false);
}
public static void assertTreeStructureEquals(final AbstractTreeStructure treeStructure, final String expected) {
Assert.assertEquals(expected, print(treeStructure, treeStructure.getRootElement(), 0, null, -1, ' ', null).toString());
public static void updateRecursively(@NotNull AbstractTreeNode<?> node) {
node.update();
for (AbstractTreeNode child : node.getChildren()) {
updateRecursively(child);
}
}
public static void assertTreeStructureEquals(@NotNull AbstractTreeStructure treeStructure, @NotNull String expected) {
Assert.assertEquals(expected.trim(), print(treeStructure, treeStructure.getRootElement(), 0, null, -1, ' ', null).toString().trim());
}
public static void invokeNamedAction(final String actionId) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 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.
@@ -28,7 +28,6 @@ public class ColorIcon extends EmptyIcon {
private boolean myBorder;
private int myColorSize;
public ColorIcon(int size, int colorSize, @NotNull Color color, final boolean border) {
super(size, size);
myColor = color;
@@ -53,18 +52,29 @@ public class ColorIcon extends EmptyIcon {
final int iconWidth = getIconWidth();
final int iconHeight = getIconHeight();
g.setColor(getIconColor());
final int size = getColorSize();
final int x = i + (iconWidth - size) / 2;
final int y = j + (iconHeight - size) / 2;
final int x = i + (iconWidth - myColorSize) / 2;
final int y = j + (iconHeight - myColorSize) / 2;
g.fillRect(x, y, myColorSize, myColorSize);
g.fillRect(x, y, size, size);
if (myBorder) {
g.setColor(Gray.x00.withAlpha(40));
g.drawRect(x, y, myColorSize, myColorSize);
g.drawRect(x, y, size, size);
}
}
protected int getColorSize() {
return scale(myColorSize);
}
@Override
protected EmptyIcon createScaledInstance(float scale) {
return new ColorIcon(getIconWidth(), myColorSize, myColor, myBorder);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -41,7 +41,8 @@ public class EmptyIcon implements Icon, ScalableIcon {
private final int width;
private final int height;
private float scale = 1f;
protected float scale = 1f;
private EmptyIcon myScaledCache;
public static Icon create(int size) {
Icon icon = cache.get(size);
@@ -80,12 +81,12 @@ public class EmptyIcon implements Icon, ScalableIcon {
@Override
public int getIconWidth() {
return scale == 1f ? width : (int) (width * scale);
return scale(width);
}
@Override
public int getIconHeight() {
return scale == 1f ? height : (int) (height * scale);
return scale(height);
}
@Override
@@ -117,19 +118,33 @@ public class EmptyIcon implements Icon, ScalableIcon {
return new EmptyIconUIResource(this);
}
protected int scale(int n) {
return scale == 1f ? n : (int) (n * scale);
}
@Override
public Icon scale(float scaleFactor) {
if (scaleFactor != scale) {
EmptyIcon icon;
if (scale != 1f) {
icon = this;
} else {
icon = this instanceof UIResource ? new EmptyIconUIResource(width, height) : new EmptyIcon(width, height);
}
icon.scale = scaleFactor;
return icon;
if (scale == scaleFactor) {
return this;
}
return this;
if (myScaledCache != null && myScaledCache.scale == scaleFactor) {
return myScaledCache;
}
myScaledCache = createScaledInstance(scaleFactor);
myScaledCache.scale = scaleFactor;
return myScaledCache;
}
protected EmptyIcon createScaledInstance(float scale) {
final EmptyIcon icon;
if (scale != 1f) {
icon = this;
} else {
icon = this instanceof UIResource ? new EmptyIconUIResource(width, height) : new EmptyIcon(width, height);
}
return icon;
}
public static class EmptyIconUIResource extends EmptyIcon implements UIResource {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 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.
@@ -15,6 +15,9 @@
*/
package com.intellij.util.ui;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -22,45 +25,59 @@ import java.awt.*;
import java.awt.image.BufferedImage;
/**
* User: Vassiliy.Kudryashov
* @author Vassiliy Kudryashov
* @author Konstantin Bulenkov
*/
public class TwoColorsIcon extends EmptyIcon {
@NotNull private final Paint myColor1;
@NotNull private final Paint myColor2;
private static final int SQUARE_SIZE = 6;
public class TwoColorsIcon extends ColorIcon {
@NotNull private final Color mySecondColor;
private static final int SQUARE_SIZE = JBUI.scale(6);
private static final BufferedImage CHESS_IMAGE = UIUtil.createImage(SQUARE_SIZE, SQUARE_SIZE, BufferedImage.TYPE_INT_RGB);
private static final TexturePaint CHESS;
static {
Graphics2D graphics = CHESS_IMAGE.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
graphics.setColor(Color.LIGHT_GRAY);
graphics.setColor(JBColor.LIGHT_GRAY);
graphics.fillRect(0, 0, SQUARE_SIZE + 1, SQUARE_SIZE + 1);
graphics.setColor(Color.GRAY);
graphics.setColor(JBColor.GRAY);
graphics.fillRect(0, 0, SQUARE_SIZE / 2, SQUARE_SIZE / 2);
graphics.fillRect(SQUARE_SIZE / 2, SQUARE_SIZE / 2, SQUARE_SIZE / 2, SQUARE_SIZE / 2);
graphics.dispose();
CHESS = new TexturePaint(CHESS_IMAGE, new Rectangle(0, 0, SQUARE_SIZE, SQUARE_SIZE));
}
private TexturePaint CHESS = new TexturePaint(CHESS_IMAGE, new Rectangle(0, 0, SQUARE_SIZE, SQUARE_SIZE));
public TwoColorsIcon(int size, @Nullable Color color1, @Nullable Color color2) {
super(size, size);
myColor1 = color1 != null ? color1 : CHESS;
myColor2 = color2 != null ? color2 : CHESS;
public TwoColorsIcon(int size, @Nullable Color color1, @Nullable Color secondColor) {
super(size, size, color1 != null ? color1 : Gray.TRANSPARENT, false);
mySecondColor = secondColor != null ? secondColor : Gray.TRANSPARENT;
}
@Override
public void paintIcon(final Component component, final Graphics g, final int x, final int y) {
public void paintIcon(final Component component, Graphics g, int x, int y) {
Graphics2D g2d = (Graphics2D)g.create();
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g2d);
try {
final int w = getIconWidth();
final int h = getIconHeight();
GraphicsUtil.setupAAPainting(g2d);
g2d.setPaint(myColor1);
g2d.setPaint(getPaint(getIconColor()));
g2d.fillPolygon(new int[]{x, x + w, x}, new int[]{y, y, y + h}, 3);
g2d.setPaint(myColor2);
g2d.setPaint(getPaint(mySecondColor));
g2d.fillPolygon(new int[]{x + w, x + w, x}, new int[]{y, y + h, y + h}, 3);
}
catch (Exception e) {
g2d.dispose();
}
finally {
config.restore();
}
}
protected Paint getPaint(Color color) {
return color == null || color.getAlpha() == 0 ? CHESS : color;
}
@Override
protected EmptyIcon createScaledInstance(float scale) {
return new TwoColorsIcon(getColorSize(), getIconColor(), mySecondColor);
}
@Override
@@ -73,16 +90,14 @@ public class TwoColorsIcon extends EmptyIcon {
if (getIconWidth() != icon.getIconWidth()) return false;
if (getIconHeight() != icon.getIconHeight()) return false;
if (!myColor1.equals(icon.myColor1)) return false;
if (!myColor2.equals(icon.myColor2)) return false;
if (!mySecondColor.equals(icon.mySecondColor)) return false;
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + myColor1.hashCode();
result = 31 * result + myColor2.hashCode();
result = 31 * result + mySecondColor.hashCode();
return result;
}
}
@@ -88,13 +88,20 @@ public class OptionalGetWithoutIsPresentInspection extends BaseInspection {
final PsiIfStatement ifStatement = (PsiIfStatement)sibling;
final PsiExpression condition = ifStatement.getCondition();
if (condition != null) {
if (!ControlFlowUtils.statementMayCompleteNormally(ifStatement.getThenBranch())) {
final PsiElement target = optionalReference.resolve();
if (!(target instanceof PsiVariable)) {
return true;
}
final PsiVariable variable = (PsiVariable)target;
final PsiStatement thenBranch = ifStatement.getThenBranch();
if (!ControlFlowUtils.statementMayCompleteNormally(thenBranch) || VariableAccessUtils.variableIsAssigned(variable, thenBranch)) {
checker.negate = true;
if (checker.checkExpression(condition)) {
return true;
}
}
else if (!ControlFlowUtils.statementMayCompleteNormally(ifStatement.getElseBranch())) {
final PsiStatement elseBranch = ifStatement.getElseBranch();
if (!ControlFlowUtils.statementMayCompleteNormally(elseBranch) || VariableAccessUtils.variableIsAssigned(variable, elseBranch)) {
checker.negate = false;
if (checker.checkExpression(condition)) {
return true;
@@ -50,4 +50,14 @@ class OptionalWithoutIsPresent {
org.testng.Assert.assertTrue(o3.isPresent());
System.out.println(o3.get());
}
public static String demo() {
Optional<String> holder = Optional.empty();
if (! holder.isPresent()) {
holder = Optional.of("hello world");
}
return holder.get();
}
}
@@ -79,6 +79,9 @@ public class OptionalGetWithoutIsPresentInspectionTest extends LightInspectionTe
" public static<T> Optional<T> empty() {" +
" return new Optional<>();" +
" }" +
" public static <T> Optional<T> of(T value) {" +
" return new Optional<>(value);" +
" }" +
"}",
"package java.util;" +
@@ -19,11 +19,17 @@ import com.intellij.codeInsight.daemon.impl.IdentifierHighlighterPassFactory
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction
import com.intellij.execution.filters.LineNumbersMapping
import com.intellij.ide.highlighter.ArchiveFileType
import com.intellij.ide.structureView.StructureViewBuilder
import com.intellij.ide.structureView.impl.java.JavaAnonymousClassesNodeProvider
import com.intellij.ide.structureView.newStructureView.StructureViewComponent
import com.intellij.ide.util.treeView.AbstractTreeNode
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.application.PluginPathManager
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileTypes.StdFileTypes
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.util.registry.RegistryValue
@@ -157,6 +163,32 @@ class IdeaDecompilerTest : LightCodeInsightFixtureTestCase() {
catch (ignored: ProcessCanceledException) { }
}
fun testStructureView() {
val file = getTestFile("StructureView.class")
file.parent.children ; file.parent.refresh(false, true) // inner classes
val editor = FileEditorManager.getInstance(project).openFile(file, false)[0]
val builder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(StdFileTypes.CLASS, file, project)!!
val viewComponent = builder.createStructureView(editor, project) as StructureViewComponent
Disposer.register(testRootDisposable, viewComponent)
viewComponent.setActionActive(JavaAnonymousClassesNodeProvider.ID, true)
val treeStructure = viewComponent.treeStructure
PlatformTestUtil.updateRecursively(treeStructure.rootElement as AbstractTreeNode<*>)
PlatformTestUtil.assertTreeStructureEquals(treeStructure, """
StructureView.java
StructureView
B
B()
build(int): StructureView
$1
class initializer
StructureView()
getData(): int
setData(int): void
data: int""".trimIndent())
}
private fun getTestFile(name: String): VirtualFile {
val path = if (FileUtil.isAbsolute(name)) name else "${myFixture.testDataPath}/${name}"
@@ -0,0 +1,19 @@
class StructureView {
private int data;
public final int getData() {
return data;
}
protected void setData(int data) {
this.data = data;
}
public static class B {
public static StructureView build(int data) {
return new StructureView() {
{ setData(data); }
};
}
}
}
@@ -51,7 +51,7 @@ public class EduAnswerPlaceholderPainter {
public static void createGuardedBlock(Editor editor, List<RangeMarker> blocks, int start, int end) {
RangeHighlighter rh = editor.getMarkupModel()
.addRangeHighlighter(start, end, HighlighterLayer.LAST + 1, null, HighlighterTargetArea.EXACT_RANGE);
.addRangeHighlighter(start, end, PLACEHOLDERS_LAYER, null, HighlighterTargetArea.EXACT_RANGE);
blocks.add(rh);
}
@@ -126,16 +126,30 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
StudyStatus taskFileStatus = getStatus(taskFile);
if (taskFileStatus == StudyStatus.Unchecked) {
task.setStatus(StudyStatus.Unchecked);
removeObsoleteTaskStatus(task);
return StudyStatus.Unchecked;
}
if (taskFileStatus == StudyStatus.Failed) {
task.setStatus(StudyStatus.Failed);
removeObsoleteTaskStatus(task);
return StudyStatus.Failed;
}
}
task.setStatus(StudyStatus.Solved);
removeObsoleteTaskStatus(task);
return StudyStatus.Solved;
}
private void removeObsoleteTaskStatus(Task task) {
for (TaskFile taskFile: task.taskFiles.values()) {
myTaskStatusMap.remove(taskFile);
for (AnswerPlaceholder answerPlaceholder: taskFile.getAnswerPlaceholders()) {
myStudyStatusMap.remove(answerPlaceholder);
}
}
}
private StudyStatus getStatus(@NotNull final TaskFile file) {
if (file.getAnswerPlaceholders().isEmpty()) {
@@ -39,12 +39,6 @@ public class PyCCProjectGenerator extends PythonProjectGenerator implements Dire
return "Course creation";
}
@Nullable
@Override
public Object showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
return null;
}
@Nullable
@Override
public Icon getLogo() {
@@ -49,12 +49,6 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator imp
return "Educational";
}
@Nullable
@Override
public Object showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
return null;
}
@Nullable
@Override
public Icon getLogo() {
@@ -42,12 +42,6 @@ public class PythonBaseProjectGenerator extends PythonProjectGenerator implement
return "Pure Python";
}
@Nullable
@Override
public Object showGenerationSettings(VirtualFile baseDir) throws ProcessCanceledException {
return null;
}
@Override
@Nullable
public JComponent getSettingsPanel(File baseDir) throws ProcessCanceledException {