diff --git a/.idea/libraries/winp.xml b/.idea/libraries/winp.xml
index 07689aee601a..8566148396e4 100644
--- a/.idea/libraries/winp.xml
+++ b/.idea/libraries/winp.xml
@@ -9,4 +9,4 @@
-
\ No newline at end of file
+
diff --git a/build/conf/mac/Contents/Info.plist b/build/conf/mac/Contents/Info.plist
index 9fcd21c14315..8daa490e8ecc 100644
--- a/build/conf/mac/Contents/Info.plist
+++ b/build/conf/mac/Contents/Info.plist
@@ -31,11 +31,11 @@
CFBundleInfoDictionaryVersion
6.0
CFBundleName
- @@bundle_name@@ @@product_version@@
+ @@bundle_name@@@@product_state@@
CFBundlePackageType
APPL
CFBundleIdentifier
- @@bundle_identifier@@
+ @@bundle_identifier@@@@product_state@@
CFBundleSignature
????
CFBundleGetInfoString
diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant
index f93dd53fa8a2..7421c91f9cc5 100644
--- a/build/scripts/utils.gant
+++ b/build/scripts/utils.gant
@@ -367,8 +367,7 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
String minor = p("component.version.minor")
String version = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "EAP $args.buildNumber" : "${p("component.version.major")}.${minor}"
- String productVersion = "${p("component.version.major")}.${minor}"
- if (isEap() && !minor.contains("RC") && !minor.contains("Beta")) productVersion += " EAP"
+ String EAP = isEap() && !minor.contains("RC") && !minor.contains("Beta") ? "-EAP" : ""
Map properties = readIdeaProperties(args)
@@ -429,7 +428,7 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
replacefilter(token: "@@executable@@", value: executable)
replacefilter(token: "@@icns@@", value: icns)
replacefilter(token: "@@bundle_name@@", value: fullName)
- replacefilter(token: "@@product_version@@", value: productVersion)
+ replacefilter(token: "@@product_state@@", value: EAP)
replacefilter(token: "@@bundle_identifier@@", value: args.bundleIdentifier)
replacefilter(token: "@@year@@", value: "$todayYear")
replacefilter(token: "@@version@@", value: version)
diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
index e04539b3e469..9ceffac57eb4 100644
--- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
+++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java
@@ -931,7 +931,7 @@ public class BuildManager implements ApplicationComponent{
// validate tools.jar presence
final JavaSdkType projectJdkType = (JavaSdkType)projectJdk.getSdkType();
- if (projectJdk.equals(internalJdk)) {
+ if (FileUtil.pathsEqual(projectJdk.getHomePath(), internalJdk.getHomePath())) {
// important: because internal JDK can be either JDK or JRE,
// this is the most universal way to obtain tools.jar path in this particular case
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ExportThreadsAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ExportThreadsAction.java
index ed829100c502..25d95ed86292 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/ExportThreadsAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ExportThreadsAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -21,61 +21,49 @@
package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerManagerEx;
+import com.intellij.debugger.engine.DebugProcessImpl;
+import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerSession;
-import com.intellij.debugger.ui.ExportDialog;
-import com.intellij.idea.ActionsBundle;
+import com.intellij.ide.actions.ExportToTextFileAction;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.SystemProperties;
+import com.intellij.unscramble.ThreadDumpPanel;
+import com.intellij.unscramble.ThreadState;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.util.List;
public class ExportThreadsAction extends AnAction implements AnAction.TransparentUpdate {
public void actionPerformed(AnActionEvent e) {
- Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
+ final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) {
return;
}
DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
- if(context.getDebuggerSession() != null) {
- String destinationDirectory = "";
- final VirtualFile baseDir = project.getBaseDir();
- if (baseDir != null) destinationDirectory = baseDir.getPresentableUrl();
-
- ExportDialog dialog = new ExportDialog(context.getDebugProcess(), destinationDirectory);
- if (dialog.showAndGet()) {
- try {
- File file = new File(dialog.getFilePath());
- BufferedWriter writer = new BufferedWriter(new FileWriter(file));
- try {
- String text = StringUtil.convertLineSeparators(dialog.getTextToSave(), SystemProperties.getLineSeparator());
- writer.write(text);
+ final DebuggerSession session = context.getDebuggerSession();
+ if(session != null && session.isAttached()) {
+ final DebugProcessImpl process = context.getDebugProcess();
+ if (process != null) {
+ process.getManagerThread().invoke(new DebuggerCommandImpl() {
+ protected void action() throws Exception {
+ final List threads = ThreadDumpAction.buildThreadStates(process.getVirtualMachineProxy());
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ public void run() {
+ ExportToTextFileAction.export(project, ThreadDumpPanel.createToFileExporter(project, threads));
+ }
+ }, ModalityState.NON_MODAL);
}
- finally {
- writer.close();
- }
- }
- catch (IOException ex) {
- Messages
- .showMessageDialog(project, ex.getMessage(), ActionsBundle.actionText(DebuggerActions.EXPORT_THREADS), Messages.getErrorIcon());
- }
+ });
}
}
}
-
-
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java
index e8eb1a902504..96e6d015f026 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -83,7 +83,7 @@ public class ThreadDumpAction extends AnAction implements AnAction.TransparentUp
}
}
- private static List buildThreadStates(VirtualMachineProxyImpl vmProxy) {
+ static List buildThreadStates(VirtualMachineProxyImpl vmProxy) {
final List threads = vmProxy.getVirtualMachine().allThreads();
final List result = new ArrayList();
final Map nameToThreadMap = new HashMap();
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java
index 09898a068e3a..0b1cd18bb05b 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -322,7 +322,7 @@ public class JavaDebugProcess extends XDebugProcess {
public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) {
Constraints beforeRunner = new Constraints(Anchor.BEFORE, "Runner.Layout");
leftToolbar.add(Separator.getInstance(), beforeRunner);
- leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner);
+ //leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.EXPORT_THREADS), beforeRunner);
leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner);
leftToolbar.add(Separator.getInstance(), beforeRunner);
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
index 8e5cfb72ce3f..a088e953557f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -287,7 +287,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
}
leftToolbar.addSeparator();
- addAction(leftToolbar, DebuggerActions.EXPORT_THREADS);
+ //addAction(leftToolbar, DebuggerActions.EXPORT_THREADS);
addAction(leftToolbar, DebuggerActions.DUMP_THREADS);
leftToolbar.addSeparator();
diff --git a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java
index ca7c26dbc811..65c6777bcbbb 100644
--- a/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/CodeInsightUtil.java
@@ -106,7 +106,9 @@ public class CodeInsightUtil {
if (parent == null) return PsiElement.EMPTY_ARRAY;
while (true) {
if (parent instanceof PsiStatement) {
- parent = parent.getParent();
+ if (!(element1 instanceof PsiComment || element2 instanceof PsiComment)) {
+ parent = parent.getParent();
+ }
break;
}
if (parent instanceof PsiCodeBlock) break;
diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
index 5ef5abbc9b0d..a5b22a82ec83 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java
@@ -45,6 +45,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.projectRoots.SdkModificator;
@@ -161,7 +162,12 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM
application.invokeLater(new Runnable() {
@Override
public void run() {
- setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, value);
+ DumbService.getInstance(project).withAlternativeResolveEnabled(new Runnable() {
+ @Override
+ public void run() {
+ setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, value);
+ }
+ });
}
}, project.getDisposed());
}
diff --git a/java/java-impl/src/com/intellij/ide/favoritesTreeView/PsiClassFavoriteNodeProvider.java b/java/java-impl/src/com/intellij/ide/favoritesTreeView/PsiClassFavoriteNodeProvider.java
index fc5fe63e7a98..6352d8105a0a 100644
--- a/java/java-impl/src/com/intellij/ide/favoritesTreeView/PsiClassFavoriteNodeProvider.java
+++ b/java/java-impl/src/com/intellij/ide/favoritesTreeView/PsiClassFavoriteNodeProvider.java
@@ -27,10 +27,10 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.FileIndexFacade;
import com.intellij.openapi.util.Comparing;
@@ -146,6 +146,10 @@ public class PsiClassFavoriteNodeProvider extends FavoriteNodeProvider {
@Override
public Object[] createPathFromUrl(final Project project, final String url, final String moduleName) {
+ if (DumbService.isDumb(project)) {
+ return null;
+ }
+
GlobalSearchScope scope = null;
if (moduleName != null) {
final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName);
diff --git a/java/java-impl/src/com/intellij/psi/impl/smartPointers/JavaAnchorProvider.java b/java/java-impl/src/com/intellij/psi/impl/smartPointers/JavaAnchorProvider.java
new file mode 100644
index 000000000000..99cf1e82073b
--- /dev/null
+++ b/java/java-impl/src/com/intellij/psi/impl/smartPointers/JavaAnchorProvider.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2015 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.
+ */
+package com.intellij.psi.impl.smartPointers;
+
+import com.intellij.lang.java.JavaLanguage;
+import com.intellij.psi.*;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Dennis.Ushakov
+ */
+public class JavaAnchorProvider implements SmartPointerAnchorProvider {
+ @Override
+ public PsiElement getAnchor(PsiElement element) {
+ if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
+ return null;
+ }
+
+ if (element instanceof PsiClass) {
+ if (element instanceof PsiAnonymousClass) {
+ return ((PsiAnonymousClass)element).getBaseClassReference().getReferenceNameElement();
+ } else {
+ return ((PsiClass)element).getNameIdentifier();
+ }
+ } else if (element instanceof PsiMethod) {
+ return ((PsiMethod)element).getNameIdentifier();
+ } else if (element instanceof PsiVariable) {
+ return ((PsiVariable)element).getNameIdentifier();
+ }
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public PsiElement getElement(PsiElement anchor) {
+ if (anchor instanceof PsiIdentifier) {
+ PsiElement parent = anchor.getParent();
+ if (parent instanceof PsiJavaCodeReferenceElement) { // anonymous class, type
+ parent = parent.getParent();
+ }
+
+ if (!anchor.equals(AnchorElementInfoFactory.getAnchor(parent))) return null;
+
+ return parent;
+ }
+ return null;
+ }
+}
diff --git a/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java b/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java
index 1c37445ba749..f477247181c0 100644
--- a/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java
+++ b/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.highlighting.HighlightManager;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
+import com.intellij.ide.ExporterToTextFile;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
@@ -32,22 +33,25 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.ui.*;
import com.intellij.ui.components.JBList;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
+import java.io.File;
+import java.util.*;
import java.util.List;
import static com.intellij.icons.AllIcons.Debugger.ThreadStates.*;
@@ -56,7 +60,7 @@ import static com.intellij.icons.AllIcons.Debugger.ThreadStates.*;
* @author Jeka
* @author Konstantin Bulenkov
*/
-public class ThreadDumpPanel extends JPanel {
+public class ThreadDumpPanel extends JPanel implements DataProvider {
private static final Icon PAUSE_ICON_DAEMON = new LayeredIcon(Paused, Daemon_sign);
private static final Icon LOCKED_ICON_DAEMON = new LayeredIcon(Locked, Daemon_sign);
private static final Icon RUNNING_ICON_DAEMON = new LayeredIcon(Running, Daemon_sign);
@@ -68,6 +72,7 @@ public class ThreadDumpPanel extends JPanel {
private final List myThreadDump;
private final JPanel myFilterPanel;
private final SearchTextField myFilterField;
+ private final ExporterToTextFile myExporterToTextFile;
public ThreadDumpPanel(final Project project, final ConsoleView consoleView, final DefaultActionGroup toolbarActions, final List threadDump) {
super(new BorderLayout());
@@ -103,11 +108,14 @@ public class ThreadDumpPanel extends JPanel {
}
});
+ myExporterToTextFile = createToFileExporter(project, myThreadDump);
+
FilterAction filterAction = new FilterAction();
filterAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_FIND).getShortcutSet(), myThreadList);
toolbarActions.add(filterAction);
toolbarActions.add(new CopyToClipboardAction(threadDump, project));
toolbarActions.add(new SortThreadsAction());
+ toolbarActions.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPORT_TO_TEXT_FILE));
add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false).getComponent(), BorderLayout.WEST);
JPanel leftPanel = new JPanel(new BorderLayout());
@@ -137,6 +145,15 @@ public class ThreadDumpPanel extends JPanel {
}
}
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (PlatformDataKeys.EXPORTER_TO_TEXT_FILE.is(dataId)) {
+ return myExporterToTextFile;
+ }
+ return null;
+ }
+
private void updateThreadList() {
String text = myFilterPanel.isVisible() ? myFilterField.getText() : "";
DefaultListModel model = (DefaultListModel)myThreadList.getModel();
@@ -354,4 +371,59 @@ public class ThreadDumpPanel extends JPanel {
updateThreadList();
}
}
+
+ public static ExporterToTextFile createToFileExporter(Project project, List threadStates) {
+ return new MyToFileExporter(project, threadStates);
+ }
+
+ private static class MyToFileExporter implements ExporterToTextFile {
+ private final Project myProject;
+ private final List myThreadStates;
+
+ public MyToFileExporter(Project project, List threadStates) {
+ myProject = project;
+ myThreadStates = threadStates;
+ }
+
+ @Override
+ public JComponent getSettingsEditor() {
+ return null;
+ }
+
+ @Override
+ public void addSettingsChangedListener(ChangeListener listener) throws TooManyListenersException {}
+
+ @Override
+ public void removeSettingsChangedListener(ChangeListener listener) {}
+
+ @Override
+ public String getReportText() {
+ StringBuilder sb = new StringBuilder();
+ for (ThreadState state : myThreadStates) {
+ sb.append(state.getStackTrace()).append("\n\n");
+ }
+ return sb.toString();
+ }
+
+ private static final @NonNls String DEFAULT_REPORT_FILE_NAME = "threads_report.txt";
+
+ @Override
+ public String getDefaultFilePath() {
+ final VirtualFile baseDir = myProject.getBaseDir();
+ if (baseDir != null) {
+ return baseDir.getPresentableUrl() + File.separator + DEFAULT_REPORT_FILE_NAME;
+ }
+ return null;
+ }
+
+ @Override
+ public void exportedTo(String filePath) {
+
+ }
+
+ @Override
+ public boolean canExport() {
+ return !myThreadStates.isEmpty();
+ }
+ }
}
diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java
index 1b925e02eabe..87cc8e38cb2f 100644
--- a/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java
+++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/ClassInheritorsSearch.java
@@ -18,6 +18,7 @@ package com.intellij.psi.search.searches;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.project.Project;
@@ -170,6 +171,9 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory() {
@Override
public SearchScope compute() {
+ if (!aClass.isValid()) {
+ throw new ProcessCanceledException();
+ }
return aClass.getUseScope();
}
}), checkDeep);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
index ca19d9766eb8..aa389214205a 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java
@@ -196,7 +196,7 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx {
DumbService dumbService = DumbService.getInstance(getProject());
PsiElementFinder[] finders = finders();
if (dumbService.isDumb()) {
- List list = dumbService.filterByDumbAwareness(Arrays.asList(finders));
+ List list = dumbService.filterByDumbAwareness(finders);
finders = list.toArray(new PsiElementFinder[list.size()]);
}
return finders;
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java
index b5933ed64e68..8a1f32ce83f4 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/SymbolCollectingProcessor.java
@@ -24,7 +24,6 @@ import com.intellij.psi.scope.BaseScopeProcessor;
import com.intellij.psi.scope.ElementClassHint;
import com.intellij.psi.scope.JavaScopeProcessorEvent;
import com.intellij.psi.scope.PsiScopeProcessor;
-import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.MostlySingularMultiMap;
import org.jetbrains.annotations.NotNull;
@@ -83,7 +82,16 @@ public class SymbolCollectingProcessor extends BaseScopeProcessor implements Ele
@NotNull
public PsiNamedElement getElement() {
- return (PsiNamedElement)ObjectUtils.assertNotNull(myElement.retrieve());
+ PsiElement element = myElement.retrieve();
+ if (element == null) {
+ String message = "Anchor hasn't survived: " + myElement;
+ if (myElement instanceof PsiAnchor.StubIndexReference) {
+ message += "; diagnostics=" + ((PsiAnchor.StubIndexReference)myElement).diagnoseNull();
+ }
+ throw new AssertionError(message);
+ }
+
+ return (PsiNamedElement)element;
}
public PsiElement getFileContext() {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
index 9c8b8b4772b3..8ee31c32f6ef 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
@@ -288,10 +288,8 @@ public class InferenceIncorporationPhase {
public boolean process(Pair pair) {
final PsiType sType = pair.first;
final PsiType tType = pair.second;
- if (!mySession.isProperType(sType) && !mySession.isProperType(tType)) {
- if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
- addConstraint(new TypeEqualityConstraint(sType, tType));
- }
+ if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
+ addConstraint(new TypeEqualityConstraint(sType, tType));
}
return true;
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 90fe82d20b46..9ec7ab51b059 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -1127,13 +1127,18 @@ public class InferenceSession {
if (parameters.length == functionalMethodParameters.length && !varargs || isStatic && varargs) {//static methods
- if (method.isConstructor() && PsiUtil.isRawSubstitutor(containingClass, qualifierResolveResult.getSubstitutor())) {
+ PsiSubstitutor psiSubstitutor = qualifierResolveResult.getSubstitutor();
+ if (method.isConstructor() && PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor)) {
+ //15.13.1 If ClassType is a raw type, but is not a non-static member type of a raw type,
+ //the candidate notional member methods are those specified in ยง15.9.3 for a
+ //class instance creation expression that uses <> to elide the type arguments to a class
initBounds(containingClass.getTypeParameters());
+ psiSubstitutor = PsiSubstitutor.EMPTY;
}
for (int i = 0; i < functionalMethodParameters.length; i++) {
final PsiType pType = signature.getParameterTypes()[i];
- addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, qualifierResolveResult.getSubstitutor(), varargs)),
+ addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(getParameterType(parameters, i, psiSubstitutor, varargs)),
PsiImplUtil.normalizeWildcardTypeByPosition(pType, reference)));
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java
index 1b66ab4dada0..56674fa3952b 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/MethodReferenceResolver.java
@@ -111,10 +111,10 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
@NotNull
@Override
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint) {
- return inferTypeArguments();
+ return inferTypeArguments(includeReturnConstraint);
}
- private PsiSubstitutor inferTypeArguments() {
+ private PsiSubstitutor inferTypeArguments(boolean includeReturnConstraint) {
if (interfaceMethod == null) return substitutor;
final InferenceSession session = new InferenceSession(method.getTypeParameters(), substitutor, reference.getManager(), reference);
session.initThrowsConstraints(method);
@@ -127,7 +127,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
return substitutor;
}
- if (interfaceMethodReturnType != PsiType.VOID && interfaceMethodReturnType != null) {
+ if (includeReturnConstraint && interfaceMethodReturnType != PsiType.VOID && interfaceMethodReturnType != null) {
if (method.isConstructor()) {
//todo
session.initBounds(reference, method.getContainingClass().getTypeParameters());
@@ -230,7 +230,7 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
if (!(conflict instanceof MethodCandidateInfo)) continue;
final PsiMethod psiMethod = ((MethodCandidateInfo)conflict).getElement();
- final PsiSubstitutor substitutor = conflict.getSubstitutor();
+ final PsiSubstitutor substitutor = ((MethodCandidateInfo)conflict).getSubstitutor(false);
final PsiType[] parameterTypes = psiMethod.getSignature(substitutor).getParameterTypes();
final boolean varargs = ((MethodCandidateInfo)conflict).isVarargs();
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java
index 67bbac28af1e..69fd19863ad2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RawQualifier.java
@@ -39,6 +39,6 @@ class MyTest1 {
static void foo(I3 i) {}
static {
- foo(Foo::new);
+ foo(Foo::new);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java
index 6b4de4e565a8..0696aadf6179 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/ReturnTypeSpecific.java
@@ -67,7 +67,7 @@ class MyTest1 {
}
public static void main(String[] args) {
- m(Foo::new);
+ m(Foo::new);
}
}
class MyTest2 {
@@ -104,6 +104,6 @@ class MyTest2 {
}
public static void main(String[] args) {
- m(Foo::new);
+ m(Foo::new);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/HighlightReferenceWhenContradictBoundsAreInferred.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/HighlightReferenceWhenContradictBoundsAreInferred.java
index c05073e7870f..0d1e79863b9d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/HighlightReferenceWhenContradictBoundsAreInferred.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/HighlightReferenceWhenContradictBoundsAreInferred.java
@@ -29,10 +29,10 @@ class Test {
static void meth4(I3 s) { }
static {
- meth1(Foo::new);
+ meth1(Foo::new);
meth2(Foo::new);
- meth3(Foo::new);
- meth4(Foo::new);
+ meth3(Foo::new);
+ meth4(Foo::new);
meth1(Test::foo);
meth2(Test::foo);
diff --git a/java/java-tests/testData/codeInsight/generation/surroundWith/java/SurroundIfBranchWithNoBracesAndComment.java b/java/java-tests/testData/codeInsight/generation/surroundWith/java/SurroundIfBranchWithNoBracesAndComment.java
new file mode 100644
index 000000000000..563c1795a3f6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/generation/surroundWith/java/SurroundIfBranchWithNoBracesAndComment.java
@@ -0,0 +1,7 @@
+class Test {
+ void m() {
+ if (true)
+ // comment
+ System.out.println();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/generation/surroundWith/java/SurroundIfBranchWithNoBracesAndComment_after.java b/java/java-tests/testData/codeInsight/generation/surroundWith/java/SurroundIfBranchWithNoBracesAndComment_after.java
new file mode 100644
index 000000000000..801e09e42baa
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/generation/surroundWith/java/SurroundIfBranchWithNoBracesAndComment_after.java
@@ -0,0 +1,8 @@
+class Test {
+ void m() {
+ if (true) {
+ // comment
+ System.out.println();
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java
index c4dce5fd134b..dd8b42ffd98f 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java
@@ -94,11 +94,11 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
}
public void testSurroundNonExpressionWithParenthesis() throws Exception {
- doTest(getTestName(false), new JavaWithParenthesesSurrounder());
+ doTest(new JavaWithParenthesesSurrounder());
}
public void testSurroundNonExpressionWithCast() throws Exception {
- doTest(getTestName(false), new JavaWithCastSurrounder());
+ doTest(new JavaWithCastSurrounder());
}
public void testSurroundExpressionWithCastEmptyLineAfter() throws Exception {
@@ -110,52 +110,52 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
}
public void testSurroundNonExpressionWithNot() throws Exception {
- doTest(getTestName(false), new JavaWithNotSurrounder());
+ doTest(new JavaWithNotSurrounder());
}
public void testSurroundBinaryWithCast() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithCastSurrounder());
+ doTest(new JavaWithCastSurrounder());
}
public void testSurroundConditionalWithCast() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithCastSurrounder());
+ doTest(new JavaWithCastSurrounder());
}
public void testSurroundAssignmentWithCast() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithCastSurrounder());
+ doTest(new JavaWithCastSurrounder());
}
public void testSurroundWithNotNullCheck() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithNullCheckSurrounder());
+ doTest(new JavaWithNullCheckSurrounder());
}
public void testSurroundExpressionWithIf() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithIfExpressionSurrounder());
+ doTest(new JavaWithIfExpressionSurrounder());
}
public void testSurroundExpressionWithIfForBoxedBooleans() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithIfExpressionSurrounder());
+ doTest(new JavaWithIfExpressionSurrounder());
}
public void testSurroundExpressionWithNotForBoxedBooleans() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithNotSurrounder());
+ doTest(new JavaWithNotSurrounder());
}
public void testSurroundExpressionWithElseIf() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithIfExpressionSurrounder());
+ doTest(new JavaWithIfExpressionSurrounder());
}
public void testSurroundExpressionWithElseIfElse() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
- doTest(getTestName(false), new JavaWithIfElseExpressionSurrounder());
+ doTest(new JavaWithIfElseExpressionSurrounder());
}
public void testSurroundWithTryFinallyUsingIndents() {
@@ -163,7 +163,7 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
boolean oldUseTabs = indentOptions.USE_TAB_CHARACTER;
try {
indentOptions.USE_TAB_CHARACTER = true;
- doTest(getTestName(false), new JavaWithTryFinallySurrounder());
+ doTest(new JavaWithTryFinallySurrounder());
}
finally {
indentOptions.USE_TAB_CHARACTER = oldUseTabs;
@@ -171,9 +171,17 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
}
public void testSurroundWithTryCatchFunctionalExpression() {
- doTest(getTestName(false), new JavaWithTryCatchSurrounder());
+ doTest(new JavaWithTryCatchSurrounder());
}
+ public void testSurroundIfBranchWithNoBracesAndComment() {
+ doTest(new JavaWithBlockSurrounder());
+ }
+
+ private void doTest(Surrounder surrounder) {
+ doTest(getTestName(false), surrounder);
+ }
+
private void doTest(@NotNull String fileName, final Surrounder surrounder) {
configureByFile(BASE_PATH + fileName + ".java");
diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/smartPointers/SmartPsiElementPointersTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/smartPointers/SmartPsiElementPointersTest.java
index 24c55c48f618..3e389146db80 100644
--- a/java/java-tests/testSrc/com/intellij/psi/impl/smartPointers/SmartPsiElementPointersTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/impl/smartPointers/SmartPsiElementPointersTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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,6 +17,7 @@ package com.intellij.psi.impl.smartPointers;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightTestCase;
+import com.intellij.ide.highlighter.HtmlFileType;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
@@ -37,6 +38,7 @@ import com.intellij.psi.stubs.StubTree;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.PsiUtilBase;
+import com.intellij.psi.xml.XmlTag;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
@@ -469,4 +471,64 @@ public class SmartPsiElementPointersTest extends CodeInsightTestCase {
assertEquals(range1.shiftRight(1), pointer1.getRange());
assertEquals(range2.shiftRight(1), pointer2.getRange());
}
+
+ public void testInXml() {
+ final PsiFile file = configureByText(HtmlFileType.INSTANCE,
+ "\n" +
+ "\n" +
+ " \n" +
+ " \n" +
+ "\n" +
+ " \n" +
+ ""
+ );
+
+ final XmlTag fieldSet = PsiTreeUtil.getParentOfType(file.findElementAt(file.getText().indexOf("fieldset")), XmlTag.class);
+ assertNotNull(fieldSet);
+ assertEquals("fieldset", fieldSet.getName());
+
+ final XmlTag select = PsiTreeUtil.getParentOfType(file.findElementAt(file.getText().indexOf("select")), XmlTag.class);
+ assertNotNull(select);
+ assertEquals("select", select.getName());
+
+ final SmartPsiElementPointer fieldSetPointer = SmartPointerManager.getInstance(getProject()).createSmartPsiElementPointer(
+ fieldSet);
+ final SmartPsiElementPointer selectPointer = SmartPointerManager.getInstance(getProject()).createSmartPsiElementPointer(select);
+
+ WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
+ @Override
+ public void run() {
+ getEditor().getDocument().insertString(getEditor().getCaretModel().getOffset(), "");
+ }
+ });
+
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+
+ final XmlTag newFieldSet = fieldSetPointer.getElement();
+ assertNotNull(newFieldSet);
+ assertEquals("fieldset", newFieldSet.getName());
+
+ final XmlTag newSelect = selectPointer.getElement();
+ assertNotNull(newSelect);
+ assertEquals("select", newSelect.getName());
+ }
+ public void testInsertImport() {
+ final PsiFile file = configureByText(JavaFileType.INSTANCE,
+ "class S {\n" +
+ "}");
+
+ PsiClass aClass = ((PsiJavaFile)file).getClasses()[0];
+
+ WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
+ @Override
+ public void run() {
+ getEditor().getDocument().insertString(0, "import java.util.Map;\n");
+ }
+ });
+
+ PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
+
+ PsiClass aClass2 = ((PsiJavaFile)file).getClasses()[0];
+ assertSame(aClass, aClass2);
+ }
}
diff --git a/java/testFramework/src/com/intellij/compiler/CompilerTestUtil.java b/java/testFramework/src/com/intellij/compiler/CompilerTestUtil.java
index aac45eac8e03..6f8cd3c20fc9 100644
--- a/java/testFramework/src/com/intellij/compiler/CompilerTestUtil.java
+++ b/java/testFramework/src/com/intellij/compiler/CompilerTestUtil.java
@@ -2,14 +2,12 @@ package com.intellij.compiler;
import com.intellij.compiler.server.BuildManager;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.application.impl.ApplicationImpl;
-import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.impl.stores.StateStorageManager;
-import com.intellij.openapi.components.impl.stores.StoreUtil;
+import com.intellij.openapi.components.impl.stores.ComponentStoreImpl;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
@@ -19,24 +17,7 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ModuleRootModificationUtil;
-import com.intellij.openapi.util.JDOMExternalizable;
-import com.intellij.openapi.util.JDOMUtil;
-import com.intellij.openapi.util.NamedJDOMExternalizable;
-import com.intellij.openapi.util.WriteExternalException;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
-import com.intellij.util.SystemProperties;
-import junit.framework.AssertionFailedError;
-import org.jdom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jps.model.serialization.JDomSerializationUtil;
-import org.junit.Assert;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -60,74 +41,27 @@ public class CompilerTestUtil {
}
public static void saveApplicationSettings() {
- saveApplicationComponent(ProjectJdkTable.getInstance());
- saveApplicationComponent(FileTypeManager.getInstance());
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ doSaveComponent(ProjectJdkTable.getInstance());
+ doSaveComponent(FileTypeManager.getInstance());
+ }
+ }, ModalityState.any());
}
- public static void saveApplicationComponent(Object appComponent) {
- try {
- final File file;
- String componentName;
- State state = StoreUtil.getStateSpec(appComponent.getClass());
- if (state != null) {
- componentName = state.name();
- Storage storageToWrite = findNonDeprecated(state.storages());
- StateStorageManager storageManager = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager();
- file = new File(storageManager.expandMacros(storageToWrite.file()));
+ public static void saveApplicationComponent(final Object appComponent) {
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ doSaveComponent(appComponent);
}
- else if (appComponent instanceof ExportableApplicationComponent && appComponent instanceof NamedJDOMExternalizable) {
- componentName = ((ExportableApplicationComponent)appComponent).getComponentName();
- file = PathManager.getOptionsFile((NamedJDOMExternalizable)appComponent);
- }
- else {
- throw new AssertionError( appComponent.getClass() + " doesn't have @State annotation and doesn't implement ExportableApplicationComponent");
- }
-
- final Element root = new Element("application");
- Element element = JDomSerializationUtil.createComponentElement(componentName);
- if (appComponent instanceof JDOMExternalizable) {
- ((JDOMExternalizable)appComponent).writeExternal(element);
- }
- else {
- //noinspection unchecked
- element.addContent(((PersistentStateComponent)appComponent).getState().cloneContent());
- }
- root.addContent(element);
- Assert.assertTrue("Cannot create " + file, FileUtil.createIfDoesntExist(file));
- new WriteAction() {
- @Override
- protected void run(@NotNull final Result result) throws IOException {
- VfsRootAccess.allowRootAccess(file.getAbsolutePath());
- try {
- VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
- Assert.assertNotNull(file.getAbsolutePath(), virtualFile);
- //emulate save via 'saveSettings' so file won't be treated as changed externally
- OutputStream stream = virtualFile.getOutputStream(new SaveSessionRequestor());
- try {
- JDOMUtil.writeParent(root, stream, SystemProperties.getLineSeparator());
- }
- finally {
- stream.close();
- }
- }
- finally {
- VfsRootAccess.disallowRootAccess(file.getAbsolutePath());
- }
- }
- }.execute().throwException();
- }
- catch (WriteExternalException e) {
- throw new RuntimeException(e);
- }
+ }, ModalityState.any());
}
- private static Storage findNonDeprecated(Storage[] storages) {
- for (Storage storage : storages) {
- if (!storage.deprecated()) {
- return storage;
- }
- }
- throw new AssertionFailedError("All storages are deprecated");
+ private static void doSaveComponent(Object appComponent) {
+ //noinspection TestOnlyProblems
+ ((ComponentStoreImpl)((ApplicationImpl)ApplicationManager.getApplication()).getStateStore()).saveApplicationComponent(appComponent);
}
public static void enableExternalCompiler() {
@@ -164,10 +98,4 @@ public class CompilerTestUtil {
}
}.execute();
}
-
- private static class SaveSessionRequestor implements StateStorage.SaveSession {
- @Override
- public void save() {
- }
- }
}
diff --git a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java
index 8646ba0c72aa..ad29218f28c4 100644
--- a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java
+++ b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeAssocTable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.openapi.fileTypes.impl;
import com.intellij.openapi.fileTypes.ExactFileNameMatcher;
@@ -226,7 +225,7 @@ public class FileTypeAssocTable {
}
@NotNull
- public List getAssociations(final T type) {
+ public List getAssociations(@NotNull T type) {
List result = new ArrayList();
for (Pair mapping : myMatchingMappings) {
if (mapping.getSecond() == type) {
@@ -255,28 +254,33 @@ public class FileTypeAssocTable {
return result;
}
- public boolean hasAssociationsFor(final T fileType) {
- if (myExtensionMappings.values().contains(fileType)) return true;
- if (myExactFileNameMappings.values().contains(fileType)) return true;
- if (myExactFileNameAnyCaseMappings.values().contains(fileType)) return true;
+ public boolean hasAssociationsFor(@NotNull T fileType) {
+ if (myExtensionMappings.values().contains(fileType) ||
+ myExactFileNameMappings.values().contains(fileType) ||
+ myExactFileNameAnyCaseMappings.values().contains(fileType)) {
+ return true;
+ }
for (Pair mapping : myMatchingMappings) {
- if (mapping.getSecond() == fileType) return true;
+ if (mapping.getSecond() == fileType) {
+ return true;
+ }
}
return false;
}
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
- final FileTypeAssocTable that = (FileTypeAssocTable)o;
-
- if (!myExtensionMappings.equals(that.myExtensionMappings)) return false;
- if (!myMatchingMappings.equals(that.myMatchingMappings)) return false;
- if (!myExactFileNameMappings.equals(that.myExactFileNameMappings)) return false;
- if (!myExactFileNameAnyCaseMappings.equals(that.myExactFileNameAnyCaseMappings)) return false;
-
- return true;
+ FileTypeAssocTable> that = (FileTypeAssocTable)o;
+ return myExtensionMappings.equals(that.myExtensionMappings) &&
+ myMatchingMappings.equals(that.myMatchingMappings) &&
+ myExactFileNameMappings.equals(that.myExactFileNameMappings) &&
+ myExactFileNameAnyCaseMappings.equals(that.myExactFileNameAnyCaseMappings);
}
public int hashCode() {
diff --git a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java
index e64ed100419e..747c0528753a 100644
--- a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java
+++ b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java
@@ -45,7 +45,6 @@ public class IgnoredPatternSet {
addIgnoreMask(ignoredFile);
}
}
-
}
void addIgnoreMask(@NotNull String ignoredFile) {
diff --git a/lib/src/winp-1.23-sources.jar b/lib/src/winp-1.23-sources.jar
new file mode 100644
index 000000000000..255784887d3a
Binary files /dev/null and b/lib/src/winp-1.23-sources.jar differ
diff --git a/lib/winp-1.23.jar b/lib/winp-1.23.jar
new file mode 100644
index 000000000000..3d88c38c0a95
Binary files /dev/null and b/lib/winp-1.23.jar differ
diff --git a/platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java b/platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java
index 5c89d98ecfa2..ad0679329bd5 100644
--- a/platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java
+++ b/platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -16,6 +16,7 @@
package com.intellij.codeInsight.highlighting;
+import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiErrorElement;
import org.jetbrains.annotations.NotNull;
@@ -23,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
* @author spleaner
*/
public abstract class HighlightErrorFilter {
+ public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.highlightErrorFilter");
public abstract boolean shouldHighlightErrorElement(@NotNull final PsiErrorElement element);
diff --git a/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java
index 9119fd6eadab..8c2a8c5c51e2 100644
--- a/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java
+++ b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java
@@ -34,6 +34,8 @@ import org.jetbrains.annotations.NotNull;
*
* Implement {@link HighPriorityAction HighPriorityAction} or
* {@link LowPriorityAction LowPriorityAction} to change ordering.
+ *
+ * Can be {@link com.intellij.openapi.project.DumbAware}.
*
* @see IntentionManager#registerIntentionAndMetaData(IntentionAction, String...)
*/
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java
index 84625d642c58..3936e59161b2 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -25,7 +25,6 @@ import com.intellij.lang.LanguageUtil;
import com.intellij.lang.annotation.Annotation;
import com.intellij.lang.annotation.Annotator;
import com.intellij.openapi.extensions.ExtensionPointListener;
-import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.openapi.progress.ProgressManager;
@@ -50,7 +49,6 @@ import java.util.List;
public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
private AnnotationHolderImpl myAnnotationHolder;
- public static final ExtensionPointName FILTER_EP_NAME = ExtensionPointName.create("com.intellij.highlightErrorFilter");
private final HighlightErrorFilter[] myErrorFilters;
private final Project myProject;
private final boolean myHighlightErrorElements;
@@ -67,7 +65,7 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
myProject = project;
myHighlightErrorElements = highlightErrorElements;
myRunAnnotators = runAnnotators;
- myErrorFilters = Extensions.getExtensions(FILTER_EP_NAME, project);
+ myErrorFilters = Extensions.getExtensions(HighlightErrorFilter.EP_NAME, project);
myDumbService = DumbService.getInstance(project);
myBatchMode = batchMode;
}
diff --git a/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java b/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java
index 6f4818b29207..29a8905a45b9 100644
--- a/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java
+++ b/platform/bootstrap/src/com/intellij/ide/BootstrapClassLoaderUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
@@ -100,35 +100,36 @@ public class BootstrapClassLoaderUtil extends ClassUtilCore {
}
private static void addParentClasspath(List classpathElements) throws MalformedURLException {
- ClassLoader loader = BootstrapClassLoaderUtil.class.getClassLoader();
- if (loader instanceof URLClassLoader) {
- ContainerUtil.addAll(classpathElements, ((URLClassLoader)loader).getURLs());
- }
- else {
- String loaderName = loader.getClass().getName();
- try {
- Class> antClassLoaderClass = Class.forName("org.apache.tools.ant.AntClassLoader");
- if (antClassLoaderClass.isInstance(loader) ||
- "org.apache.tools.ant.AntClassLoader".equals(loaderName) ||
- "org.apache.tools.ant.loader.AntClassLoader2".equals(loaderName)) {
- String classpath = (String)antClassLoaderClass
- .getDeclaredMethod("getClasspath", ArrayUtil.EMPTY_CLASS_ARRAY)
- .invoke(loader, ArrayUtil.EMPTY_OBJECT_ARRAY);
- StringTokenizer tokenizer = new StringTokenizer(classpath, File.separator, false);
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- classpathElements.add(new File(token).toURI().toURL());
+ for (ClassLoader loader = BootstrapClassLoaderUtil.class.getClassLoader(); loader != null; loader = loader.getParent()) {
+ if (loader instanceof URLClassLoader) {
+ ContainerUtil.addAll(classpathElements, ((URLClassLoader)loader).getURLs());
+ }
+ else {
+ String loaderName = loader.getClass().getName();
+ try {
+ Class> antClassLoaderClass = Class.forName("org.apache.tools.ant.AntClassLoader");
+ if (antClassLoaderClass.isInstance(loader) ||
+ "org.apache.tools.ant.AntClassLoader".equals(loaderName) ||
+ "org.apache.tools.ant.loader.AntClassLoader2".equals(loaderName)) {
+ String classpath = (String)antClassLoaderClass
+ .getDeclaredMethod("getClasspath", ArrayUtil.EMPTY_CLASS_ARRAY)
+ .invoke(loader, ArrayUtil.EMPTY_OBJECT_ARRAY);
+ StringTokenizer tokenizer = new StringTokenizer(classpath, File.separator, false);
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ classpathElements.add(new File(token).toURI().toURL());
+ }
+ }
+ else {
+ getLogger().warn("Unknown class loader: " + loaderName);
}
}
- else {
- getLogger().warn("Unknown class loader: " + loaderName);
- }
+ catch (ClassCastException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
+ catch (ClassNotFoundException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
+ catch (NoSuchMethodException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
+ catch (IllegalAccessException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
+ catch (InvocationTargetException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
}
- catch (ClassCastException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
- catch (ClassNotFoundException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
- catch (NoSuchMethodException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
- catch (IllegalAccessException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
- catch (InvocationTargetException e) { getLogger().warn("Unknown class loader '" + loaderName + "'", e); }
}
}
diff --git a/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java b/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java
index 350c403cadd1..845e50fbe804 100644
--- a/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java
+++ b/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java
@@ -33,15 +33,15 @@ public abstract class BaseSchemeProcessor implem
}
@Override
- public void onSchemeAdded(@NotNull final T scheme) {
+ public void onSchemeAdded(@NotNull T scheme) {
}
@Override
- public void onSchemeDeleted(@NotNull final T scheme) {
+ public void onSchemeDeleted(@NotNull T scheme) {
}
@Override
- public void onCurrentSchemeChanged(final Scheme newCurrentScheme) {
+ public void onCurrentSchemeChanged(Scheme newCurrentScheme) {
}
@Nullable
@@ -49,6 +49,14 @@ public abstract class BaseSchemeProcessor implem
return readScheme(new Document((Element)element.detach()));
}
+ @Nullable
+ /**
+ * @param duringLoad If occurred during {@link SchemesManager#loadSchemes()} call
+ */
+ public T readScheme(@NotNull Element element, boolean duringLoad) throws InvalidDataException, IOException, JDOMException {
+ return readScheme(element);
+ }
+
@Override
public T readScheme(@NotNull Document schemeContent) throws InvalidDataException, IOException, JDOMException {
throw new AbstractMethodError();
diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbService.java b/platform/core-api/src/com/intellij/openapi/project/DumbService.java
index bbc3e824e933..68ca99133e46 100644
--- a/platform/core-api/src/com/intellij/openapi/project/DumbService.java
+++ b/platform/core-api/src/com/intellij/openapi/project/DumbService.java
@@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -159,6 +160,19 @@ public abstract class DumbService {
return INSTANCE_KEY.getValue(project);
}
+ /**
+ * @return all the elements of the given array if there's no dumb mode currently, or the dumb-aware ones if {@link #isDumb()} is true.
+ * @see #isDumbAware(Object)
+ */
+ @NotNull
+ public List filterByDumbAwareness(@NotNull T[] array) {
+ return filterByDumbAwareness(Arrays.asList(array));
+ }
+
+ /**
+ * @return all the elements of the given collection if there's no dumb mode currently, or the dumb-aware ones if {@link #isDumb()} is true.
+ * @see #isDumbAware(Object)
+ */
@NotNull
public List filterByDumbAwareness(@NotNull Collection collection) {
if (isDumb()) {
@@ -227,6 +241,20 @@ public abstract class DumbService {
*/
public abstract void setAlternativeResolveEnabled(boolean enabled);
+ /**
+ * Invokes the given runnable with alternative resolve set to true.
+ * @see #setAlternativeResolveEnabled(boolean)
+ */
+ public void withAlternativeResolveEnabled(@NotNull Runnable runnable) {
+ setAlternativeResolveEnabled(true);
+ try {
+ runnable.run();
+ }
+ finally {
+ setAlternativeResolveEnabled(false);
+ }
+ }
+
/**
* @return whether alternative resolution is enabled for the current thread.
*
diff --git a/platform/core-impl/src/com/intellij/mock/MockComponentManager.java b/platform/core-impl/src/com/intellij/mock/MockComponentManager.java
index 33dce7f09ce3..7a7348fdbee0 100644
--- a/platform/core-impl/src/com/intellij/mock/MockComponentManager.java
+++ b/platform/core-impl/src/com/intellij/mock/MockComponentManager.java
@@ -43,26 +43,30 @@ public class MockComponentManager extends UserDataHolderBase implements Componen
private final MutablePicoContainer myPicoContainer;
private final Map myComponents = new HashMap();
+ private final Set