diff --git a/build/lib/gant/jps-sources.zip b/build/lib/gant/jps-sources.zip index 985632f5cc3d..43b79e0d3a5e 100644 Binary files a/build/lib/gant/jps-sources.zip and b/build/lib/gant/jps-sources.zip differ diff --git a/build/lib/gant/lib/jps.jar b/build/lib/gant/lib/jps.jar index 34cb9fa28de0..74b65ee1b81c 100644 Binary files a/build/lib/gant/lib/jps.jar and b/build/lib/gant/lib/jps.jar differ diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 8974a752cbf2..912428c2ace7 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -66,6 +66,12 @@ binding.setVariable("guessHome", { binding.setVariable("loadProject", { requireProperty("jdkHome", requireProperty("jdk16.home", guessJdk())) + def mac = isMac() + jdk("IDEA jdk", jdkHome) { + if (!mac) { + classpath "$jdkHome/lib/tools.jar" + } + } IdeaProjectLoader.loadFromPath(project, "${home}") binding.ant.patternset(id: "idea.compiler.resources") { @@ -77,12 +83,6 @@ binding.setVariable("loadProject", { } project["compiler.resources.id"] = "idea.compiler.resources" - - if (!isMac()) { - project.modules.values().each { - it.classpath << project.resolve("$jdkHome/lib/tools.jar") - } - } }) requireProperty("home", guessHome()) diff --git a/platform/lang-api/src/com/intellij/codeInsight/editorActions/JoinLinesHandlerDelegate.java b/platform/lang-api/src/com/intellij/codeInsight/editorActions/JoinLinesHandlerDelegate.java index afc22efb51a7..208695d30676 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/editorActions/JoinLinesHandlerDelegate.java +++ b/platform/lang-api/src/com/intellij/codeInsight/editorActions/JoinLinesHandlerDelegate.java @@ -25,6 +25,7 @@ import com.intellij.psi.PsiFile; */ public interface JoinLinesHandlerDelegate { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.joinLinesHandler"); + int CANNOT_JOIN = -1; /** * Tries to join lines at the specified position of the specified file. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index e4e7f43e179d..6501a6a282fd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -35,11 +35,8 @@ import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.options.FontSize; import com.intellij.openapi.ui.popup.JBPopup; -import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.Ref; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.psi.PsiElement; import com.intellij.psi.SmartPointerManager; @@ -50,6 +47,8 @@ import com.intellij.ui.components.JBScrollPane; import com.intellij.util.Consumer; import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -65,6 +64,13 @@ import java.util.Stack; public class DocumentationComponent extends JPanel implements Disposable { + private static final DataContext EMPTY_DATA_CONTEXT = new DataContext() { + @Override + public Object getData(@NonNls String dataId) { + return null; + } + }; + private static final int MAX_WIDTH = 500; private static final int MAX_HEIGHT = 300; private static final int MIN_HEIGHT = 45; @@ -78,9 +84,10 @@ public class DocumentationComponent extends JPanel implements Disposable { private boolean myIsEmpty; private boolean myIsShown; private final JLabel myElementLabel; - private JBPopup mySettingsPopup; private Style myFontSizeStyle; private JSlider myFontSizeSlider; + private JComponent mySettingsPanel; + private MyShowSettingsButton myShowSettingsButton; private boolean myIgnoreFontSizeSliderChange; private static class Context { @@ -197,6 +204,7 @@ public class DocumentationComponent extends JPanel implements Disposable { final MouseAdapter mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent e) { myManager.requestFocus(); + myShowSettingsButton.hideSettings(); } }; myEditorPane.addMouseListener(mouseAdapter); @@ -224,7 +232,29 @@ public class DocumentationComponent extends JPanel implements Disposable { }); setLayout(new BorderLayout()); - add(myScrollPane, BorderLayout.CENTER); + JLayeredPane layeredPane = new JLayeredPane() { + @Override + public void doLayout() { + final Rectangle r = getBounds(); + for (Component component : getComponents()) { + if (component instanceof JScrollPane) { + component.setBounds(0, 0, r.width, r.height); + } + else { + Dimension d = component.getPreferredSize(); + component.setBounds(r.width - d.width, 2, d.width, d.height); + } + } + } + }; + layeredPane.add(myScrollPane); + layeredPane.setLayer(myScrollPane, 0); + + mySettingsPanel = createSettingsPanel(); + layeredPane.add(mySettingsPanel); + layeredPane.setLayer(mySettingsPanel, JLayeredPane.POPUP_LAYER); + add(layeredPane, BorderLayout.CENTER); + setOpaque(true); myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder()); final DefaultActionGroup actions = new DefaultActionGroup(); @@ -254,7 +284,7 @@ public class DocumentationComponent extends JPanel implements Disposable { myControlPanel.add(myToolBar.getComponent(), BorderLayout.WEST); myControlPanel.add(dummyPanel, BorderLayout.CENTER); - myControlPanel.add(createSettingsButton(), BorderLayout.EAST); + myControlPanel.add(myShowSettingsButton = new MyShowSettingsButton(), BorderLayout.EAST); myControlPanelVisible = false; final HyperlinkListener hyperlinkListener = new HyperlinkListener() { @@ -287,15 +317,16 @@ public class DocumentationComponent extends JPanel implements Disposable { this(manager, null); } - private JComponent createSettingsButton() { - String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel"); - final JPanel fontSizePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - fontSizePanel.add(new JLabel(ApplicationBundle.message("label.font.size"))); + private JComponent createSettingsPanel() { + JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); + result.add(new JLabel(ApplicationBundle.message("label.font.size"))); myFontSizeSlider = new JSlider(JSlider.HORIZONTAL, 0, FontSize.values().length - 1, 3); myFontSizeSlider.setMinorTickSpacing(1); myFontSizeSlider.setPaintTicks(true); + myFontSizeSlider.setPaintTrack(true); myFontSizeSlider.setSnapToTicks(true); - fontSizePanel.add(myFontSizeSlider); + UIUtil.setSliderIsFilled(myFontSizeSlider, true); + result.add(myFontSizeSlider); myFontSizeSlider.addChangeListener(new ChangeListener() { @Override @@ -309,35 +340,14 @@ public class DocumentationComponent extends JPanel implements Disposable { applyFontSize(); } }); - Presentation presentation = new Presentation(); - presentation.setIcon(IconLoader.getIcon("/general/secondaryGroup.png")); - final Ref ref = new Ref(); - ActionButton result = new ActionButton( - new AnAction() { - @Override - public void actionPerformed(AnActionEvent e) { - EditorColorsManager colorsManager = EditorColorsManager.getInstance(); - EditorColorsScheme scheme = colorsManager.getGlobalScheme(); - setFontSizeSliderSize(scheme.getQuickDocFontSize()); - mySettingsPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(fontSizePanel, DocumentationComponent.this) - .setFocusable(false).setBelongsToGlobalPopupStack(false).setCancelCallback(new Computable() { - @Override - public Boolean compute() { - mySettingsPopup = null; - return true; - } - }).createPopup(); - mySettingsPopup.showUnderneathOf(ref.get()); - } - }, - presentation, - ActionPlaces.JAVADOC_INPLACE_SETTINGS, - ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE - ); - ref.set(result); - - fontSizePanel.setToolTipText(tooltipText); + + String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel"); + result.setToolTipText(tooltipText); myFontSizeSlider.setToolTipText(tooltipText); + result.setBorder(IdeBorderFactory.createRoundedBorder()); + result.setVisible(false); + result.setOpaque(true); + myFontSizeSlider.setOpaque(true); return result; } @@ -694,10 +704,45 @@ public class DocumentationComponent extends JPanel implements Disposable { myManager = null; myHint = null; myNavigateCallback = null; - - if (mySettingsPopup != null) { - Disposer.dispose(mySettingsPopup); - mySettingsPopup = null; + } + + private class MyShowSettingsButton extends ActionButton { + + MyShowSettingsButton() { + this(new MyShowSettingsAction(), new Presentation(), ActionPlaces.JAVADOC_INPLACE_SETTINGS, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); + } + + MyShowSettingsButton(AnAction action, Presentation presentation, String place, @NotNull Dimension minimumSize) { + super(action, presentation, place, minimumSize); + myPresentation.setIcon(IconLoader.getIcon("/general/secondaryGroup.png")); + } + + public void hideSettings() { + AnActionEvent event = new AnActionEvent( + null, EMPTY_DATA_CONTEXT, ActionPlaces.JAVADOC_INPLACE_SETTINGS, myPresentation, ActionManager.getInstance(), 0 + ); + myAction.actionPerformed(event); + } + } + + private class MyShowSettingsAction extends ToggleAction { + + @Override + public boolean isSelected(AnActionEvent e) { + return mySettingsPanel.isVisible(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + if (!state) { + mySettingsPanel.setVisible(false); + return; + } + + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + EditorColorsScheme scheme = colorsManager.getGlobalScheme(); + setFontSizeSliderSize(scheme.getQuickDocFontSize()); + mySettingsPanel.setVisible(true); } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinRawLinesHandlerDelegate.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinRawLinesHandlerDelegate.java new file mode 100644 index 000000000000..143ca6ece641 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinRawLinesHandlerDelegate.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Created by IntelliJ IDEA. + * User: max + * Date: May 20, 2002 + * Time: 6:21:42 PM + * To change template for new class use + * Code Style | Class Templates options (Tools | IDE Options). + */ +package com.intellij.codeInsight.editorActions; + +import com.intellij.openapi.editor.Document; +import com.intellij.psi.PsiFile; + +public interface JoinRawLinesHandlerDelegate extends JoinLinesHandlerDelegate { + int tryJoinRawLines(Document document, PsiFile file, int start, int end); +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java index fd6f4e6be567..3b2da4750a33 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java @@ -39,6 +39,7 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; +import com.intellij.ui.HintHint; import com.intellij.ui.LightweightHint; import com.intellij.util.text.StringSearcher; import com.intellij.util.ui.UIUtil; @@ -177,7 +178,7 @@ public class IncrementalSearchHandler { int y = - hint.getComponent().getPreferredSize().height; Point p = SwingUtilities.convertPoint(component,x,y,component.getRootPane().getLayeredPane()); - HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, HintManagerImpl.HIDE_BY_ESCAPE | HintManagerImpl.HIDE_BY_TEXT_CHANGE, 0, false); + HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, p, HintManagerImpl.HIDE_BY_ESCAPE | HintManagerImpl.HIDE_BY_TEXT_CHANGE, 0, false, new HintHint(editor, p).setAwtTooltip(false)); PerHintSearchData hintData = new PerHintSearchData(project, label2); hintData.searchStart = editor.getCaretModel().getOffset(); diff --git a/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java b/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java index e0fd2f392cb1..e25f96811077 100644 --- a/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java +++ b/platform/platform-api/src/com/intellij/ide/util/BrowseFilesListener.java @@ -21,6 +21,7 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.event.ActionEvent; @@ -60,6 +61,10 @@ public class BrowseFilesListener implements ActionListener { return null; } + protected void doSetText(@NotNull final String path) { + myTextField.setText(path); + } + public void actionPerformed( ActionEvent e ) { final VirtualFile fileToSelect = getFileToSelect(); myChooserDescriptor.setTitle(myTitle); // important to set title and description here because a shared descriptor instance can be used @@ -69,7 +74,7 @@ public class BrowseFilesListener implements ActionListener { @Override public void consume(final VirtualFile[] files) { if (files != null && files.length > 0) { - myTextField.setText(files[0].getPath().replace('/', File.separatorChar)); + doSetText(files[0].getPath().replace('/', File.separatorChar)); } } }); diff --git a/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java b/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java index 52272fe91fef..b737d7583ceb 100644 --- a/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java +++ b/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java @@ -18,6 +18,7 @@ package com.intellij.ide.util; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; public abstract class PropertiesComponent { public abstract void unsetValue(String name); @@ -42,6 +43,11 @@ public abstract class PropertiesComponent { public abstract String getValue(@NonNls String name); + @NotNull + public String getValue(@NonNls String name, @NotNull String defaultValue) { + return isValueSet(name) ? getValue(name) : defaultValue; + } + public String getOrInit(@NonNls String name, String defaultValue) { if (!isValueSet(name)) { setValue(name, defaultValue); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java b/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java index 911982812186..c32530cc9f3d 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/GenericLineWrapPositionStrategy.java @@ -59,7 +59,7 @@ public class GenericLineWrapPositionStrategy implements LineWrapPositionStrategy maxPreferredOffsetToUse = maxPreferredOffsetToUse < startOffset ? startOffset : maxPreferredOffsetToUse; // Try to find out wrap position before preferred offset. - for (int i = maxPreferredOffsetToUse; i > startOffset; i--) { + for (int i = Math.min(maxPreferredOffsetToUse, text.length() - 1); i > startOffset; i--) { char c = text.charAt(i); if (c == '\n') { return i + 1; @@ -99,7 +99,7 @@ public class GenericLineWrapPositionStrategy implements LineWrapPositionStrategy // Try to find target offset that is beyond preferred offset. // Note that we don't consider symbol weights here and just break on the first appropriate position. - if (!allowToBeyondMaxPreferredOffset) { + if (!allowToBeyondMaxPreferredOffset || maxPreferredOffset >= text.length() - 1) { return maxPreferredOffset; } for (int i = maxPreferredOffsetToUse + 1; i < endOffset; i++) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 8542f7b9d161..f4796f4d1141 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -238,6 +238,10 @@ public class Messages { return showDialog(project, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon); } + public static int showOkCancelDialog(Component parent, String message, String title, int defaultOptionIndex, int focusedOptionIndex, Icon icon) { + return showDialog(parent, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, defaultOptionIndex, focusedOptionIndex, icon); + } + public static int showOkCancelDialog(Component parent, String message, String title, Icon icon) { return showDialog(parent, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon); } diff --git a/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java b/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java index b0ee757523ba..38dd926187c3 100644 --- a/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java +++ b/platform/platform-api/src/com/intellij/ui/IdeBorderFactory.java @@ -27,6 +27,9 @@ import java.awt.*; public class IdeBorderFactory { public static final int BORDER_ROUNDNESS = 5; + private IdeBorderFactory() { + } + public static Border createBorder() { return createBorder(SideBorder.ALL); } diff --git a/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java b/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java index f31c72ced0b8..04449de5a3ba 100644 --- a/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java +++ b/platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java @@ -33,9 +33,10 @@ public abstract class BaseButtonBehavior { private boolean myPressedByMouse; private boolean mySelected; - private TimedDeadzone myMouseDeadzone; + private int myActionTrigger; + public BaseButtonBehavior(JComponent component) { this(component, TimedDeadzone.DEFAULT); } @@ -45,6 +46,12 @@ public abstract class BaseButtonBehavior { myMouseDeadzone = new TimedDeadzone(mouseDeadzoneTime, Alarm.ThreadToUse.SWING_THREAD); myComponent.addMouseListener(new MyMouseListener()); myComponent.addMouseMotionListener(new MyMouseMotionListener()); + setActionTrigger(MouseEvent.MOUSE_RELEASED); + } + + public void setActionTrigger(int trigger) { + assert trigger == MouseEvent.MOUSE_PRESSED || trigger == MouseEvent.MOUSE_RELEASED; + myActionTrigger = trigger; } public final boolean isHovered() { @@ -111,7 +118,11 @@ public abstract class BaseButtonBehavior { setPressedByMouse(true); - repaintComponent(); + if (myActionTrigger == MouseEvent.MOUSE_PRESSED) { + if (execute(e)) return; + } else { + repaintComponent(); + } } @@ -121,21 +132,30 @@ public abstract class BaseButtonBehavior { setPressedByMouse(false); - Point point = e.getPoint(); - if (point.x < 0 || point.x > myComponent.getWidth()) return; - if (point.y < 0 || point.y > myComponent.getHeight()) return; - - repaintComponent(); - - execute(e); + if (myActionTrigger == MouseEvent.MOUSE_RELEASED) { + if (execute(e)) return; + } else { + repaintComponent(); + } } finally { myWasPressedOnFocusTransfer = false; } } + private boolean execute(MouseEvent e) { + Point point = e.getPoint(); + if (point.x < 0 || point.x > myComponent.getWidth()) return true; + if (point.y < 0 || point.y > myComponent.getHeight()) return true; + + repaintComponent(); + + BaseButtonBehavior.this.execute(e); + return false; + } + private boolean passIfNeeded(final MouseEvent e, boolean considerDeadzone) { - final boolean actionClick = UIUtil.isActionClick(e, MouseEvent.MOUSE_RELEASED) || UIUtil.isActionClick(e, MouseEvent.MOUSE_PRESSED); + final boolean actionClick = UIUtil.isActionClick(e, myActionTrigger); if (!actionClick || (considerDeadzone && myMouseDeadzone.isWithin())) { pass(e); diff --git a/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java index 31f5fb82b90e..93d26be1f868 100644 --- a/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/startup/impl/StartupManagerImpl.java @@ -15,8 +15,10 @@ */ package com.intellij.ide.startup.impl; +import com.intellij.ide.BrowserUtil; import com.intellij.ide.caches.CacheUpdater; import com.intellij.ide.startup.StartupManagerEx; +import com.intellij.notification.*; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -27,12 +29,15 @@ import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.DumbServiceImpl; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; +import javax.swing.event.HyperlinkEvent; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; @@ -144,6 +149,22 @@ public class StartupManagerImpl extends StartupManagerEx { if (!app.isUnitTestMode()) { VirtualFileManager.getInstance().refresh(!app.isHeadlessEnvironment()); } + + if (SystemInfo.isMac && SystemInfo.is64Bit && "10.6".compareTo(SystemInfo.OS_VERSION) <= 0) { + if (Registry.is("ide.firstStartup")) { + Notification n = + new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "64-bit System Information", "You IntelliJ IDEA now running in 64-bit mode.
" + + "You may reduce memory, used by IntelliJ IDEA, by running it in 32-bit mode. " + + "Click for details", NotificationType.INFORMATION, new NotificationListener() { + @Override + public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { + BrowserUtil.launchBrowser(event.getURL().toString()); + } + }); + Notifications.Bus.notify(n, NotificationDisplayType.STICKY_BALLOON, null); + Registry.get("ide.firstStartup").setValue(false); + } + } } private void startCacheUpdate() { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java index 367b99fc24aa..9579adba8dac 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java @@ -472,8 +472,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen return i; } } - assert end > 0; - return end - 1; + return end; } private static int calculateWidthInColumns(char c, int widthInPixels, int spaceWithInPixels) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java index e9412b21e285..f47bec52c7ec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java @@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.content; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; import com.intellij.util.ui.BaseButtonBehavior; +import com.intellij.util.ui.TimedDeadzone; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -44,7 +45,8 @@ class ContentTabLabel extends BaseLabel { } } }; - + myBehavior.setActionTrigger(MouseEvent.MOUSE_PRESSED); + myBehavior.setMouseDeadzone(TimedDeadzone.NULL); } public void update() { diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 925c8f2003d3..0367c55c0f9a 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -30,6 +30,7 @@ actionSystem.quickAccessModifiers= actionSystem.quickAccessShowSpotsTime=1500 actionSystem.win.supressAlt=true +ide.firstStartup=true ide.debugMode=false ide.debugMode.description=Record additonal information to make bug reports more informative ide.forcedShowTooltip=alt diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index ea943d271326..f298a0f4205b 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -96,7 +96,7 @@ - + diff --git a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java index 104f9ca5f0a1..b090176309ef 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/Foundation.java @@ -85,6 +85,10 @@ public class Foundation { return myFoundationLibrary.objc_getClass(clazz); } + public static String fullUserName() { + return toStringViaUTF8(myFoundationLibrary.NSFullUserName()); + } + /** * Return a CFString as an ID, toll-free bridged to NSString. *

diff --git a/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java b/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java index f4a887cd1da0..4b1bcaff5786 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/FoundationLibrary.java @@ -25,6 +25,8 @@ import com.sun.jna.Pointer; public interface FoundationLibrary extends Library { void NSLog(Pointer pString, Object thing); + ID NSFullUserName(); + ID objc_allocateClassPair(ID supercls, String name, int extraBytes); void objc_registerClassPair(ID cls); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index cad2e46b6d72..403b1089820e 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1762,5 +1762,21 @@ public class UIUtil { return null; } + public static void scrollListToVisibleIfNeeded(@NotNull final JList list) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + final int selectedIndex = list.getSelectedIndex(); + if (selectedIndex >= 0) { + final Rectangle visibleRect = list.getVisibleRect(); + final Rectangle cellBounds = list.getCellBounds(selectedIndex, selectedIndex); + if (!visibleRect.contains(cellBounds)) { + list.scrollRectToVisible(cellBounds); + } + } + } + }); + } + } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java index 989cd873d211..de2b17872776 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/UnaryExpressionNotPlusMinus.java @@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.GroovyBundle; import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; +import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ConditionalExpression; import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement; import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeSpec; import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils; @@ -41,7 +42,7 @@ public class UnaryExpressionNotPlusMinus implements GroovyElementTypes { if (builder.getTokenType() == mLPAREN) { final ReferenceElement.ReferenceElementResult result = parseTypeCast(builder); if (result != fail) { - if (UnaryExpression.parse(builder, parser) || result == ReferenceElement.ReferenceElementResult.mustBeType) { + if (ConditionalExpression.parse(builder, parser) || result == ReferenceElement.ReferenceElementResult.mustBeType) { marker.done(CAST_EXPRESSION); return true; } else { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy index d8eea7e836cf..32971c1bd12d 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy @@ -187,6 +187,8 @@ public class ExpressionsParsingTest extends GroovyParsingTestCase { public void testtypecast$una4() throws Throwable { doTest(); } public void testtypecast$una5() throws Throwable { doTest(); } public void testtypecast$una6() throws Throwable { doTest(); } + public void testtypecast$elvis() throws Throwable { doTest(); } + public void testtypecast$conditional() throws Throwable { doTest(); } public void testAtHang() throws Throwable { doTest(); } public void testDollar() throws Throwable { doTest(); } diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/typecast/conditional.test b/plugins/groovy/testdata/parsing/groovy/expressions/typecast/conditional.test new file mode 100644 index 000000000000..458db889dfde --- /dev/null +++ b/plugins/groovy/testdata/parsing/groovy/expressions/typecast/conditional.test @@ -0,0 +1,35 @@ +def list = (List) foo?bar: bar +----- +Groovy script + Variable definitions + Modifiers + PsiElement(def)('def') + PsiWhiteSpace(' ') + Variable + PsiElement(identifier)('list') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Typecast expression + PsiElement(()('(') + Type element + Reference element + PsiElement(identifier)('List') + Type arguments + PsiElement(<)('<') + Type element + Reference element + PsiElement(identifier)('String') + PsiElement(>)('>') + PsiElement())(')') + PsiWhiteSpace(' ') + Conditional expression + Reference expression + PsiElement(identifier)('foo') + PsiElement(?)('?') + Reference expression + PsiElement(identifier)('bar') + PsiElement(:)(':') + PsiWhiteSpace(' ') + Reference expression + PsiElement(identifier)('bar') \ No newline at end of file diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/typecast/elvis.test b/plugins/groovy/testdata/parsing/groovy/expressions/typecast/elvis.test new file mode 100644 index 000000000000..8aad2fca88f5 --- /dev/null +++ b/plugins/groovy/testdata/parsing/groovy/expressions/typecast/elvis.test @@ -0,0 +1,32 @@ +def list = (List) foo?: bar +----- +Groovy script + Variable definitions + Modifiers + PsiElement(def)('def') + PsiWhiteSpace(' ') + Variable + PsiElement(identifier)('list') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + Typecast expression + PsiElement(()('(') + Type element + Reference element + PsiElement(identifier)('List') + Type arguments + PsiElement(<)('<') + Type element + Reference element + PsiElement(identifier)('String') + PsiElement(>)('>') + PsiElement())(')') + PsiWhiteSpace(' ') + Elvis expression + Reference expression + PsiElement(identifier)('foo') + PsiElement(?:)('?:') + PsiWhiteSpace(' ') + Reference expression + PsiElement(identifier)('bar') \ No newline at end of file diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java index 064abf331b95..35e45c924dae 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java @@ -17,6 +17,7 @@ package com.intellij.javaee; import com.intellij.application.options.PathMacrosImpl; import com.intellij.application.options.ReplacePathToMacroMap; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.components.State; @@ -26,6 +27,7 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.xml.XmlFile; @@ -40,6 +42,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.net.URL; import java.util.*; /** @@ -61,18 +64,18 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple private final Set myIgnoredResources = new HashSet(); - private final AtomicNotNullLazyValue>> myStdResources = new AtomicNotNullLazyValue>>() { + private final AtomicNotNullLazyValue>> myStdResources = new AtomicNotNullLazyValue>>() { @NotNull @Override - protected Map> compute() { + protected Map> compute() { return computeStdResources(); } }; private String myDefaultHtmlDoctype = XmlUtil.XHTML_URI; - protected Map> computeStdResources() { + protected Map> computeStdResources() { ResourceRegistrarImpl registrar = new ResourceRegistrarImpl(); for (StandardResourceProvider provider : Extensions.getExtensions(StandardResourceProvider.EP_NAME)) { provider.registerResources(registrar); @@ -128,7 +131,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } public String getResourceLocation(@NonNls String url, String version) { - String result = getUserResourse(url, version); + String result = getUserResource(url, version); if (result == null) { result = getStdResource(url, version); } @@ -141,19 +144,25 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple @Override @Nullable public String getUserResourse(Project project, String url, String version) { - String resourse = getProjectResources(project).getUserResourse(url, version); - return resourse == null ? getUserResourse(url, version) : resourse; + String resourse = getProjectResources(project).getUserResource(url, version); + return resourse == null ? getUserResource(url, version) : resourse; } @Override @Nullable public String getStdResource(String url, String version) { - Map map = getMap(myStdResources.getValue(), version, false); - return map != null ? map.get(url) : null; + Map map = getMap(myStdResources.getValue(), version, false); + if (map != null) { + Resource resource = map.get(url); + return resource == null ? null : resource.getResourceUrl(); + } + else { + return null; + } } @Nullable - private String getUserResourse(String url, String version) { + private String getUserResource(String url, String version) { Map map = getMap(myResources, version, false); return map != null ? map.get(url) : null; } @@ -184,39 +193,21 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple public String[] getResourceUrls(@Nullable final FileType fileType, @NonNls final String version, final boolean includeStandard) { final List result = new LinkedList(); - addResourcesFromMap(fileType, result, version, myResources); + addResourcesFromMap(result, version, myResources); if (includeStandard) { - addResourcesFromMap(fileType, result, version, myStdResources.getValue()); + addResourcesFromMap(result, version, myStdResources.getValue()); } return ArrayUtil.toStringArray(result); } - private static void addResourcesFromMap(@Nullable final FileType fileType, - final List result, + private static void addResourcesFromMap(final List result, String version, - Map> resourcesMap) { - Map resources = getMap(resourcesMap, version, false); + Map> resourcesMap) { + Map resources = getMap(resourcesMap, version, false); if (resources == null) return; - final Set keySet = resources.keySet(); - - for (String key : keySet) { - String resource = resources.get(key); - - if (fileType != null) { - String defaultExtension = fileType.getDefaultExtension(); - - if (resource.endsWith(defaultExtension) && - resource.length() > defaultExtension.length() && - resource.charAt(resource.length() - defaultExtension.length() - 1) == '.') { - result.add(key); - } - } - else { - result.add(key); - } - } + result.addAll(resources.keySet()); } public void addResource(String url, String location) { @@ -399,15 +390,11 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple } } - public List getStandardResources() { - ArrayList strings = new ArrayList(); - Collection> maps = myStdResources.getValue().values(); - for (Map map : maps) { - strings.addAll(map.values()); - } - return strings; + Collection> getStandardResources() { + return myStdResources.getValue().values(); } + private final static NotNullLazyKey INSTANCE_CACHE = ServiceManager.createLazyKey(ProjectResources.class); private static ExternalResourceManagerImpl getProjectResources(Project project) { @@ -431,5 +418,53 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple fireExternalResourceChanged(); } + static class Resource { + String file; + Class clazz; + @Nullable + String getResourceUrl() { + + if (clazz == null) return file; + + final URL resource = clazz.getResource(file); + clazz = null; + if (resource == null) { + String message = "Cannot find standard resource. filename:" + file + " class=" + clazz; + if (ApplicationManager.getApplication().isUnitTestMode()) { + LOG.error(message); + } + else { + LOG.warn(message); + } + + return null; + } + + String path = FileUtil.unquote(resource.toString()); + // this is done by FileUtil for windows + path = path.replace('\\','/'); + file = path; + return path; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Resource resource = (Resource)o; + + if (clazz != resource.clazz) return false; + if (file != null ? !file.equals(resource.file) : resource.file != null) return false; + + return true; + } + + @Override + public int hashCode() { + return file.hashCode(); + } + } } diff --git a/xml/impl/src/com/intellij/xml/index/ExternalResourcesRootsProvider.java b/xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java similarity index 51% rename from xml/impl/src/com/intellij/xml/index/ExternalResourcesRootsProvider.java rename to xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java index 1fd3cf74af10..9243fe3166e5 100644 --- a/xml/impl/src/com/intellij/xml/index/ExternalResourcesRootsProvider.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourcesRootsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -13,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.xml.index; +package com.intellij.javaee; import com.intellij.codeInsight.daemon.impl.quickfix.FetchExtResourceAction; -import com.intellij.javaee.ExternalResourceManagerEx; -import com.intellij.javaee.ExternalResourceManagerImpl; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.IndexableSetContributor; +import org.jetbrains.annotations.NotNull; +import java.util.Collection; import java.util.HashSet; -import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -34,20 +34,34 @@ import java.util.Set; */ public class ExternalResourcesRootsProvider extends IndexableSetContributor { + private final NotNullLazyValue> myStandardResources = new NotNullLazyValue>() { + @NotNull + @Override + protected Set compute() { + ExternalResourceManagerImpl manager = (ExternalResourceManagerImpl)ExternalResourceManagerEx.getInstance(); + Collection> resources = manager.getStandardResources(); + Set dirs = new HashSet(); + for (Map map : resources) { + for (ExternalResourceManagerImpl.Resource resource : map.values()) { + ExternalResourceManagerImpl.Resource dir = new ExternalResourceManagerImpl.Resource(); + int i = resource.file.lastIndexOf("/"); + dir.file = i > 0 ? resource.file.substring(0, i) : resource.file; + dirs.add(dir); + } + } + HashSet set = new HashSet(); + for (ExternalResourceManagerImpl.Resource dir : dirs) { + String url = dir.getResourceUrl(); + ContainerUtil.addIfNotNull(set, url); + } + return set; + } + }; + public Set getAdditionalRootsToIndex() { - ExternalResourceManagerImpl manager = (ExternalResourceManagerImpl)ExternalResourceManagerEx.getInstance(); - List urls = manager.getStandardResources(); - Set dirs = new HashSet(ContainerUtil.map(urls, new Function() { - @Override - public String fun(String s) { - int endIndex = s.lastIndexOf('/'); - return endIndex > 0 ? s.substring(0, endIndex) : s; - } - })); - HashSet roots = new HashSet(); - for (String url : dirs) { + for (String url : myStandardResources.getValue()) { VirtualFile file = VfsUtil.findRelativeFile(url, null); if (file != null) { roots.add(file); diff --git a/xml/impl/src/com/intellij/javaee/ProjectResources.java b/xml/impl/src/com/intellij/javaee/ProjectResources.java index efbeaf6cc644..76c0abcfc28c 100644 --- a/xml/impl/src/com/intellij/javaee/ProjectResources.java +++ b/xml/impl/src/com/intellij/javaee/ProjectResources.java @@ -39,7 +39,7 @@ public class ProjectResources extends ExternalResourceManagerImpl implements Per } @Override - protected Map> computeStdResources() { + protected Map> computeStdResources() { return Collections.emptyMap(); } diff --git a/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java b/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java index b306e1d0f27f..33865042ffcb 100644 --- a/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java +++ b/xml/impl/src/com/intellij/javaee/ResourceRegistrarImpl.java @@ -16,15 +16,9 @@ package com.intellij.javaee; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.CollectionFactory; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; -import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,9 +28,8 @@ import java.util.Map; */ public class ResourceRegistrarImpl implements ResourceRegistrar { - private final Map> myResources = new HashMap>(); + private final Map> myResources = new HashMap>(); private final List myIgnored = new ArrayList(); - private final Map> myCache = CollectionFactory.hashMap(); public void addStdResource(@NonNls String resource, @NonNls String fileName) { addStdResource(resource, null, fileName, getClass()); @@ -47,22 +40,12 @@ public class ResourceRegistrarImpl implements ResourceRegistrar { } public void addStdResource(@NonNls String resource, @NonNls String version, @NonNls String fileName, Class klass) { - final String file = getFile(fileName, klass); - if (file != null) { - //saveCache(fileName, klass, file); - final Map map = ExternalResourceManagerImpl.getMap(myResources, version, true); - assert map != null; - map.put(resource, file); - } - else { - String message = "Cannot find standard resource. filename:" + fileName + " klass=" + klass; - if (ApplicationManager.getApplication().isUnitTestMode()) { - ExternalResourceManagerImpl.LOG.error(message); - } - else { - ExternalResourceManagerImpl.LOG.warn(message); - } - } + final Map map = ExternalResourceManagerImpl.getMap(myResources, version, true); + assert map != null; + ExternalResourceManagerImpl.Resource res = new ExternalResourceManagerImpl.Resource(); + res.file = fileName; + res.clazz = klass == null ? ExternalResourceManagerImpl.class : klass; + map.put(resource, res); } public void addIgnoredResource(@NonNls String url) { @@ -85,77 +68,7 @@ public class ResourceRegistrarImpl implements ResourceRegistrar { addStdResource(resource, version, ExternalResourceManagerImpl.STANDARD_SCHEMAS + fileName, clazz); } - @Nullable - private String getFile(String name, Class klass) { - /* - VirtualFile file = findUsingCache(name, klass); - if (file != null) { - return file; - } - */ - - final URL resource = klass.getResource(name); - if (resource == null) return null; - - String path = FileUtil.unquote(resource.toString()); - // this is done by FileUtil for windows - path = path.replace('\\','/'); - - return path;//VfsUtil.findRelativeFile(path, null); - } - - @Nullable - private VirtualFile findUsingCache(String name, Class klass) { - if (!name.startsWith("/")) return null; - - final Map cache = myCache.get(klass.getClassLoader()); - if (cache == null) return null; - - int end = name.length(); - while (true) { - final int i = name.lastIndexOf('/', end); - if (i < 0) break; - - final VirtualFile existing = cache.get(name.substring(0, i)); - if (existing != null) { - final VirtualFile guess = existing.findFileByRelativePath(name.substring(i + 1)); - if (guess != null) { - return guess; - } - } - - end = i - 1; - } - - return null; - } - - private void saveCache(String name, Class klass, VirtualFile file) { - if (!name.startsWith("/")) return; - - final ClassLoader loader = klass.getClassLoader(); - Map cache = myCache.get(loader); - if (cache == null) { - myCache.put(loader, cache = CollectionFactory.hashMap()); - } - - String parent = name; - VirtualFile current = file; - while (true) { - if (current.equals(cache.get(parent))) break; - - cache.put(parent, current); - final int i = parent.lastIndexOf('/'); - if (i <= 0) break; - if (!parent.substring(i + 1).equals(current.getName())) { - break; - } - parent = parent.substring(0, i); - current = current.getParent(); - } - } - - public Map> getResources() { + public Map> getResources() { return myResources; }