mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+6
-1
@@ -178,6 +178,9 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple
|
||||
PsiModificationTracker.MODIFICATION_COUNT,
|
||||
this));
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("an exception during scope without code references calculation", e);
|
||||
return null;
|
||||
@@ -211,7 +214,6 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple
|
||||
if (!isServiceEnabledFor(aClass) || searchScope == LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope()) return null;
|
||||
|
||||
try {
|
||||
|
||||
Map<VirtualFile, Object[]> candidatesPerFile = ReadAction.compute(() -> {
|
||||
if (myProject.isDisposed()) throw new ProcessCanceledException();
|
||||
return CachedValuesManager.getCachedValue(aClass, () -> CachedValueProvider.Result.create(
|
||||
@@ -234,6 +236,9 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService imple
|
||||
}
|
||||
return new CompilerHierarchyInfoImpl(candidatesPerFile, aClass, dirtyScope, searchScope, myProject, searchFileType, searchType);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("an exception during hierarchy calculation", e);
|
||||
return null;
|
||||
|
||||
+1
-9
@@ -20,14 +20,12 @@ import com.intellij.debugger.engine.JavaDebugProcess;
|
||||
import com.intellij.debugger.settings.JavaDebuggerSettings;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.TabbedConfigurable;
|
||||
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
@@ -49,8 +47,7 @@ public class CustomizeContextViewAction extends XDebuggerTreeActionBase {
|
||||
@Override
|
||||
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
|
||||
final Project project = e.getProject();
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
final MyTabbedConfigurable configurable = new MyTabbedConfigurable(disposable);
|
||||
final MyTabbedConfigurable configurable = new MyTabbedConfigurable();
|
||||
SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable) {
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
@@ -66,15 +63,10 @@ public class CustomizeContextViewAction extends XDebuggerTreeActionBase {
|
||||
super.doCancelAction();
|
||||
}
|
||||
};
|
||||
Disposer.register(editor.getDisposable(), disposable);
|
||||
editor.show();
|
||||
}
|
||||
|
||||
private static class MyTabbedConfigurable extends TabbedConfigurable {
|
||||
public MyTabbedConfigurable(@NotNull Disposable parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Configurable> createConfigurables() {
|
||||
return JavaDebuggerSettings.createDataViewsConfigurable();
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.jdi.StackFrameProxy;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
@@ -156,7 +155,7 @@ public class RequestHint {
|
||||
return myMethodFilter instanceof BreakpointStepMethodFilter || myTargetMethodMatched;
|
||||
}
|
||||
|
||||
private boolean isTheSameFrame(SuspendContextImpl context) {
|
||||
protected boolean isTheSameFrame(SuspendContextImpl context) {
|
||||
if (mySteppedOut) return false;
|
||||
final ThreadReferenceProxyImpl contextThread = context.getThread();
|
||||
if (contextThread != null) {
|
||||
@@ -188,6 +187,10 @@ public class RequestHint {
|
||||
return STOP;
|
||||
}
|
||||
|
||||
protected boolean isSteppedOut() {
|
||||
return mySteppedOut;
|
||||
}
|
||||
|
||||
public int getNextStepDepth(final SuspendContextImpl context) {
|
||||
try {
|
||||
final StackFrameProxyImpl frameProxy = context.getFrameProxy();
|
||||
|
||||
@@ -131,7 +131,17 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
|
||||
myAllClassesByName = new MultiMap<>();
|
||||
allClasses().forEach(t -> myAllClassesByName.putValue(t.signature(), t));
|
||||
}
|
||||
return (List<ReferenceType>)myAllClassesByName.get(signature);
|
||||
Collection<ReferenceType> res = myAllClassesByName.get(signature);
|
||||
// TODO: Below is extra logging for IDEA-164040, remove when fixed
|
||||
if (res.isEmpty()) {
|
||||
List<ReferenceType> types = myVirtualMachine.classesByName(s);
|
||||
if (!types.isEmpty()) {
|
||||
LOG.error("Obsolete classes cache does not contain " + s + ", while the real vm does");
|
||||
clearCaches();
|
||||
}
|
||||
return types;
|
||||
}
|
||||
return (List<ReferenceType>)res;
|
||||
}
|
||||
else {
|
||||
return myVirtualMachine.classesByName(s);
|
||||
|
||||
@@ -245,7 +245,7 @@ public class BreakpointManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public ExceptionBreakpoint addExceptionBreakpoint(@NotNull final String exceptionClassName, final String packageName) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
final JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
|
||||
|
||||
@@ -47,7 +47,6 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizerUtil;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -150,14 +149,17 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
}
|
||||
|
||||
AtomicReference<ProgressIndicator> indicatorRef = new AtomicReference<>();
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, myProject)));
|
||||
ApplicationManager.getApplication()
|
||||
.invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, false, myProject, "Cancel emulation")));
|
||||
ProgressIndicator indicator = indicatorRef.get();
|
||||
ProgressManager.getInstance().executeProcessUnderProgress(
|
||||
() -> processPreparedSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(debugProcess, subType, false), indicator),
|
||||
indicator);
|
||||
if (indicator.isCanceled()) {
|
||||
ApplicationManager.getApplication().invokeLater(
|
||||
() -> DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(this));
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
getProperties().EMULATED = false;
|
||||
fireBreakpointChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +495,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
}
|
||||
|
||||
public boolean isEmulated() {
|
||||
return getProperties().EMULATED && Registry.is("debugger.emulate.method.breakpoints");
|
||||
return getProperties().EMULATED;
|
||||
}
|
||||
|
||||
private boolean isWatchEntry() {
|
||||
|
||||
+1
-3
@@ -17,7 +17,6 @@
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.util.ui.DialogUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -98,8 +97,7 @@ public class MethodBreakpointPropertiesPanel extends XBreakpointCustomProperties
|
||||
|
||||
@Override
|
||||
public void loadFrom(@NotNull XBreakpoint<JavaMethodBreakpointProperties> breakpoint) {
|
||||
myEmulatedCheckBox.setVisible(
|
||||
Registry.is("debugger.emulate.method.breakpoints") && breakpoint.getType() instanceof JavaMethodBreakpointType);
|
||||
myEmulatedCheckBox.setVisible(breakpoint.getType() instanceof JavaMethodBreakpointType);
|
||||
myEmulatedCheckBox.setSelected(breakpoint.getProperties().EMULATED);
|
||||
|
||||
myWatchEntryCheckBox.setSelected(breakpoint.getProperties().WATCH_ENTRY);
|
||||
|
||||
@@ -107,15 +107,19 @@ public class JUnitUtil {
|
||||
}
|
||||
|
||||
public static boolean isTestMethod(final Location<? extends PsiMethod> location, boolean checkAbstract, boolean checkRunWith) {
|
||||
return isTestMethod(location, checkAbstract, checkRunWith, true);
|
||||
}
|
||||
|
||||
public static boolean isTestMethod(final Location<? extends PsiMethod> location, boolean checkAbstract, boolean checkRunWith, boolean checkClass) {
|
||||
final PsiMethod psiMethod = location.getPsiElement();
|
||||
final PsiClass aClass = location instanceof MethodLocation ? ((MethodLocation)location).getContainingClass() : psiMethod.getContainingClass();
|
||||
if (aClass == null || !isTestClass(aClass, checkAbstract, true)) return false;
|
||||
if (checkClass && (aClass == null || !isTestClass(aClass, checkAbstract, true))) return false;
|
||||
if (isTestAnnotated(psiMethod)) return true;
|
||||
if (psiMethod.isConstructor()) return false;
|
||||
if (!psiMethod.hasModifierProperty(PsiModifier.PUBLIC)) return false;
|
||||
if (psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) return false;
|
||||
if (AnnotationUtil.isAnnotated(psiMethod, CONFIGURATIONS_ANNOTATION_NAME, false)) return false;
|
||||
if (checkRunWith) {
|
||||
if (checkClass && checkRunWith) {
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(aClass, RUN_WITH);
|
||||
if (annotation != null) {
|
||||
return !isParameterized(annotation);
|
||||
@@ -124,8 +128,11 @@ public class JUnitUtil {
|
||||
if (psiMethod.getParameterList().getParametersCount() > 0) return false;
|
||||
if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
if (!psiMethod.getName().startsWith("test")) return false;
|
||||
PsiClass testCaseClass = getTestCaseClassOrNull(location);
|
||||
return testCaseClass != null && psiMethod.getContainingClass().isInheritor(testCaseClass, true) && PsiType.VOID.equals(psiMethod.getReturnType());
|
||||
if (checkClass) {
|
||||
PsiClass testCaseClass = getTestCaseClassOrNull(location);
|
||||
if (testCaseClass == null || !psiMethod.getContainingClass().isInheritor(testCaseClass, true)) return false;
|
||||
}
|
||||
return PsiType.VOID.equals(psiMethod.getReturnType());
|
||||
}
|
||||
|
||||
public static boolean isTestCaseInheritor(final PsiClass aClass) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,6 @@ import java.util.Collection;
|
||||
|
||||
public class RemoteConfiguration extends ModuleBasedConfiguration<JavaRunConfigurationModule>
|
||||
implements RunConfigurationWithSuppressedDefaultRunAction, RemoteRunProfile {
|
||||
|
||||
@Override
|
||||
public void writeExternal(final Element element) throws WriteExternalException {
|
||||
super.writeExternal(element);
|
||||
@@ -100,6 +99,4 @@ public class RemoteConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
public Collection<Module> getValidModules() {
|
||||
return getAllModules();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
@@ -291,7 +289,7 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
});
|
||||
myConfigureButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> doConfigure());
|
||||
doConfigure();
|
||||
}
|
||||
});
|
||||
updateState();
|
||||
|
||||
+1
-7
@@ -28,8 +28,6 @@ import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -40,7 +38,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContaine
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -90,10 +87,7 @@ public class AddSupportForSingleFrameworkDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
protected void doOKAction() {
|
||||
final Ref<Boolean> result = Ref.create(false);
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> result.set(addSupport()));
|
||||
|
||||
if (result.get()) {
|
||||
if (addSupport()) {
|
||||
super.doOKAction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,11 +153,6 @@ public class ImportModuleAction extends AnAction {
|
||||
return createImportWizard(project, dialogParent, file, providers);
|
||||
}
|
||||
|
||||
/** @deprecated to be removed in IDEA 16 */
|
||||
public static String getFileChooserDescription(@Nullable final Project project) {
|
||||
return getFileChooserDescription(getProviders(project));
|
||||
}
|
||||
|
||||
private static String getFileChooserDescription(List<ProjectImportProvider> providers) {
|
||||
StringBuilder builder = new StringBuilder("<html>Select ");
|
||||
boolean first = true;
|
||||
|
||||
+1
-3
@@ -19,8 +19,6 @@ import com.intellij.application.options.ModulesComboBox;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
@@ -132,7 +130,7 @@ public class CreateLibraryFromFilesDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> addLibrary());
|
||||
addLibrary();
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -22,8 +22,6 @@ import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
@@ -89,13 +87,13 @@ public class AddFrameworkSupportDialog extends DialogWrapper {
|
||||
if (!myAddSupportPanel.validate()) return;
|
||||
if (!myAddSupportPanel.downloadLibraries(myAddSupportPanel.getMainPanel())) return;
|
||||
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> new WriteAction() {
|
||||
new WriteAction() {
|
||||
protected void run(@NotNull final Result result) {
|
||||
ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
myAddSupportPanel.addSupport(myModule, model);
|
||||
model.commit();
|
||||
}
|
||||
}.execute());
|
||||
}.execute();
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
@@ -27,14 +27,11 @@ import com.intellij.ide.wizard.StepWithSubSteps;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
@@ -164,9 +161,7 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS
|
||||
|
||||
@Override
|
||||
protected final void doOKAction() {
|
||||
final Ref<Boolean> result = Ref.create(false);
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> result.set(doFinishAction()));
|
||||
if (!result.get()) return;
|
||||
if (!doFinishAction()) return;
|
||||
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
+8
-21
@@ -33,8 +33,6 @@ import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.IdeaModifiableModelsProvider;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
@@ -43,7 +41,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContaine
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
@@ -402,26 +399,16 @@ public class AddSupportForFrameworksPanel implements Disposable {
|
||||
}
|
||||
|
||||
public boolean downloadLibraries(@NotNull final JComponent parentComponent) {
|
||||
final Ref<Boolean> result = Ref.create(true);
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> {
|
||||
applyLibraryOptionsForSelected();
|
||||
List<LibraryCompositionSettings> list = getLibrariesCompositionSettingsList();
|
||||
for (LibraryCompositionSettings compositionSettings : list) {
|
||||
if (!compositionSettings.downloadFiles(parentComponent)) {
|
||||
result.set(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!result.get()) {
|
||||
int answer = Messages.showYesNoDialog(parentComponent,
|
||||
ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
|
||||
CommonBundle.getWarningTitle(), Messages.getWarningIcon());
|
||||
if (answer != Messages.YES) {
|
||||
return false;
|
||||
applyLibraryOptionsForSelected();
|
||||
for (LibraryCompositionSettings compositionSettings : getLibrariesCompositionSettingsList()) {
|
||||
if (!compositionSettings.downloadFiles(parentComponent)) {
|
||||
int answer = Messages.showYesNoDialog(parentComponent,
|
||||
ProjectBundle.message("warning.message.some.required.libraries.wasn.t.downloaded"),
|
||||
CommonBundle.getWarningTitle(), Messages.getWarningIcon());
|
||||
return answer == Messages.YES;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+15
-19
@@ -32,8 +32,6 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
@@ -374,24 +372,22 @@ public class ModulesConfigurator implements ModulesProvider, ModuleEditor.Change
|
||||
final ProjectBuilder builder = runModuleWizard(parent, anImport);
|
||||
if (builder != null ) {
|
||||
final List<Module> modules = new ArrayList<>();
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> {
|
||||
final List<Module> committedModules;
|
||||
if (builder instanceof ProjectImportBuilder<?>) {
|
||||
final ModifiableArtifactModel artifactModel =
|
||||
ProjectStructureConfigurable.getInstance(myProject).getArtifactsStructureConfigurable().getModifiableArtifactModel();
|
||||
committedModules = ((ProjectImportBuilder<?>)builder).commit(myProject, myModuleModel, this, artifactModel);
|
||||
final List<Module> committedModules;
|
||||
if (builder instanceof ProjectImportBuilder<?>) {
|
||||
final ModifiableArtifactModel artifactModel =
|
||||
ProjectStructureConfigurable.getInstance(myProject).getArtifactsStructureConfigurable().getModifiableArtifactModel();
|
||||
committedModules = ((ProjectImportBuilder<?>)builder).commit(myProject, myModuleModel, this, artifactModel);
|
||||
}
|
||||
else {
|
||||
committedModules = builder.commit(myProject, myModuleModel, this);
|
||||
}
|
||||
if (committedModules != null) {
|
||||
modules.addAll(committedModules);
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
for (Module module : modules) {
|
||||
getOrCreateModuleEditor(module);
|
||||
}
|
||||
else {
|
||||
committedModules = builder.commit(myProject, myModuleModel, this);
|
||||
}
|
||||
if (committedModules != null) {
|
||||
modules.addAll(committedModules);
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
for (Module module : modules) {
|
||||
getOrCreateModuleEditor(module);
|
||||
}
|
||||
});
|
||||
});
|
||||
return modules;
|
||||
}
|
||||
|
||||
+16
-20
@@ -22,8 +22,6 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
@@ -89,25 +87,23 @@ public class AddCustomLibraryDialog extends DialogWrapper {
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
final LibraryCompositionSettings settings = myPanel.apply();
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> {
|
||||
if (settings != null && settings.downloadFiles(myPanel.getMainPanel())) {
|
||||
if (myModifiableRootModel == null) {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull final Result result) {
|
||||
addLibraries(model, settings);
|
||||
model.commit();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
else {
|
||||
addLibraries(myModifiableRootModel, settings);
|
||||
}
|
||||
|
||||
if (settings != null && settings.downloadFiles(myPanel.getMainPanel())) {
|
||||
if (myModifiableRootModel == null) {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull final Result result) {
|
||||
addLibraries(model, settings);
|
||||
model.commit();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
super.doOKAction();
|
||||
});
|
||||
else {
|
||||
addLibraries(myModifiableRootModel, settings);
|
||||
}
|
||||
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
private void addLibraries(ModifiableRootModel model, final LibraryCompositionSettings settings) {
|
||||
|
||||
+13
-15
@@ -17,15 +17,15 @@ package com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
|
||||
import com.intellij.openapi.roots.ui.configuration.classpath.ChangeLibraryLevelActionBase;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElementUsage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -59,20 +59,18 @@ public class ChangeLibraryLevelAction extends ChangeLibraryLevelActionBase {
|
||||
final LibraryEx oldLibrary = (LibraryEx)context.getLibrary(libraryElement.getLibrary().getName(), mySourceConfigurable.getLevel());
|
||||
LOG.assertTrue(oldLibrary != null);
|
||||
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> {
|
||||
final Library newLibrary = doCopy(oldLibrary);
|
||||
if (newLibrary == null) return;
|
||||
final Library newLibrary = doCopy(oldLibrary);
|
||||
if (newLibrary == null) return;
|
||||
|
||||
final Collection<ProjectStructureElementUsage> usages = context.getDaemonAnalyzer().getUsages(libraryElement);
|
||||
for (ProjectStructureElementUsage usage : usages) {
|
||||
usage.replaceElement(new LibraryProjectStructureElement(context, newLibrary));
|
||||
}
|
||||
final Collection<ProjectStructureElementUsage> usages = context.getDaemonAnalyzer().getUsages(libraryElement);
|
||||
for (ProjectStructureElementUsage usage : usages) {
|
||||
usage.replaceElement(new LibraryProjectStructureElement(context, newLibrary));
|
||||
}
|
||||
|
||||
if (!myCopy) {
|
||||
mySourceConfigurable.removeLibrary(libraryElement);
|
||||
}
|
||||
ProjectStructureConfigurable.getInstance(myProject).selectProjectOrGlobalLibrary(newLibrary, true);
|
||||
});
|
||||
if (!myCopy) {
|
||||
mySourceConfigurable.removeLibrary(libraryElement);
|
||||
}
|
||||
ProjectStructureConfigurable.getInstance(myProject).selectProjectOrGlobalLibrary(newLibrary, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-9
@@ -33,7 +33,9 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.*;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.*;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.ClonableOrderEntry;
|
||||
import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
|
||||
@@ -58,8 +60,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.navigation.Place;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -907,12 +907,10 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
};
|
||||
builder.setName(component.getNameValue());
|
||||
builder.setModuleFilePath(path + "/" + builder.getName() + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, () -> {
|
||||
final Module module = myContext.myModulesConfigurator.addModule(builder);
|
||||
if (module != null) {
|
||||
addModuleNode(module);
|
||||
}
|
||||
});
|
||||
final Module module = myContext.myModulesConfigurator.addModule(builder);
|
||||
if (module != null) {
|
||||
addModuleNode(module);
|
||||
}
|
||||
}
|
||||
catch (Exception e1) {
|
||||
LOG.error(e1);
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class WrapLongWithMathToIntExactFix extends LocalQuickFixAndIntentionActi
|
||||
@Nullable
|
||||
@Override
|
||||
protected PsiExpression getModifiedArgument(final PsiExpression expression, final PsiType toType) throws IncorrectOperationException {
|
||||
return areSameTypes(toType, PsiType.INT) ? (PsiExpression)getModifiedExpression(expression) : null;
|
||||
return areSameTypes(expression.getType(), PsiType.LONG) && areSameTypes(toType, PsiType.INT) ? (PsiExpression)getModifiedExpression(expression) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -162,6 +162,11 @@ public class UnnecessaryModuleDependencyInspection extends GlobalInspectionTool
|
||||
return "Remove dependency";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull CommonProblemDescriptor descriptor) {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||
|
||||
+5
-1
@@ -39,7 +39,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -131,6 +130,11 @@ public class UnusedLibrariesInspection extends GlobalInspectionTool {
|
||||
myFiles = files;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
|
||||
+10
-1
@@ -107,7 +107,16 @@ public class JavaLanguageLevelPusher implements FilePropertyPusher<LanguageLevel
|
||||
DataInputOutputUtil.writeINT(oStream, level.ordinal());
|
||||
oStream.close();
|
||||
|
||||
PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(fileOrDir, f -> isJavaLike(f.getFileType()));
|
||||
// Todo: GwtLanguageLevelPusher changes java language level for single files without firing filePropertiesChanged
|
||||
// so code below doesn't work.
|
||||
// Uncomment it and remove older code once the problem is fixed
|
||||
//PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(fileOrDir, f -> isJavaLike(f.getFileType()));
|
||||
|
||||
for (VirtualFile child : fileOrDir.getChildren()) {
|
||||
if (!child.isDirectory() && isJavaLike(child.getFileType())) {
|
||||
PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isJavaLike(FileType type) {
|
||||
|
||||
@@ -88,18 +88,21 @@ class JavaModuleCompletion {
|
||||
}
|
||||
|
||||
private static void addModuleReferences(PsiElement context, Consumer<LookupElement> result) {
|
||||
PsiJavaModule host = PsiTreeUtil.getParentOfType(context, PsiJavaModule.class);
|
||||
if (host != null) {
|
||||
String hostName = host.getModuleName();
|
||||
Project project = context.getProject();
|
||||
JavaModuleNameIndex index = JavaModuleNameIndex.getInstance();
|
||||
GlobalSearchScope scope = ProjectScope.getAllScope(project);
|
||||
index.processAllKeys(project, name -> {
|
||||
if (!name.equals(hostName) && index.get(name, project, scope).size() == 1) {
|
||||
result.consume(new OverrideableSpace(LookupElementBuilder.create(name), TailType.SEMICOLON));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
PsiElement statement = context.getParent();
|
||||
if (!(statement instanceof PsiJavaModule)) {
|
||||
PsiElement host = statement.getParent();
|
||||
if (host instanceof PsiJavaModule) {
|
||||
String hostName = ((PsiJavaModule)host).getModuleName();
|
||||
Project project = context.getProject();
|
||||
JavaModuleNameIndex index = JavaModuleNameIndex.getInstance();
|
||||
GlobalSearchScope scope = ProjectScope.getAllScope(project);
|
||||
index.processAllKeys(project, name -> {
|
||||
if (!name.equals(hostName) && index.get(name, project, scope).size() == 1) {
|
||||
result.consume(new OverrideableSpace(LookupElementBuilder.create(name), TailType.SEMICOLON));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
@@ -38,28 +35,6 @@ import java.util.Collection;
|
||||
public class LookupItemUtil{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.lookup.LookupItemUtil");
|
||||
|
||||
/**
|
||||
* @deprecated to remove in IDEA 16
|
||||
*/
|
||||
@Nullable
|
||||
public static LookupElement addLookupItem(Collection<LookupElement> set, @NotNull Object object) {
|
||||
if (object instanceof PsiType) {
|
||||
PsiType psiType = (PsiType)object;
|
||||
for (final LookupElement lookupItem : set) {
|
||||
Object o = lookupItem.getObject();
|
||||
if (o.equals(psiType)) {
|
||||
return lookupItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (LookupElement lookupItem : set) {
|
||||
if(lookupItem.getObject().equals(lookupItem)) return null;
|
||||
}
|
||||
LookupElement item = objectToLookupItem(object);
|
||||
return set.add(item) ? item : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @see LookupElementBuilder
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,7 +96,7 @@ public class JavaAnonymousUnwrapper extends JavaUnwrapper {
|
||||
private static PsiElement findTopmostParentOfType(PsiElement el, Class<? extends PsiElement> clazz) {
|
||||
while (true) {
|
||||
@SuppressWarnings({"unchecked"})
|
||||
PsiElement temp = PsiTreeUtil.getParentOfType(el, clazz, true, PsiAnonymousClass.class);
|
||||
PsiElement temp = PsiTreeUtil.getParentOfType(el, clazz, true, PsiAnonymousClass.class, PsiLambdaExpression.class);
|
||||
if (temp == null || temp instanceof PsiFile) return el;
|
||||
el = temp;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class JavaLambdaUnwrapper extends JavaUnwrapper {
|
||||
}
|
||||
else {
|
||||
context.extractElement(body, from);
|
||||
if (context.myIsEffective) {
|
||||
if (context.myIsEffective && !(from.getParent() instanceof PsiLambdaExpression)) {
|
||||
PsiStatement emptyStatement = JavaPsiFacade.getElementFactory(from.getProject()).createStatementFromText(";", from);
|
||||
from.getParent().addBefore(emptyStatement, from);
|
||||
}
|
||||
|
||||
+5
@@ -90,6 +90,11 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT
|
||||
return InspectionsBundle.message("default.file.template.edit.template");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) {
|
||||
final FileTemplateConfigurable configurable = new FileTemplateConfigurable(project);
|
||||
|
||||
+5
@@ -79,6 +79,11 @@ public class DependencyInspection extends DependencyInspectionBase {
|
||||
return InspectionsBundle.message("edit.dependency.rules.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
ShowSettingsUtil.getInstance().editConfigurable(project, new DependencyConfigurable(project));
|
||||
|
||||
+8
-3
@@ -15,22 +15,27 @@
|
||||
*/
|
||||
package com.intellij.ide.projectView;
|
||||
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CompositePsiClasChildrenSource implements PsiClassChildrenSource {
|
||||
class CompositePsiClassChildrenSource implements PsiClassChildrenSource {
|
||||
private final PsiClassChildrenSource[] mySources;
|
||||
|
||||
public CompositePsiClasChildrenSource(PsiClassChildrenSource[] sources) {
|
||||
CompositePsiClassChildrenSource(PsiClassChildrenSource[] sources) {
|
||||
mySources = sources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildren(PsiClass psiClass, List<PsiElement> children) {
|
||||
for (PsiClassChildrenSource source : mySources) {
|
||||
source.addChildren(psiClass, children);
|
||||
try {
|
||||
source.addChildren(psiClass, children);
|
||||
}
|
||||
catch (IndexNotReadyException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,5 +50,5 @@ public interface PsiClassChildrenSource {
|
||||
}
|
||||
};
|
||||
|
||||
PsiClassChildrenSource DEFAULT_CHILDREN = new CompositePsiClasChildrenSource(new PsiClassChildrenSource[]{CLASSES, METHODS, FIELDS});
|
||||
PsiClassChildrenSource DEFAULT_CHILDREN = new CompositePsiClassChildrenSource(new PsiClassChildrenSource[]{CLASSES, METHODS, FIELDS});
|
||||
}
|
||||
|
||||
@@ -374,13 +374,10 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
public void setupSdkPaths(@NotNull Sdk sdk) {
|
||||
String homePath = sdk.getHomePath();
|
||||
assert homePath != null : sdk;
|
||||
|
||||
File jdkHome = new File(homePath);
|
||||
List<VirtualFile> classes = findClasses(jdkHome, false);
|
||||
VirtualFile sources = findSources(jdkHome);
|
||||
VirtualFile docs = findDocs(jdkHome, "docs/api");
|
||||
SdkModificator sdkModificator = sdk.getSdkModificator();
|
||||
|
||||
List<VirtualFile> classes = findClasses(jdkHome, false);
|
||||
Set<VirtualFile> previousRoots = new LinkedHashSet<>(Arrays.asList(sdkModificator.getRoots(OrderRootType.CLASSES)));
|
||||
sdkModificator.removeRoots(OrderRootType.CLASSES);
|
||||
previousRoots.removeAll(new HashSet<>(classes));
|
||||
@@ -391,49 +388,8 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
sdkModificator.addRoot(root, OrderRootType.CLASSES);
|
||||
}
|
||||
|
||||
if (sources != null) {
|
||||
sdkModificator.addRoot(sources, OrderRootType.SOURCES);
|
||||
}
|
||||
VirtualFile javaFxSources = findSources(jdkHome, "javafx-src");
|
||||
if (javaFxSources != null) {
|
||||
sdkModificator.addRoot(javaFxSources, OrderRootType.SOURCES);
|
||||
}
|
||||
|
||||
if (docs != null) {
|
||||
sdkModificator.addRoot(docs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
else if (SystemInfo.isMac) {
|
||||
VirtualFile commonDocs = findDocs(jdkHome, "docs");
|
||||
if (commonDocs == null) {
|
||||
commonDocs = findInJar(new File(jdkHome, "docs.jar"), "doc/api");
|
||||
if (commonDocs == null) {
|
||||
commonDocs = findInJar(new File(jdkHome, "docs.jar"), "docs/api");
|
||||
}
|
||||
}
|
||||
if (commonDocs != null) {
|
||||
sdkModificator.addRoot(commonDocs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
|
||||
VirtualFile appleDocs = findDocs(jdkHome, "appledocs");
|
||||
if (appleDocs == null) {
|
||||
appleDocs = findInJar(new File(jdkHome, "appledocs.jar"), "appledoc/api");
|
||||
}
|
||||
if (appleDocs != null) {
|
||||
sdkModificator.addRoot(appleDocs, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
|
||||
if (commonDocs == null && appleDocs == null && sources == null) {
|
||||
String url = getDefaultDocumentationUrl(sdk);
|
||||
if (url != null) {
|
||||
sdkModificator.addRoot(VirtualFileManager.getInstance().findFileByUrl(url), JavadocOrderRootType.getInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (getVersion(sdk) == JavaSdkVersion.JDK_1_7) {
|
||||
VirtualFile url = VirtualFileManager.getInstance().findFileByUrl("http://docs.oracle.com/javafx/2/api/");
|
||||
sdkModificator.addRoot(url, JavadocOrderRootType.getInstance());
|
||||
}
|
||||
|
||||
addSources(jdkHome, sdkModificator);
|
||||
addDocs(jdkHome, sdkModificator, sdk);
|
||||
attachJdkAnnotations(sdkModificator);
|
||||
|
||||
sdkModificator.commitChanges();
|
||||
@@ -518,7 +474,7 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
File jdkHomeFile = new File(home);
|
||||
addClasses(jdkHomeFile, sdkModificator, isJre);
|
||||
addSources(jdkHomeFile, sdkModificator);
|
||||
addDocs(jdkHomeFile, sdkModificator);
|
||||
addDocs(jdkHomeFile, sdkModificator, null);
|
||||
sdkModificator.commitChanges();
|
||||
|
||||
return jdk;
|
||||
@@ -529,20 +485,33 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
public Sdk createMockJdk(@NotNull String jdkName, @NotNull String home, boolean isJre) {
|
||||
String homePath = home.replace(File.separatorChar, '/');
|
||||
File jdkHomeFile = new File(homePath);
|
||||
List<VirtualFile> classes = findClasses(jdkHomeFile, isJre);
|
||||
VirtualFile sources = findSources(jdkHomeFile);
|
||||
VirtualFile docs = findDocs(jdkHomeFile, "docs/api");
|
||||
|
||||
ProjectRootContainerImpl rootContainer = new ProjectRootContainerImpl(true);
|
||||
SdkModificator sdkModificator = new SdkModificator() {
|
||||
@Override public String getName() { throw new UnsupportedOperationException(); }
|
||||
@Override public void setName(String name) { throw new UnsupportedOperationException(); }
|
||||
@Override public String getHomePath() { throw new UnsupportedOperationException(); }
|
||||
@Override public void setHomePath(String path) { throw new UnsupportedOperationException(); }
|
||||
@Override public String getVersionString() { throw new UnsupportedOperationException(); }
|
||||
@Override public void setVersionString(String versionString) { throw new UnsupportedOperationException(); }
|
||||
@Override public SdkAdditionalData getSdkAdditionalData() { throw new UnsupportedOperationException(); }
|
||||
@Override public void setSdkAdditionalData(SdkAdditionalData data) { throw new UnsupportedOperationException(); }
|
||||
@Override public VirtualFile[] getRoots(OrderRootType rootType) { throw new UnsupportedOperationException(); }
|
||||
@Override public void removeRoot(VirtualFile root, OrderRootType rootType) { throw new UnsupportedOperationException(); }
|
||||
@Override public void removeRoots(OrderRootType rootType) { throw new UnsupportedOperationException(); }
|
||||
@Override public void removeAllRoots() { throw new UnsupportedOperationException(); }
|
||||
@Override public void commitChanges() { throw new UnsupportedOperationException(); }
|
||||
@Override public boolean isWritable() { throw new UnsupportedOperationException(); }
|
||||
|
||||
@Override
|
||||
public void addRoot(VirtualFile root, OrderRootType rootType) {
|
||||
rootContainer.addRoot(root, rootType);
|
||||
}
|
||||
};
|
||||
|
||||
rootContainer.startChange();
|
||||
for (VirtualFile aClass : classes) {
|
||||
rootContainer.addRoot(aClass, OrderRootType.CLASSES);
|
||||
}
|
||||
if (sources != null) {
|
||||
rootContainer.addRoot(sources, OrderRootType.SOURCES);
|
||||
}
|
||||
if (docs != null) {
|
||||
rootContainer.addRoot(docs, OrderRootType.DOCUMENTATION);
|
||||
}
|
||||
addClasses(jdkHomeFile, sdkModificator, isJre);
|
||||
addSources(jdkHomeFile, sdkModificator);
|
||||
rootContainer.finishChange();
|
||||
|
||||
ProjectJdkImpl jdk = new ProjectJdkImpl(jdkName, this, homePath, jdkName) {
|
||||
@@ -625,28 +594,25 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRootSetChangedListener(@NotNull RootSetChangedListener listener) {
|
||||
}
|
||||
public void addRootSetChangedListener(@NotNull RootSetChangedListener listener) { }
|
||||
|
||||
@Override
|
||||
public void addRootSetChangedListener(@NotNull RootSetChangedListener listener, @NotNull Disposable parentDisposable) {
|
||||
}
|
||||
public void addRootSetChangedListener(@NotNull RootSetChangedListener listener, @NotNull Disposable parentDisposable) { }
|
||||
|
||||
@Override
|
||||
public void removeRootSetChangedListener(@NotNull RootSetChangedListener listener) {
|
||||
}
|
||||
public void removeRootSetChangedListener(@NotNull RootSetChangedListener listener) { }
|
||||
};
|
||||
}
|
||||
|
||||
private void throwReadOnly() {
|
||||
throw new IncorrectOperationException("Can't modify, MockJDK is read-only, consider calling .clone() first");
|
||||
}
|
||||
};
|
||||
|
||||
ProjectJdkImpl.copyRoots(rootContainer, jdk);
|
||||
return jdk;
|
||||
}
|
||||
|
||||
private static void throwReadOnly() {
|
||||
throw new IncorrectOperationException("Can't modify, MockJDK is read-only, consider calling .clone() first");
|
||||
}
|
||||
|
||||
private static void addClasses(File file, SdkModificator sdkModificator, boolean isJre) {
|
||||
for (VirtualFile virtualFile : findClasses(file, isJre)) {
|
||||
sdkModificator.addRoot(virtualFile, OrderRootType.CLASSES);
|
||||
@@ -658,8 +624,7 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
List<VirtualFile> result = ContainerUtil.newArrayList();
|
||||
VirtualFileManager fileManager = VirtualFileManager.getInstance();
|
||||
|
||||
VirtualFile jrt = fileManager.findFileByUrl(
|
||||
VirtualFileManager.constructUrl(JrtFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(file.getPath()) + JrtFileSystem.SEPARATOR));
|
||||
VirtualFile jrt = fileManager.findFileByUrl(JrtFileSystem.PROTOCOL_PREFIX + getPath(file) + JrtFileSystem.SEPARATOR);
|
||||
if (jrt != null) {
|
||||
ContainerUtil.addAll(result, jrt.getChildren());
|
||||
}
|
||||
@@ -674,61 +639,91 @@ public class JavaSdkImpl extends JavaSdk {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void addSources(@NotNull File file, @NotNull SdkModificator sdkModificator) {
|
||||
VirtualFile vFile = findSources(file);
|
||||
if (vFile != null) {
|
||||
sdkModificator.addRoot(vFile, OrderRootType.SOURCES);
|
||||
private static void addSources(@NotNull File jdkHome, @NotNull SdkModificator sdkModificator) {
|
||||
VirtualFile jdkSrc = findSources(jdkHome, "src");
|
||||
if (jdkSrc != null) {
|
||||
sdkModificator.addRoot(jdkSrc, OrderRootType.SOURCES);
|
||||
}
|
||||
|
||||
VirtualFile fxSrc = findSources(jdkHome, "javafx-src");
|
||||
if (fxSrc != null) {
|
||||
sdkModificator.addRoot(fxSrc, OrderRootType.SOURCES);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile findSources(File file) {
|
||||
return findSources(file, "src");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile findSources(File file, final String srcName) {
|
||||
File jarFile = new File(file, srcName + ".jar");
|
||||
if (!jarFile.exists()) {
|
||||
jarFile = new File(file, srcName + ".zip");
|
||||
}
|
||||
|
||||
if (jarFile.exists()) {
|
||||
VirtualFile vFile = findInJar(jarFile, "src");
|
||||
if (vFile != null) return vFile;
|
||||
// try 1.4 format
|
||||
vFile = findInJar(jarFile, "");
|
||||
private static VirtualFile findSources(File jdkHome, String srcName) {
|
||||
File srcArc = new File(jdkHome, srcName + ".jar");
|
||||
if (!srcArc.exists()) srcArc = new File(jdkHome, srcName + ".zip");
|
||||
if (srcArc.exists()) {
|
||||
VirtualFile vFile = findInJar(srcArc, "src");
|
||||
if (vFile == null) vFile = findInJar(srcArc, "");
|
||||
return vFile;
|
||||
}
|
||||
else {
|
||||
File srcDir = new File(file, "src");
|
||||
if (!srcDir.exists() || !srcDir.isDirectory()) return null;
|
||||
String path = srcDir.getAbsolutePath().replace(File.separatorChar, '/');
|
||||
return LocalFileSystem.getInstance().findFileByPath(path);
|
||||
|
||||
File srcDir = new File(jdkHome, "src");
|
||||
if (srcDir.isDirectory()) {
|
||||
return LocalFileSystem.getInstance().findFileByPath(getPath(srcDir));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void addDocs(File file, SdkModificator rootContainer) {
|
||||
VirtualFile vFile = findDocs(file, "docs/api");
|
||||
if (vFile != null) {
|
||||
rootContainer.addRoot(vFile, JavadocOrderRootType.getInstance());
|
||||
private void addDocs(File jdkHome, SdkModificator sdkModificator, @Nullable Sdk sdk) {
|
||||
OrderRootType docRootType = JavadocOrderRootType.getInstance();
|
||||
|
||||
VirtualFile apiDocs = findDocs(jdkHome, "docs/api");
|
||||
if (apiDocs != null) {
|
||||
sdkModificator.addRoot(apiDocs, docRootType);
|
||||
}
|
||||
else if (SystemInfo.isMac) {
|
||||
VirtualFile commonDocs = findDocs(jdkHome, "docs");
|
||||
if (commonDocs == null) commonDocs = findInJar(new File(jdkHome, "docs.jar"), "doc/api");
|
||||
if (commonDocs == null) commonDocs = findInJar(new File(jdkHome, "docs.jar"), "docs/api");
|
||||
if (commonDocs != null) {
|
||||
sdkModificator.addRoot(commonDocs, docRootType);
|
||||
}
|
||||
|
||||
VirtualFile appleDocs = findDocs(jdkHome, "appledocs");
|
||||
if (appleDocs == null) appleDocs = findInJar(new File(jdkHome, "appledocs.jar"), "appledoc/api");
|
||||
if (appleDocs != null) {
|
||||
sdkModificator.addRoot(appleDocs, docRootType);
|
||||
}
|
||||
}
|
||||
|
||||
if (sdk != null && sdkModificator.getRoots(docRootType).length == 0 && sdkModificator.getRoots(OrderRootType.SOURCES).length == 0) {
|
||||
// registers external docs when both sources and local docs are missing
|
||||
String docUrl = getDefaultDocumentationUrl(sdk);
|
||||
if (docUrl != null) {
|
||||
VirtualFile onlineDoc = VirtualFileManager.getInstance().findFileByUrl(docUrl);
|
||||
if (onlineDoc != null) {
|
||||
sdkModificator.addRoot(onlineDoc, docRootType);
|
||||
}
|
||||
}
|
||||
|
||||
if (getVersion(sdk) == JavaSdkVersion.JDK_1_7) {
|
||||
VirtualFile fxDocUrl = VirtualFileManager.getInstance().findFileByUrl("http://docs.oracle.com/javafx/2/api/");
|
||||
if (fxDocUrl != null) {
|
||||
sdkModificator.addRoot(fxDocUrl, docRootType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile findDocs(@NotNull File jdkHome, @NotNull String relativePath) {
|
||||
File docDir = new File(jdkHome.getAbsolutePath(), relativePath);
|
||||
return docDir.isDirectory() ? LocalFileSystem.getInstance().findFileByPath(getPath(docDir)) : null;
|
||||
}
|
||||
|
||||
private static VirtualFile findInJar(File jarFile, String relativePath) {
|
||||
if (!jarFile.exists()) return null;
|
||||
String url = JarFileSystem.PROTOCOL_PREFIX +
|
||||
jarFile.getAbsolutePath().replace(File.separatorChar, '/') + JarFileSystem.JAR_SEPARATOR + relativePath;
|
||||
String url = JarFileSystem.PROTOCOL_PREFIX + getPath(jarFile) + JarFileSystem.JAR_SEPARATOR + relativePath;
|
||||
return VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile findDocs(@NotNull File file, @NotNull String relativePath) {
|
||||
file = new File(file.getAbsolutePath() + File.separator + relativePath.replace('/', File.separatorChar));
|
||||
if (!file.exists() || !file.isDirectory()) return null;
|
||||
String path = file.getAbsolutePath().replace(File.separatorChar, '/');
|
||||
return LocalFileSystem.getInstance().findFileByPath(path);
|
||||
private static String getPath(File jarFile) {
|
||||
return jarFile.getAbsolutePath().replace(File.separatorChar, '/');
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.formatter.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.formatting.Wrap;
|
||||
import com.intellij.formatting.Alignment;
|
||||
import com.intellij.formatting.Indent;
|
||||
import com.intellij.formatting.Block;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MethodCallExpressionBlock extends AbstractJavaBlock{
|
||||
public MethodCallExpressionBlock(ASTNode node,
|
||||
Wrap wrap,
|
||||
Alignment alignment,
|
||||
Indent indent,
|
||||
CodeStyleSettings settings,
|
||||
JavaCodeStyleSettings javaSettings)
|
||||
{
|
||||
super(node, wrap, alignment, indent, settings, javaSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Block> buildChildren() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -113,24 +113,18 @@ public class JavaCodeBlockModificationListener implements PsiTreeChangePreproces
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInsideCodeBlock(PsiElement element) {
|
||||
if (element instanceof PsiFileSystemItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInsideCodeBlock(final PsiElement element) {
|
||||
if (element == null || element.getParent() == null) return true;
|
||||
|
||||
PsiElement parent = element;
|
||||
while (true) {
|
||||
if (parent instanceof PsiFile || parent instanceof PsiDirectory || parent == null) {
|
||||
return false;
|
||||
}
|
||||
if (parent instanceof PsiClass) return false; // anonymous or local class
|
||||
if (parent instanceof PsiModifiableCodeBlock) {
|
||||
if (!((PsiModifiableCodeBlock)parent).shouldChangeModificationCount(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (parent == null || parent instanceof PsiFileSystemItem) return false;
|
||||
if (parent instanceof PsiClass) return false; // anonymous or local class
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -100,15 +100,23 @@ public class JavaChangeSignatureDetector implements LanguageChangeSignatureDetec
|
||||
buf.append(", ");
|
||||
}
|
||||
|
||||
String oldParamName = initialChangeInfo.getOldParameterNames()[i];
|
||||
String oldParamType = initialChangeInfo.getOldParameterTypes()[i];
|
||||
if (toRemove[i]) {
|
||||
String deletedParam = initialChangeInfo.getOldParameterTypes()[i] + " " + initialChangeInfo.getOldParameterNames()[i];
|
||||
String deletedParam = oldParamType + " " + oldParamName;
|
||||
deleteRanges.add(new TextRange(buf.length(), buf.length() + deletedParam.length()));
|
||||
buf.append(deletedParam);
|
||||
}
|
||||
else {
|
||||
for (JavaParameterInfo parameter : newParameters) {
|
||||
if (parameter.getOldIndex() == i) {
|
||||
buf.append(parameter.getTypeText()).append(" ").append(parameter.getName());
|
||||
buf.append(parameter.getTypeText());
|
||||
buf.append(" ");
|
||||
if (!oldParamName.equals(parameter.getName())) {
|
||||
deleteRanges.add(new TextRange(buf.length(), buf.length() + oldParamName.length()));
|
||||
buf.append(oldParamName);
|
||||
}
|
||||
buf.append(parameter.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -827,11 +827,12 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
parameter.getNameIdentifier().replace(newIdentifier);
|
||||
}
|
||||
|
||||
final PsiTypeElement typeElement = parameter.getTypeElement();
|
||||
PsiTypeElement typeElement = parameter.getTypeElement();
|
||||
if (typeElement != null) {
|
||||
parameter.normalizeDeclaration();
|
||||
typeElement = parameter.getTypeElement();
|
||||
String oldType = oldParameterTypes[index];
|
||||
if (!oldType.equals(info.getTypeText())) {
|
||||
parameter.normalizeDeclaration();
|
||||
PsiType newType =
|
||||
substitutor.substitute(info.createType(changeInfo.getMethod().getParameterList(), changeInfo.getMethod().getManager()));
|
||||
typeElement.replace(factory.createTypeElement(newType));
|
||||
|
||||
@@ -365,7 +365,7 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
|
||||
if (relativePath != null && !relativePath.isEmpty()) {
|
||||
finalTarget = WriteAction.compute(() -> buildRelativeDir(targetDirectory, relativePath).findOrCreateTargetDirectory());
|
||||
}
|
||||
final PsiFile fileCopy = CopyFilesOrDirectoriesHandler.copyToDirectory(file, getNewFileName(file, copyClassName), finalTarget, choice);
|
||||
final PsiFile fileCopy = CopyFilesOrDirectoriesHandler.copyToDirectory(file, getNewFileName(file, copyClassName), finalTarget, choice, null);
|
||||
if (fileCopy != null) {
|
||||
createdFiles.add(fileCopy);
|
||||
}
|
||||
|
||||
+10
-2
@@ -41,7 +41,10 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
@@ -67,7 +70,9 @@ import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.refactoring.util.*;
|
||||
import com.intellij.refactoring.util.classMembers.ElementNeedsThis;
|
||||
import com.intellij.refactoring.util.duplicates.*;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -1462,6 +1467,9 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
myTargetClass = myCodeFragmentMember instanceof PsiMember
|
||||
? ((PsiMember)myCodeFragmentMember).getContainingClass()
|
||||
: PsiTreeUtil.getParentOfType(myCodeFragmentMember, PsiClass.class);
|
||||
if (myTargetClass == null) {
|
||||
LOG.error(myElements[0].getContainingFile());
|
||||
}
|
||||
if (!shouldAcceptCurrentTarget(extractPass, myTargetClass)) {
|
||||
|
||||
final LinkedHashMap<PsiClass, List<PsiVariable>> classes = new LinkedHashMap<>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,6 +88,9 @@ public class ExtractClassHandler implements ElementsHandler {
|
||||
if (classIsTrivial(containingClass)) {
|
||||
return RefactorJBundle.message("the.selected.class.has.no.members.to.extract");
|
||||
}
|
||||
if (!containingClass.getManager().isInProject(containingClass)) {
|
||||
return "The selected class should belong to project sources";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.refactoring.extractclass;
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -26,7 +25,6 @@ import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.psi.MethodInheritanceUtils;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -438,6 +436,12 @@ class ExtractedClassBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (referent instanceof PsiClass) {
|
||||
String qualifiedName = ((PsiClass)referent).getQualifiedName();
|
||||
if (qualifiedName != null) {
|
||||
out.append(qualifiedName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
+5
@@ -19,6 +19,7 @@ import com.intellij.ide.util.DirectoryChooserUtil;
|
||||
import com.intellij.lang.java.JavaFindUsagesProvider;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.JavaProjectRootsUtil;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
@@ -236,7 +237,11 @@ public class MoveClassesOrPackagesUtil {
|
||||
if (!Comparing.equal(moveDestination.getVirtualFile(), containingDirectory != null ? containingDirectory.getVirtualFile() : null)) {
|
||||
LOG.assertTrue(file.getVirtualFile() != null, aClass);
|
||||
|
||||
Project project = file.getProject();
|
||||
MoveFilesOrDirectoriesUtil.doMoveFile(file, moveDestination);
|
||||
|
||||
DumbService.getInstance(project).completeJustSubmittedTasks();
|
||||
|
||||
file = moveDestination.findFile(file.getName());
|
||||
|
||||
if (newPackage != null && file instanceof PsiClassOwner && !FileTypeUtils.isInServerPageFile(file) && !PsiUtil.isModuleFile(file)) {
|
||||
|
||||
+33
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,8 @@
|
||||
package com.intellij.refactoring.move.moveMembers;
|
||||
|
||||
import com.intellij.codeInsight.ChangeContextUtil;
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.ExpectedTypesProvider;
|
||||
import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
@@ -32,7 +34,10 @@ import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
@@ -77,10 +82,10 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
|
||||
|
||||
@Override
|
||||
public void checkConflictsOnUsage(@NotNull MoveMembersProcessor.MoveMembersUsageInfo usageInfo,
|
||||
@Nullable String newVisibility,
|
||||
@Nullable PsiModifierList modifierListCopy,
|
||||
@NotNull PsiClass targetClass,
|
||||
@NotNull Set<PsiMember> membersToMove,
|
||||
@NotNull MoveMembersOptions moveMembersOptions,
|
||||
@NotNull MultiMap<PsiElement, String> conflicts) {
|
||||
final PsiElement element = usageInfo.getElement();
|
||||
if (element == null) return;
|
||||
@@ -94,6 +99,7 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
|
||||
}
|
||||
|
||||
if (!JavaResolveUtil.isAccessible(member, targetClass, modifierListCopy, element, accessObjectClass, null)) {
|
||||
String newVisibility = moveMembersOptions.getExplicitMemberVisibility();
|
||||
String visibility = newVisibility != null ? newVisibility : VisibilityUtil.getVisibilityStringToDisplay(member);
|
||||
String message = RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2",
|
||||
RefactoringUIUtil.getDescription(member, false),
|
||||
@@ -120,12 +126,27 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
|
||||
conflicts.putValue(usageInfo.member, "final variable initializer won't be available after move.");
|
||||
}
|
||||
|
||||
if (toBeConvertedToEnum(moveMembersOptions, member, targetClass) && !isEnumAcceptable(element, targetClass)) {
|
||||
conflicts.putValue(element, "Enum type won't be applicable in the current context");
|
||||
}
|
||||
|
||||
final PsiReference reference = usageInfo.getReference();
|
||||
if (reference != null) {
|
||||
RefactoringConflictsUtil.checkAccessibilityConflicts(reference, member, modifierListCopy, targetClass, membersToMove, conflicts);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEnumAcceptable(PsiElement element, PsiClass targetClass) {
|
||||
if (element instanceof PsiExpression) {
|
||||
ExpectedTypeInfo[] types = ExpectedTypesProvider.getExpectedTypes((PsiExpression)element, false);
|
||||
if (types.length == 1) {
|
||||
PsiType type = types[0].getType();
|
||||
return type.isAssignableFrom(JavaPsiFacade.getElementFactory(element.getProject()).createType(targetClass));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConflictsOnMember(@NotNull PsiMember member,
|
||||
@Nullable String newVisibility,
|
||||
@@ -216,9 +237,7 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
|
||||
ChangeContextUtil.encodeContextInfo(member, true);
|
||||
|
||||
final PsiMember memberCopy;
|
||||
if (options.makeEnumConstant() &&
|
||||
member instanceof PsiVariable &&
|
||||
EnumConstantsUtil.isSuitableForEnumConstant(((PsiVariable)member).getType(), targetClass)) {
|
||||
if (toBeConvertedToEnum(options, member, targetClass)) {
|
||||
memberCopy = EnumConstantsUtil.createEnumConstant(targetClass, member.getName(), ((PsiVariable)member).getInitializer());
|
||||
}
|
||||
else {
|
||||
@@ -237,6 +256,14 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
|
||||
return anchor != null ? (PsiMember)targetClass.addAfter(memberCopy, anchor) : (PsiMember)targetClass.add(memberCopy);
|
||||
}
|
||||
|
||||
private static boolean toBeConvertedToEnum(@NotNull MoveMembersOptions options,
|
||||
@NotNull PsiMember member,
|
||||
@NotNull PsiClass targetClass) {
|
||||
return options.makeEnumConstant() &&
|
||||
member instanceof PsiVariable &&
|
||||
EnumConstantsUtil.isSuitableForEnumConstant(((PsiVariable)member).getType(), targetClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeContextInfo(@NotNull PsiElement scope) {
|
||||
ChangeContextUtil.decodeContextInfo(scope, null, null);
|
||||
|
||||
+16
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,12 +35,21 @@ public interface MoveMemberHandler {
|
||||
@NotNull Set<PsiMember> membersToMove,
|
||||
@NotNull PsiClass targetClass);
|
||||
|
||||
void checkConflictsOnUsage(@NotNull MoveMembersProcessor.MoveMembersUsageInfo usageInfo,
|
||||
@Nullable String newVisibility,
|
||||
@Nullable PsiModifierList modifierListCopy,
|
||||
@NotNull PsiClass targetClass,
|
||||
@NotNull Set<PsiMember> membersToMove,
|
||||
@NotNull MultiMap<PsiElement, String> conflicts);
|
||||
default void checkConflictsOnUsage(@NotNull MoveMembersProcessor.MoveMembersUsageInfo usageInfo,
|
||||
@Nullable PsiModifierList modifierListCopy,
|
||||
@NotNull PsiClass targetClass,
|
||||
@NotNull Set<PsiMember> membersToMove,
|
||||
MoveMembersOptions moveMembersOptions,
|
||||
@NotNull MultiMap<PsiElement, String> conflicts) {
|
||||
checkConflictsOnUsage(usageInfo, moveMembersOptions.getExplicitMemberVisibility(), modifierListCopy, targetClass, membersToMove, conflicts);
|
||||
}
|
||||
|
||||
default void checkConflictsOnUsage(@NotNull MoveMembersProcessor.MoveMembersUsageInfo usageInfo,
|
||||
@Nullable String newVisibility,
|
||||
@Nullable PsiModifierList modifierListCopy,
|
||||
@NotNull PsiClass targetClass,
|
||||
@NotNull Set<PsiMember> membersToMove,
|
||||
@NotNull MultiMap<PsiElement, String> conflicts) {}
|
||||
|
||||
void checkConflictsOnMember(@NotNull PsiMember member,
|
||||
@Nullable String newVisibility,
|
||||
|
||||
+14
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,8 @@
|
||||
package com.intellij.refactoring.move.moveMembers;
|
||||
|
||||
import com.intellij.psi.PsiMember;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -26,8 +28,19 @@ public interface MoveMembersOptions {
|
||||
|
||||
String getTargetClassName();
|
||||
|
||||
@PsiModifier.ModifierConstant
|
||||
@Nullable
|
||||
String getMemberVisibility();
|
||||
|
||||
@PsiModifier.ModifierConstant
|
||||
@Nullable
|
||||
default String getExplicitMemberVisibility() {
|
||||
String visibility = getMemberVisibility();
|
||||
if (VisibilityUtil.ESCALATE_VISIBILITY.equals(visibility)) {
|
||||
return PsiModifier.PUBLIC;
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
|
||||
boolean makeEnumConstant();
|
||||
}
|
||||
|
||||
+5
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -282,11 +282,7 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
|
||||
final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
|
||||
final UsageInfo[] usages = refUsages.get();
|
||||
|
||||
String newVisibility = myNewVisibility;
|
||||
if (VisibilityUtil.ESCALATE_VISIBILITY.equals(newVisibility)) { // still need to check for access object
|
||||
newVisibility = PsiModifier.PUBLIC;
|
||||
}
|
||||
|
||||
String newVisibility = myOptions.getExplicitMemberVisibility(); // still need to check for access object
|
||||
final Map<PsiMember, PsiModifierList> modifierListCopies = new HashMap<>();
|
||||
for (PsiMember member : myMembersToMove) {
|
||||
PsiModifierList modifierListCopy = member.getModifierList();
|
||||
@@ -304,7 +300,7 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
|
||||
modifierListCopies.put(member, modifierListCopy);
|
||||
}
|
||||
|
||||
analyzeConflictsOnUsages(usages, myMembersToMove, newVisibility, myTargetClass, modifierListCopies, conflicts);
|
||||
analyzeConflictsOnUsages(usages, myMembersToMove, myTargetClass, modifierListCopies, myOptions, conflicts);
|
||||
analyzeConflictsOnMembers(myMembersToMove, newVisibility, myTargetClass, modifierListCopies, conflicts);
|
||||
|
||||
RefactoringConflictsUtil.analyzeModuleConflicts(myProject, myMembersToMove, usages, myTargetClass, conflicts);
|
||||
@@ -314,9 +310,9 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
private static void analyzeConflictsOnUsages(UsageInfo[] usages,
|
||||
Set<PsiMember> membersToMove,
|
||||
String newVisibility,
|
||||
@NotNull PsiClass targetClass,
|
||||
Map<PsiMember, PsiModifierList> modifierListCopies,
|
||||
MoveMembersOptions options,
|
||||
MultiMap<PsiElement, String> conflicts) {
|
||||
for (UsageInfo usage : usages) {
|
||||
if (!(usage instanceof MoveMembersUsageInfo)) continue;
|
||||
@@ -324,7 +320,7 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
|
||||
final PsiMember member = usageInfo.member;
|
||||
final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage());
|
||||
if (handler != null) {
|
||||
handler.checkConflictsOnUsage(usageInfo, newVisibility, modifierListCopies.get(member), targetClass, membersToMove, conflicts);
|
||||
handler.checkConflictsOnUsage(usageInfo, modifierListCopies.get(member), targetClass, membersToMove, options, conflicts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-8
@@ -49,9 +49,7 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -255,12 +253,22 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
|
||||
@Override
|
||||
public Collection<String> findConflicts(PsiElement element, PsiElement[] elements, UsageInfo[] usages) {
|
||||
String methodRefFound = null;
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && (element instanceof PsiMethod || element instanceof PsiParameter)) {
|
||||
for (UsageInfo usage : usages) {
|
||||
final PsiElement refElement = usage.getElement();
|
||||
if (refElement instanceof PsiMethodReferenceExpression) {
|
||||
methodRefFound = RefactoringBundle.message("expand.method.reference.warning");
|
||||
break;
|
||||
if (element instanceof PsiMethod || element instanceof PsiParameter) {
|
||||
PsiMethod method;
|
||||
if (element instanceof PsiMethod) {
|
||||
method = (PsiMethod)element;
|
||||
}
|
||||
else {
|
||||
PsiElement declarationScope = ((PsiParameter)element).getDeclarationScope();
|
||||
method = declarationScope instanceof PsiMethod ? (PsiMethod)declarationScope : null;
|
||||
}
|
||||
if (method != null) {
|
||||
for (UsageInfo usage : usages) {
|
||||
final PsiElement refElement = usage.getElement();
|
||||
if (refElement instanceof PsiMethodReferenceExpression && method.equals(((PsiMethodReferenceExpression)refElement).resolve())) {
|
||||
methodRefFound = RefactoringBundle.message("expand.method.reference.warning");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.JavaProjectRootsUtil;
|
||||
@@ -400,14 +399,13 @@ public class CreateTestDialog extends DialogWrapper {
|
||||
|
||||
myFixLibraryButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND,
|
||||
() -> ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
if (mySelectedFramework instanceof JavaTestFramework) {
|
||||
((JavaTestFramework)mySelectedFramework).setupLibrary(myTargetModule);
|
||||
} else {
|
||||
OrderEntryFix.addJarToRoots(mySelectedFramework.getLibraryPath(), myTargetModule, null);
|
||||
}
|
||||
}));
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
if (mySelectedFramework instanceof JavaTestFramework) {
|
||||
((JavaTestFramework)mySelectedFramework).setupLibrary(myTargetModule);
|
||||
} else {
|
||||
OrderEntryFix.addJarToRoots(mySelectedFramework.getLibraryPath(), myTargetModule, null);
|
||||
}
|
||||
});
|
||||
myFixLibraryPanel.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -217,9 +217,7 @@ public class AnnotationUtil {
|
||||
//noinspection unchecked
|
||||
list.addAll((Collection<? extends T>)result);
|
||||
|
||||
List<Object> dependencies = ContainerUtil.<Object>newArrayList(result);
|
||||
dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
|
||||
return Result.create(list, dependencies);
|
||||
return Result.create(list, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
public abstract class JavaCodeInsightSettingsFacade {
|
||||
/** todo remove in IDEA 16 */
|
||||
@Deprecated
|
||||
public abstract boolean isShowStaticAfterInstance();
|
||||
|
||||
public static JavaCodeInsightSettingsFacade getInstance(Project project) {
|
||||
return ServiceManager.getService(project, JavaCodeInsightSettingsFacade.class);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -140,7 +140,12 @@ public class TypesDistinctProver {
|
||||
if (level < 2) return false;
|
||||
}
|
||||
|
||||
if (boundClass1 == null || boundClass2 == null) {
|
||||
return type1 != null && type2 != null && !type1.equals(type2);
|
||||
}
|
||||
|
||||
return type2 != null && type1 != null && !type1.equals(type2) &&
|
||||
!(level == 0 && boundClass1.isInterface() && boundClass2.isInterface()) &&
|
||||
(!InheritanceUtil.isInheritorOrSelf(boundClass1, boundClass2, true) ||
|
||||
!InheritanceUtil.isInheritorOrSelf(boundClass2, boundClass1, true));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PairFunction;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -169,7 +168,7 @@ public class PsiImplUtil {
|
||||
for (int i = 0; i < typeParameters.length; i++) {
|
||||
if (typeParameter.equals(typeParameters[i])) return i;
|
||||
}
|
||||
LOG.assertTrue(false);
|
||||
LOG.error(typeParameter + " in " + typeParameterList);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -617,20 +616,6 @@ public class PsiImplUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated use {@link #collectTypeUseAnnotations(PsiModifierList, List)} (to be removed in IDEA 16) */
|
||||
public static List<PsiAnnotation> getTypeUseAnnotations(@NotNull PsiModifierList modifierList) {
|
||||
SmartList<PsiAnnotation> result = null;
|
||||
|
||||
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
|
||||
if (isTypeAnnotation(annotation)) {
|
||||
if (result == null) result = new SmartList<PsiAnnotation>();
|
||||
result.add(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final Key<Boolean> TYPE_ANNO_MARK = Key.create("type.annotation.mark");
|
||||
|
||||
public static void markTypeAnnotations(@NotNull PsiTypeElement typeElement) {
|
||||
|
||||
+8
-5
@@ -1614,7 +1614,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
if (methodContainingClass != null) {
|
||||
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, psiSubstitutor);
|
||||
psiSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass +
|
||||
"; super: " + methodContainingClass +
|
||||
"; reference: " + reference.getText() +
|
||||
@@ -1631,7 +1631,7 @@ public class InferenceSession {
|
||||
final PsiType pType = signature.getParameterTypes()[0];
|
||||
|
||||
// 15.13.1 If the ReferenceType is a raw type, and there exists a parameterization of this type, T, that is a supertype of P1,
|
||||
// the type to search is the result of capture conversion (5.1.10) applied to T;
|
||||
// the type to search is the result of capture conversion (5.1.10) applied to T;
|
||||
// otherwise, the type to search is the same as the type of the first search. Again, the type arguments, if any, are given by the method reference.
|
||||
if (PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor)) {
|
||||
PsiType normalizedPType = PsiUtil.captureToplevelWildcards(pType, myContext);
|
||||
@@ -1646,7 +1646,7 @@ public class InferenceSession {
|
||||
mySiteSubstitutor = mySiteSubstitutor.putAll(receiverSubstitutor);
|
||||
|
||||
if (methodContainingClass != null) {
|
||||
final PsiSubstitutor superSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, receiverSubstitutor);
|
||||
final PsiSubstitutor superSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), receiverSubstitutor);
|
||||
LOG.assertTrue(superSubstitutor != null, "mContainingClass: " + methodContainingClass.getName() + "; containingClass: " + containingClass.getName());
|
||||
mySiteSubstitutor = mySiteSubstitutor.putAll(superSubstitutor);
|
||||
}
|
||||
@@ -1660,8 +1660,11 @@ public class InferenceSession {
|
||||
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(qType), pType));
|
||||
|
||||
if (methodContainingClass != null) {
|
||||
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass + "; super: " + methodContainingClass);
|
||||
psiSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass +
|
||||
"; super: " + methodContainingClass +
|
||||
"; reference: " + reference.getText() +
|
||||
"; containingFile: " + reference.getContainingFile().getName());
|
||||
}
|
||||
|
||||
for (int i = 0; i < signature.getParameterTypes().length - 1; i++) {
|
||||
|
||||
+13
-4
@@ -19,6 +19,7 @@ import com.intellij.navigation.ColoredItemPresentation;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
@@ -47,8 +48,12 @@ public class JavaPresentationUtil {
|
||||
|
||||
@Override
|
||||
public TextAttributesKey getTextAttributesKey() {
|
||||
if (psiMethod.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
try {
|
||||
if (psiMethod.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
}
|
||||
}
|
||||
catch (IndexNotReadyException ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -75,8 +80,12 @@ public class JavaPresentationUtil {
|
||||
|
||||
@Override
|
||||
public TextAttributesKey getTextAttributesKey() {
|
||||
if (psiField.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
try {
|
||||
if (psiField.isDeprecated()) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
}
|
||||
}
|
||||
catch (IndexNotReadyException ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+9
-5
@@ -24,6 +24,7 @@ import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -32,6 +33,7 @@ import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -254,11 +256,13 @@ public class PropertyGroup implements Group, ColoredItemPresentation, AccessLeve
|
||||
return isDeprecated(getField()) && isDeprecated(getGetter()) && isDeprecated(getSetter());
|
||||
}
|
||||
|
||||
private static boolean isDeprecated(final PsiElement element) {
|
||||
if (element == null) return false;
|
||||
if (!element.isValid()) return false;
|
||||
if (!(element instanceof PsiDocCommentOwner)) return false;
|
||||
return ((PsiDocCommentOwner)element).isDeprecated();
|
||||
private static boolean isDeprecated(@Nullable final PsiDocCommentOwner element) {
|
||||
try {
|
||||
return element != null && element.isValid() && element.isDeprecated();
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
class Test {
|
||||
|
||||
{
|
||||
Marker<String> cm = forEach(child1(), child2());
|
||||
}
|
||||
|
||||
public static <D> Child1<D> child1() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <S> Child2<S> child2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <F, CM extends Marker<F>> CM forEach(CM contents, CM cm) {
|
||||
return null;
|
||||
}
|
||||
|
||||
interface Marker<A> {}
|
||||
static class Parent<S> {}
|
||||
|
||||
static class Child1<D> extends Parent<ChildAttr1> implements Marker<D> {}
|
||||
interface ChildAttr1 {}
|
||||
|
||||
static class Child2<S> extends Parent<ChildAttr2> implements Marker<S> {}
|
||||
interface ChildAttr2 {}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package p;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PersistentMap<K, V> extends FileReader {
|
||||
public void close() throws IOException {}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package p;
|
||||
import java.io.*;
|
||||
|
||||
class Subst {
|
||||
PersistentMap<Integer, String> messages;
|
||||
|
||||
{
|
||||
register(() -> catchAndWarn(messages::close));
|
||||
}
|
||||
|
||||
static void register(Runnable r) {}
|
||||
|
||||
private static void catchAndWarn(ThrowableRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
catch (IOException e) {}
|
||||
}
|
||||
|
||||
interface ThrowableRunnable {
|
||||
void run() throws IOException;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
void <caret>foo(int a[]) {}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
void foo(int... a) {}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Extracted {
|
||||
public Extracted() {
|
||||
}
|
||||
|
||||
List<Test> foo() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public class Test {
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
List<Test> foo() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,5 @@
|
||||
public class B {
|
||||
{
|
||||
Object o = A.ONE;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
public class B {
|
||||
public static final String ONE = "";
|
||||
public static final String ONE = "";
|
||||
{
|
||||
Object o = ONE;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Subst {
|
||||
void test1() {
|
||||
test2(Subst::bar);
|
||||
}
|
||||
|
||||
private static void bar(Object o) {
|
||||
|
||||
}
|
||||
|
||||
void test2(final Consumer<Object> consu<caret>mer) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Subst {
|
||||
void test1() {
|
||||
test2();
|
||||
}
|
||||
|
||||
private static void bar(Object o) {
|
||||
|
||||
}
|
||||
|
||||
void test2() {}
|
||||
}
|
||||
+22
-14
@@ -34,7 +34,10 @@ import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MostlySingularMultiMap;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.eclipse.util.PathUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -47,8 +50,8 @@ public class ExternalAnnotationsManagerTest extends IdeaTestCase {
|
||||
Sdk jdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
|
||||
Sdk sdk = PsiTestUtil.addJdkAnnotations(jdk);
|
||||
String home = jdk.getHomeDirectory().getParent().getPath();
|
||||
String toolsPath = home + "/lib/tools.jar!/";
|
||||
VfsRootAccess.allowRootAccess(getTestRootDisposable(), home);
|
||||
String toolsPath = home + "/lib/tools.jar!/";
|
||||
VirtualFile toolsJar = JarFileSystem.getInstance().findFileByPath(toolsPath);
|
||||
|
||||
Sdk plusTools = PsiTestUtil.addRootsToJdk(sdk, OrderRootType.CLASSES, toolsJar);
|
||||
@@ -60,22 +63,22 @@ public class ExternalAnnotationsManagerTest extends IdeaTestCase {
|
||||
LocalFileSystem.getInstance() .findFileByPath(FileUtil.toSystemIndependentName(path)))
|
||||
.toArray(VirtualFile[]::new);
|
||||
|
||||
Sdk result = PsiTestUtil.addRootsToJdk(plusTools, OrderRootType.CLASSES, files);
|
||||
return result;
|
||||
return PsiTestUtil.addRootsToJdk(plusTools, OrderRootType.CLASSES, files);
|
||||
}
|
||||
|
||||
public void testBundledAnnotationXmls() {
|
||||
public void testBundledAnnotationXmlSyntax() {
|
||||
String root = PathManagerEx.getCommunityHomePath() + "/java/jdkAnnotations";
|
||||
findAnnotationsXmlAndCheck(root);
|
||||
findAnnotationsXmlAndCheckSyntax(root);
|
||||
}
|
||||
|
||||
private void findAnnotationsXmlAndCheck(String root) {
|
||||
private void findAnnotationsXmlAndCheckSyntax(String root) {
|
||||
VirtualFile jdkAnnoRoot = LocalFileSystem.getInstance().findFileByPath(root);
|
||||
VfsUtilCore.visitChildrenRecursively(jdkAnnoRoot, new VirtualFileVisitor() {
|
||||
@Override
|
||||
public boolean visitFile(@NotNull VirtualFile file) {
|
||||
if (file.getName().equals("annotations.xml")) {
|
||||
check(file);
|
||||
String assumedPackage = PathUtil.getRelative(root, file.getParent().getPath()).replaceAll("/",".");
|
||||
checkSyntax(file, assumedPackage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -95,27 +98,27 @@ public class ExternalAnnotationsManagerTest extends IdeaTestCase {
|
||||
.setProjectSdk(PsiTestUtil.addRootsToJdk(getTestProjectJdk(), OrderRootType.CLASSES, androidJars)));
|
||||
|
||||
String root = PathManagerEx.getCommunityHomePath() + "/android/android/annotations";
|
||||
findAnnotationsXmlAndCheck(root);
|
||||
findAnnotationsXmlAndCheckSyntax(root);
|
||||
}
|
||||
|
||||
private void check(VirtualFile file) {
|
||||
private void checkSyntax(@NotNull VirtualFile file, @NotNull String assumedPackage) {
|
||||
//System.out.println("file = " + file);
|
||||
ExternalAnnotationsManagerImpl manager = (ExternalAnnotationsManagerImpl)ExternalAnnotationsManager.getInstance(getProject());
|
||||
PsiFile psiFile = getPsiManager().findFile(file);
|
||||
MostlySingularMultiMap<String, BaseExternalAnnotationsManager.AnnotationData> map = manager.getDataFromFile(psiFile);
|
||||
for (String externalName : map.keySet()) {
|
||||
checkExternalName(psiFile, externalName);
|
||||
checkExternalName(psiFile, externalName, assumedPackage);
|
||||
|
||||
// 'annotation name="org.jetbrains.annotations.NotNull"' should have FQN
|
||||
for (BaseExternalAnnotationsManager.AnnotationData annotationData : map.get(externalName)) {
|
||||
PsiAnnotation annotation = annotationData.getAnnotation(manager);
|
||||
String nameText = annotation.getNameReferenceElement().getText();
|
||||
assertClassFqn(nameText, psiFile, externalName);
|
||||
assertClassFqn(nameText, psiFile, externalName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PsiClass assertClassFqn(String text, PsiFile psiFile, String externalName) {
|
||||
private PsiClass assertClassFqn(@NotNull String text, @NotNull PsiFile psiFile, @NotNull String externalName, @Nullable("null means can be any") String assumedPackage) {
|
||||
if (!PsiNameHelper.getInstance(getProject()).isQualifiedName(text) || !text.contains(".")) {
|
||||
fail("'" + text + "' doesn't seem like a FQN", psiFile, externalName);
|
||||
}
|
||||
@@ -124,21 +127,26 @@ public class ExternalAnnotationsManagerTest extends IdeaTestCase {
|
||||
if (aClass == null) {
|
||||
fail("'" + text + "' doesn't resolve to a class", psiFile, externalName);
|
||||
}
|
||||
String packageName = ((PsiClassOwner)aClass.getContainingFile()).getPackageName();
|
||||
if (assumedPackage != null && !assumedPackage.equals(packageName)) {
|
||||
fail("Wrong package for class '"+text+"'. Expected: '"+assumedPackage+"' but was: '"+packageName+"'", psiFile, externalName);
|
||||
}
|
||||
return aClass;
|
||||
}
|
||||
|
||||
@Contract("_,_,_-> fail")
|
||||
private static void fail(String error, PsiFile psiFile, String externalName) {
|
||||
int offset = psiFile.getText().indexOf(XmlUtil.escape(externalName));
|
||||
int line = PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile).getLineNumber(offset);
|
||||
fail(error + "\nFile: " + psiFile.getVirtualFile().getPath() + ":" + (line+1) + " (offset: "+offset+")");
|
||||
}
|
||||
|
||||
private void checkExternalName(PsiFile psiFile, String externalName) {
|
||||
private void checkExternalName(@NotNull PsiFile psiFile, @NotNull String externalName, @NotNull String assumedPackage) {
|
||||
// 'item name="java.lang.ClassLoader java.net.URL getResource(java.lang.String) 0"' should have all FQNs
|
||||
String unescaped = StringUtil.unescapeXml(externalName);
|
||||
List<String> words = StringUtil.split(unescaped, " ");
|
||||
String className = words.get(0);
|
||||
PsiClass aClass = assertClassFqn(className, psiFile, externalName);
|
||||
PsiClass aClass = assertClassFqn(className, psiFile, externalName, assumedPackage);
|
||||
if (words.size() == 1) return;
|
||||
|
||||
String rest = unescaped.substring(className.length() + " ".length());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -217,6 +217,16 @@ public class MultipleJdksHighlightingTest extends UsefulTestCase {
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
public void testMethodReferencePointingToDifferentJdk() throws Exception {
|
||||
ModuleRootModificationUtil.addDependency(myJava8Module, myJava3Module);
|
||||
final String testName = getTestName(false);
|
||||
myFixture.copyFileToProject("java3/p/" + testName + ".java");
|
||||
myFixture.copyFileToProject("java8/p/" + testName + ".java");
|
||||
|
||||
myFixture.configureByFiles("java8/p/" + testName + ".java", "java3/p/" + testName + ".java");
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
public void testInheritorsOfJdkClassOnlyInModulesWithThatJdk() {
|
||||
ModuleRootModificationUtil.addDependency(myJava8Module, myJava7Module);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class ModuleCompletionTest : LightJava9ModulesCodeInsightFixtureTestCase() {
|
||||
}
|
||||
|
||||
fun testFileHeader() = complete("<caret>", "module <caret>")
|
||||
fun testModuleName() = variants("module M<caret>")
|
||||
fun testStatements1() = variants("module M { <caret> }", "requires", "exports", "uses", "provides")
|
||||
fun testStatements2() = complete("module M { requires X; ex<caret> }", "module M { requires X; exports <caret> }")
|
||||
fun testModuleRef() = complete("module M { requires M<caret> }", "module M { requires M2;<caret> }")
|
||||
|
||||
+13
-12
@@ -39,6 +39,7 @@ import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspectionBase;
|
||||
import com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection;
|
||||
import com.intellij.diagnostic.PerformanceWatcher;
|
||||
import com.intellij.diagnostic.ThreadDumper;
|
||||
import com.intellij.execution.filters.TextConsoleBuilderFactory;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
@@ -1335,16 +1336,16 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
|
||||
List<HighlightInfo> warns = doHighlighting(HighlightSeverity.WARNING);
|
||||
assertOneElement(warns);
|
||||
List<HighlightInfo.IntentionActionDescriptor> actions = ShowIntentionsPass.getAvailableActions(getEditor(), getFile(), -1);
|
||||
List<HighlightInfo.IntentionActionDescriptor> actions = ShowIntentionsPass.getAvailableFixes(getEditor(), getFile(), -1);
|
||||
final HighlightInfo.IntentionActionDescriptor descriptor = assertOneElement(actions);
|
||||
WriteCommandAction.runWriteCommandAction(getProject(), () -> descriptor.getAction().invoke(getProject(), getEditor(), getFile()));
|
||||
|
||||
highlightErrors();
|
||||
actions = ShowIntentionsPass.getAvailableActions(getEditor(), getFile(), -1);
|
||||
actions = ShowIntentionsPass.getAvailableFixes(getEditor(), getFile(), -1);
|
||||
assertEmpty(actions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testApplyErrorInTheMiddle() throws Throwable {
|
||||
String text = "class <caret>X { ";
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@@ -1372,7 +1373,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
assertEmpty(errors);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testErrorInTheEndOutsideVisibleArea() throws Throwable {
|
||||
String text = "<xml> \n" + StringUtil.repeatSymbol('\n', 1000) + "</xml>\nxxxxx<caret>";
|
||||
configureByText(StdFileTypes.XML, text);
|
||||
@@ -1426,7 +1427,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
assertEquals(4, infos.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testTypingNearEmptyErrorElement() throws Throwable {
|
||||
String text = "class LQF {\n" +
|
||||
" public void main() {\n" +
|
||||
@@ -1445,7 +1446,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
assertEmpty(infos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testLIPGetAllParentsAfterCodeBlockModification() throws Throwable {
|
||||
@Language("JAVA")
|
||||
String text = "class LQF {\n" +
|
||||
@@ -1513,7 +1514,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
assertEquals(new HashSet<>(methodAndParents), new HashSet<>(visitedElements));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testCancelsItSelfOnTypingInAlienProject() throws Throwable {
|
||||
String body = StringUtil.repeat("\"String field = null;\"\n", 1000);
|
||||
configureByText(StdFileTypes.JAVA, "class X{ void f() {" + body + "<caret>\n} }");
|
||||
@@ -1523,7 +1524,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
boolean succ2 = ProjectManagerEx.getInstanceEx().openProject(alienProject);
|
||||
assertTrue(succ2);
|
||||
DaemonProgressIndicator.setDebug(true);
|
||||
final DaemonProgressIndicator[] indicator = new DaemonProgressIndicator[1];
|
||||
|
||||
try {
|
||||
Module alienModule = doCreateRealModuleIn("x", alienProject, getModuleType());
|
||||
@@ -1551,7 +1551,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
di.runPasses(getFile(), getEditor().getDocument(), textEditor, ArrayUtil.EMPTY_INT_ARRAY, true, () -> {
|
||||
if (checked[0]) return;
|
||||
checked[0] = true;
|
||||
indicator[0] = myDaemonCodeAnalyzer.getUpdateProgress();
|
||||
typeInAlienEditor(alienEditor, 'x');
|
||||
});
|
||||
}
|
||||
@@ -1659,7 +1658,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
long end = System.currentTimeMillis();
|
||||
long interruptTime = end - now;
|
||||
interruptTimes[finalI] = interruptTime;
|
||||
assertNull(codeAnalyzer.getUpdateProgress());
|
||||
assertTrue(codeAnalyzer.getUpdateProgress().isCanceled());
|
||||
System.out.println(interruptTime);
|
||||
throw new ProcessCanceledException();
|
||||
};
|
||||
@@ -1730,7 +1729,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
long end = System.currentTimeMillis();
|
||||
long interruptTime = end - now;
|
||||
interruptTimes[finalI] = interruptTime;
|
||||
assertNull(codeAnalyzer.getUpdateProgress());
|
||||
assertTrue(codeAnalyzer.getUpdateProgress().isCanceled());
|
||||
//System.out.println(interruptTime);
|
||||
throw new ProcessCanceledException();
|
||||
};
|
||||
@@ -2143,8 +2142,10 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
|
||||
long elapsed = System.currentTimeMillis() - start;
|
||||
|
||||
assertEquals(0, errors.size());
|
||||
if (!run.get()) {
|
||||
fail(ThreadDumper.dumpThreadsToString());
|
||||
}
|
||||
assertTrue("Elapsed: "+elapsed, elapsed >= SLEEP);
|
||||
assertTrue(run.get());
|
||||
}
|
||||
finally {
|
||||
ExternalLanguageAnnotators.INSTANCE.removeExplicitExtension(JavaLanguage.INSTANCE, annotator);
|
||||
|
||||
+35
-1
@@ -18,9 +18,15 @@ package com.intellij.codeInsight.daemon.inlays
|
||||
import com.intellij.codeInsight.daemon.impl.ParameterHintsPresentationManager
|
||||
import com.intellij.codeInsight.hints.settings.ParameterNameHintsSettings
|
||||
import com.intellij.openapi.editor.Inlay
|
||||
import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.openapi.fileEditor.FileEditor
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.impl.DebugUtil
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.util.DocumentUtil
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
@@ -80,6 +86,20 @@ class InlayAssert(private val file: PsiFile, val inlays: List<Inlay>) {
|
||||
assertThat(inlays).hasSize(0)
|
||||
}
|
||||
|
||||
private fun getAllInlays(): String {
|
||||
val fileManager = FileEditorManager.getInstance(file.project)
|
||||
val fileEditor: FileEditor = fileManager.getEditors(file.virtualFile).first()!!
|
||||
val editor = ((fileEditor as TextEditor).editor as EditorEx)
|
||||
|
||||
val inlays = editor.inlayModel.getInlineElementsInRange(0, file.textLength)
|
||||
|
||||
val hintManager = ParameterHintsPresentationManager.getInstance()
|
||||
return inlays
|
||||
.filter { hintManager.isParameterHint(it) }
|
||||
.map { it.offset to hintManager.getHintText(it) }
|
||||
.joinToString(",")
|
||||
}
|
||||
|
||||
fun assertInlays(vararg expectedInlays: String) {
|
||||
assertThat(expectedInlays.size).isNotEqualTo(0)
|
||||
|
||||
@@ -89,7 +109,13 @@ class InlayAssert(private val file: PsiFile, val inlays: List<Inlay>) {
|
||||
val hintNames = hints.map { it.second }
|
||||
|
||||
val elements = hintOffsets.mapNotNull { file.findElementAt(it) }
|
||||
assertThat(hints.size).isEqualTo(expectedInlays.size).withFailMessage("Element at offsets: ${elements.joinToString(", ")}")
|
||||
assertThat(hints.size)
|
||||
.withFailMessage("Expected ${expectedInlays.size} elements with hints, Actual elements count ${hints.size}" +
|
||||
": ${elements.joinToString(", ")}, file text: \n\n ${file.text} \n\n isCommitted ${isCommitted(file)} \n\n" +
|
||||
"Psi: \n ${DebugUtil.psiToString(file, true)}\n" +
|
||||
"All inlays: ${getAllInlays()}")
|
||||
|
||||
.isEqualTo(expectedInlays.size)
|
||||
|
||||
val expect = expectedInlays.map { it.substringBefore("->") to it.substringAfter("->") }
|
||||
val expectedHintNames = expect.map { it.first }
|
||||
@@ -101,4 +127,12 @@ class InlayAssert(private val file: PsiFile, val inlays: List<Inlay>) {
|
||||
assertThat(wordsAfter).isEqualTo(expectedWordsAfter)
|
||||
}
|
||||
|
||||
private fun isCommitted(file: PsiFile): Boolean {
|
||||
val manager = PsiDocumentManager.getInstance(file.project)
|
||||
val document = manager.getDocument(file)
|
||||
|
||||
assertThat(document).isNotNull()
|
||||
return manager.isCommitted(document!!)
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -487,6 +487,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTwoDifferentParameterizationCheckWithInterfaceTypeArguments() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -665,14 +665,12 @@ class Outer {
|
||||
|
||||
def copy = defContext.createCopy()
|
||||
|
||||
def write = new Element("context")
|
||||
copy.writeTemplateContext(write)
|
||||
def write = copy.writeTemplateContext(null)
|
||||
assert write.children.size() == 2 : JDOMUtil.writeElement(write)
|
||||
|
||||
copy.setEnabled(TemplateContextType.EP_NAME.findExtension(JavaCommentContextType), false)
|
||||
|
||||
write = new Element("context")
|
||||
copy.writeTemplateContext(write)
|
||||
write = copy.writeTemplateContext(null)
|
||||
assert write.children.size() == 3 : JDOMUtil.writeElement(write)
|
||||
}
|
||||
|
||||
@@ -700,8 +698,7 @@ class Outer {
|
||||
def javaContext = TemplateContextType.EP_NAME.findExtension(JavaCodeContextType.Generic)
|
||||
context.setEnabled(javaContext, true)
|
||||
|
||||
def saved = new Element('context')
|
||||
context.writeTemplateContext(saved)
|
||||
def saved = context.writeTemplateContext(null)
|
||||
|
||||
context = new TemplateContext()
|
||||
context.readTemplateContext(saved)
|
||||
|
||||
@@ -27,6 +27,16 @@ public class UnwrapLambdaTest extends UnwrapTestCase {
|
||||
" Sys<caret>tem.gc();\n" +
|
||||
"}\n");
|
||||
}
|
||||
|
||||
public void testUnwrapNestedLambda() throws Exception {
|
||||
assertUnwrapped("{\n" +
|
||||
" bar(() -> bar(() -> Sys<caret>tem.gc()));\n" +
|
||||
"}\n",
|
||||
|
||||
"{\n" +
|
||||
" bar(() -> Sys<caret>tem.gc());\n" +
|
||||
"}\n", 1);
|
||||
}
|
||||
|
||||
public void testUnwrapExpressionDeclaration() throws Exception {
|
||||
assertUnwrapped("{\n" +
|
||||
@@ -61,4 +71,14 @@ public class UnwrapLambdaTest extends UnwrapTestCase {
|
||||
" null;\n" +
|
||||
"}\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String createCode(String codeBefore) {
|
||||
return "public class A {\n" +
|
||||
" void foo() {\n" +
|
||||
indentTwice(codeBefore) +
|
||||
" }\n" +
|
||||
" void bar(Runnable r){}\n" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@ import com.intellij.execution.application.ApplicationConfiguration;
|
||||
import com.intellij.execution.application.ApplicationConfigurationType;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.impl.RunManagerImpl;
|
||||
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
|
||||
import com.intellij.execution.junit.*;
|
||||
import com.intellij.execution.junit2.configuration.JUnitConfigurable;
|
||||
import com.intellij.execution.junit2.configuration.JUnitConfigurationModel;
|
||||
@@ -27,6 +29,7 @@ import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
|
||||
import com.intellij.execution.testframework.SearchForTestsTask;
|
||||
import com.intellij.execution.testframework.TestSearchScope;
|
||||
import com.intellij.execution.ui.CommonJavaParametersPanel;
|
||||
import com.intellij.ide.util.AppPropertiesComponentImpl;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
@@ -37,10 +40,7 @@ import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -67,6 +67,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ConfigurationsTest extends BaseConfigurationTestCase {
|
||||
private final Assertion CHECK = new Assertion();
|
||||
|
||||
@@ -253,17 +255,22 @@ public class ConfigurationsTest extends BaseConfigurationTestCase {
|
||||
CHECK.singleOccurence(classPath, getFSPath(findFile(MOCK_JUNIT)));
|
||||
}
|
||||
|
||||
public void testExternalizeJUnitConfiguration() throws WriteExternalException, InvalidDataException {
|
||||
JUnitConfiguration configuration = createConfiguration(findTestA(getModule1()));
|
||||
Element element = new Element("cfg");
|
||||
configuration.writeExternal(element);
|
||||
JUnitConfiguration newCfg =
|
||||
new JUnitConfiguration(null, myProject, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
|
||||
public void testExternalizeJUnitConfiguration() {
|
||||
Module module = getModule1();
|
||||
JUnitConfiguration oldRc = createConfiguration(findTestA(module));
|
||||
oldRc.setWorkingDirectory(module.getModuleFilePath());
|
||||
|
||||
newCfg.readExternal(element);
|
||||
checkTestObject(configuration.getPersistentData().TEST_OBJECT, newCfg);
|
||||
assertEquals(Collections.singleton(getModule1()), ContainerUtilRt.newHashSet(newCfg.getModules()));
|
||||
checkClassName(configuration.getPersistentData().getMainClassName(), newCfg);
|
||||
RunManagerImpl runManager = new RunManagerImpl(myProject, new AppPropertiesComponentImpl());
|
||||
Element element = new Element("configuration");
|
||||
new RunnerAndConfigurationSettingsImpl(runManager, oldRc, false).writeExternal(element);
|
||||
|
||||
RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(runManager);
|
||||
settings.readExternal(element);
|
||||
JUnitConfiguration newRc = (JUnitConfiguration)settings.getConfiguration();
|
||||
|
||||
checkTestObject(oldRc.getPersistentData().TEST_OBJECT, newRc);
|
||||
assertThat(newRc.getModules()).containsOnly(module);
|
||||
checkClassName(oldRc.getPersistentData().getMainClassName(), newRc);
|
||||
}
|
||||
|
||||
public void testTestClassPathWhenRunningConfigurations() throws IOException, ExecutionException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import com.intellij.execution.configurations.UnknownConfigurationType;
|
||||
import com.intellij.execution.junit.JUnitConfigurationType;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
@@ -196,7 +195,7 @@ public class RunConfigurableTest extends LightIdeaTestCase {
|
||||
assertEquals(expected, myConfigurable.getAvailableDropPosition(direction));
|
||||
}
|
||||
|
||||
private static RunManagerImpl createRunManager(Element element) throws InvalidDataException {
|
||||
private static RunManagerImpl createRunManager(Element element) {
|
||||
Project project = getProject();
|
||||
RunManagerImpl runManager = new RunManagerImpl(project, PropertiesComponent.getInstance(project));
|
||||
runManager.initializeConfigurationTypes(new ConfigurationType[]{ApplicationConfigurationType.getInstance(),
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.intellij.psi.resolve;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiElementFactoryImpl;
|
||||
import com.intellij.psi.impl.search.JavaSourceFilterScope;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -95,4 +97,14 @@ public class ResolveInCodeFragmentTest extends ResolveTestCase {
|
||||
PsiCodeBlock block = factory.createCodeBlockFromText("{ return o; }", method);
|
||||
assertInstanceOf(block.findReferenceAt(block.getText().indexOf("o")).resolve(), PsiParameter.class);
|
||||
}
|
||||
|
||||
public void testDropCachesOnNonPhysicalContextChange() {
|
||||
PsiElementFactoryImpl factory = (PsiElementFactoryImpl)JavaPsiFacade.getElementFactory(getProject());
|
||||
PsiClass superClass = ((PsiJavaFile) PsiFileFactory.getInstance(myProject).createFileFromText("a.java", JavaFileType.INSTANCE, "class Super { @Deprecated void foo(){} }")).getClasses()[0];
|
||||
PsiClass subClass = ((PsiNewExpression)factory.createExpressionFromText("new Super() { void foo(){} }", superClass)).getAnonymousClass();
|
||||
assertNotNull(AnnotationUtil.findAnnotationInHierarchy(subClass.getMethods()[0], Deprecated.class));
|
||||
|
||||
superClass.getMethods()[0].getModifierList().getAnnotations()[0].delete();
|
||||
assertNull(AnnotationUtil.findAnnotationInHierarchy(subClass.getMethods()[0], Deprecated.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -355,6 +355,10 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest {
|
||||
}, false);
|
||||
}
|
||||
|
||||
public void testReplaceOldStyleArrayWithVarargs() throws Exception {
|
||||
doTest(null, new ParameterInfoImpl[] {new ParameterInfoImpl(0, "a", new PsiEllipsisType(PsiType.INT))}, false);
|
||||
}
|
||||
|
||||
public void testReorderParamsOfFunctionalInterface() {
|
||||
doTest(null, null, null, method -> new ParameterInfoImpl[]{
|
||||
new ParameterInfoImpl(1, "b", PsiType.INT),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -160,6 +160,10 @@ public class ExtractClassTest extends MultiFileTestCase{
|
||||
doTestInnerClass();
|
||||
}
|
||||
|
||||
public void testEnsurePreservedQualifier() throws Exception {
|
||||
doTestMethod();
|
||||
}
|
||||
|
||||
private void doTestFieldAndMethod(final String methodName) throws Exception {
|
||||
doTest((rootDir, rootAfter) -> {
|
||||
PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -119,7 +119,13 @@ public class MoveMembersTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
public void testEnumConstantFromCaseStatement() throws Exception {
|
||||
doTest("B", "A", 0);
|
||||
try {
|
||||
doTest("B", "A", 0);
|
||||
fail("Conflict expected");
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
assertEquals("Enum type won't be applicable in the current context", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testStringConstantFromCaseStatement() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -312,6 +312,17 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
}
|
||||
|
||||
public void testParameterInMethodUsedInMethodReference() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
try {
|
||||
BaseRefactoringProcessor.ConflictsInTestsException.setTestIgnore(true);
|
||||
doSingleFileTest();
|
||||
}
|
||||
finally {
|
||||
BaseRefactoringProcessor.ConflictsInTestsException.setTestIgnore(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void testNoConflictOnDeleteParameterWithMethodRefArg() throws Exception {
|
||||
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
doSingleFileTest();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,12 @@
|
||||
<item name='java.lang.Iterable java.util.Iterator<T> iterator()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name="java.lang.Readable int read(java.nio.CharBuffer) 0">
|
||||
<item name='java.lang.Object java.lang.Class<?> getClass()'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name="java.lang.Readable int read(java.nio.CharBuffer) 0">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name="java.lang.Runtime java.lang.Process exec(java.lang.String[]) 0">
|
||||
|
||||
+4
-4
@@ -172,7 +172,7 @@ class JavaPredefinedConfigurations {
|
||||
// Add comments and metadata
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.comments"),"/* 'CommentContent */", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.class"),"/** @'_Tag+ '_TagValue* */\nclass '_Class {\n}", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.methods"),"/** @'_Tag+ '_TagValue* */\n'_Type+ '_Method+('_ParameterType '_Parameter*);", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.methods"),"/** @'_Tag+ '_TagValue* */\n'_Type '_Method('_ParameterType '_Parameter*);", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.fields"),"class '_Class {\n /** @'_Tag+ '_TagValue* */\n '_Type+ 'Field+ = '_Init*;\n}", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.tags"),"/** @'Tag+ '_TagValue* */", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.xdoclet.metadata"),"/** @'Tag \n '_Property+\n*/", METADATA_TYPE),
|
||||
@@ -187,10 +187,10 @@ class JavaPredefinedConfigurations {
|
||||
" '_FieldType 'Field+ = '_Init?;\n" +
|
||||
"}", METADATA_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.annotated.methods"),
|
||||
"@'_Annotation+( )\n'_MethodType '_Method+('_ParameterType '_Parameter*);", METADATA_TYPE),
|
||||
"@'_Annotation+( )\n'_MethodType '_Method('_ParameterType '_Parameter*);", METADATA_TYPE),
|
||||
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.not.annotated.methods"),
|
||||
"@'_Annotation{0,0}\n'_MethodType '_Method+('_ParameterType '_Parameter*);", METADATA_TYPE),
|
||||
"@'_Annotation{0,0}\n'_MethodType '_Method('_ParameterType '_Parameter*);", METADATA_TYPE),
|
||||
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.annotation.declarations"),
|
||||
"@interface 'Interface {}", METADATA_TYPE),
|
||||
@@ -264,7 +264,7 @@ class JavaPredefinedConfigurations {
|
||||
" }\n"+
|
||||
"}",MISC_TYPE),
|
||||
createSearchTemplateInfo(SSRBundle.message("predefined.configuration.similar.methods.structure"),
|
||||
"'_RetType '_Method+('_ParameterType '_Parameter) throws 'ExceptionType {\n" +
|
||||
"'_RetType '_Method('_ParameterType '_Parameter*) throws 'ExceptionType {\n" +
|
||||
" try {\n" +
|
||||
" '_OtherStatements+;\n" +
|
||||
" } catch('_SomeException '_Exception) {\n" +
|
||||
|
||||
+6
-1
@@ -31,6 +31,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
@@ -318,7 +319,11 @@ public class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
final PsiElement firstElement = elements[0];
|
||||
final PsiElement secondElement = elements[1];
|
||||
|
||||
if (firstElement instanceof PsiDeclarationStatement && PsiTreeUtil.lastChild(firstElement) instanceof PsiErrorElement) {
|
||||
if (firstElement instanceof PsiDocComment) {
|
||||
// might be method with javadoc
|
||||
return true;
|
||||
}
|
||||
else if (firstElement instanceof PsiDeclarationStatement && PsiTreeUtil.lastChild(firstElement) instanceof PsiErrorElement) {
|
||||
// might be method
|
||||
return true;
|
||||
}
|
||||
|
||||
+6
-13
@@ -1670,23 +1670,16 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
|
||||
@Override
|
||||
public void visitClass(PsiClass clazz) {
|
||||
PsiClass clazz2 = (PsiClass)myMatchingVisitor.getElement();
|
||||
if (clazz.hasTypeParameters()) {
|
||||
myMatchingVisitor
|
||||
.setResult(
|
||||
myMatchingVisitor.match(clazz.getTypeParameterList(), ((PsiClass)myMatchingVisitor.getElement()).getTypeParameterList()));
|
||||
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.match(clazz.getTypeParameterList(), clazz2.getTypeParameterList()));
|
||||
if (!myMatchingVisitor.getResult()) return;
|
||||
}
|
||||
|
||||
PsiClass clazz2;
|
||||
|
||||
if (myMatchingVisitor.getElement() instanceof PsiDeclarationStatement &&
|
||||
myMatchingVisitor.getElement().getFirstChild() instanceof PsiClass
|
||||
) {
|
||||
clazz2 = (PsiClass)myMatchingVisitor.getElement().getFirstChild();
|
||||
}
|
||||
else {
|
||||
clazz2 = (PsiClass)myMatchingVisitor.getElement();
|
||||
final PsiDocComment comment = clazz.getDocComment();
|
||||
if (comment != null) {
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.match(comment, clazz2));
|
||||
if (!myMatchingVisitor.getResult()) return;
|
||||
}
|
||||
|
||||
final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(clazz.getNameIdentifier());
|
||||
|
||||
+23
-20
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.structuralsearch.impl.matcher.handlers;
|
||||
|
||||
import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator;
|
||||
@@ -5,7 +20,6 @@ import com.intellij.dupLocator.iterators.CountingNodeIterator;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.structuralsearch.impl.matcher.GlobalMatchingVisitor;
|
||||
import com.intellij.structuralsearch.impl.matcher.MatchContext;
|
||||
import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator;
|
||||
|
||||
@@ -13,11 +27,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: maxim
|
||||
* @author maxim
|
||||
* Date: 31.12.2004
|
||||
* Time: 12:01:29
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class DeclarationStatementHandler extends MatchingHandler {
|
||||
private MatchingHandler myCommentHandler;
|
||||
@@ -31,21 +43,17 @@ public class DeclarationStatementHandler extends MatchingHandler {
|
||||
if (!super.match(patternNode,matchedNode,context)) return false;
|
||||
final PsiDeclarationStatement dcl = (PsiDeclarationStatement)patternNode;
|
||||
if (matchedNode instanceof PsiDeclarationStatement) {
|
||||
return GlobalMatchingVisitor.continueMatchingSequentially(
|
||||
new SsrFilteringNodeIterator(patternNode.getFirstChild()),
|
||||
new SsrFilteringNodeIterator(matchedNode.getFirstChild()),
|
||||
context
|
||||
);
|
||||
return context.getMatcher().matchSequentially(new SsrFilteringNodeIterator(patternNode.getFirstChild()),
|
||||
new SsrFilteringNodeIterator(matchedNode.getFirstChild()));
|
||||
}
|
||||
final PsiElement[] declared = dcl.getDeclaredElements();
|
||||
|
||||
// declaration statement could wrap class or dcl
|
||||
if (declared.length > 0 && !(matchedNode.getParent() instanceof PsiDeclarationStatement) /* skip twice matching for child*/) {
|
||||
if (!(matchedNode instanceof PsiField)) {
|
||||
return GlobalMatchingVisitor.continueMatchingSequentially(
|
||||
return context.getMatcher().matchSequentially(
|
||||
new ArrayBackedNodeIterator(declared),
|
||||
new CountingNodeIterator(declared.length, new SsrFilteringNodeIterator(matchedNode)),
|
||||
context
|
||||
new CountingNodeIterator(declared.length, new SsrFilteringNodeIterator(matchedNode))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,10 +73,9 @@ public class DeclarationStatementHandler extends MatchingHandler {
|
||||
}
|
||||
node = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class);
|
||||
}
|
||||
boolean result = GlobalMatchingVisitor.continueMatchingSequentially(
|
||||
boolean result = context.getMatcher().matchSequentially(
|
||||
new ArrayBackedNodeIterator(declared),
|
||||
new ArrayBackedNodeIterator(matchNodes.toArray(new PsiElement[matchNodes.size()])),
|
||||
context
|
||||
new ArrayBackedNodeIterator(matchNodes.toArray(new PsiElement[matchNodes.size()]))
|
||||
);
|
||||
|
||||
if (result && declared[0] instanceof PsiVariable) {
|
||||
@@ -92,11 +99,7 @@ public class DeclarationStatementHandler extends MatchingHandler {
|
||||
|
||||
@Override
|
||||
public boolean shouldAdvanceTheMatchFor(PsiElement patternElement, PsiElement matchedElement) {
|
||||
if (patternElement instanceof PsiComment &&
|
||||
( matchedElement instanceof PsiField ||
|
||||
matchedElement instanceof PsiClass
|
||||
)
|
||||
) {
|
||||
if (patternElement instanceof PsiComment && (matchedElement instanceof PsiField || matchedElement instanceof PsiClass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -55,11 +56,6 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
|
||||
return ActionHint.parse(file, contents);
|
||||
}
|
||||
|
||||
private static void doTestFor(@NotNull String testName, @NotNull QuickFixTestCase quickFixTestCase) {
|
||||
final String relativePath = ObjectUtils.notNull(quickFixTestCase.getBasePath(), "") + "/" + BEFORE_PREFIX + testName;
|
||||
final String testFullPath = quickFixTestCase.getTestDataPath().replace(File.separatorChar, '/') + relativePath;
|
||||
@@ -148,7 +144,8 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
ReadonlyStatusHandlerImpl handler = (ReadonlyStatusHandlerImpl)ReadonlyStatusHandler.getInstance(file.getProject());
|
||||
handler.setClearReadOnlyInTests(true);
|
||||
try {
|
||||
ShowIntentionActionsHandler.chooseActionAndInvoke(file, getEditor(), action, action.getText());
|
||||
ApplicationManager.getApplication().invokeLater(() ->
|
||||
ShowIntentionActionsHandler.chooseActionAndInvoke(file, getEditor(), action, action.getText()));
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
finally {
|
||||
@@ -239,7 +236,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
@NotNull
|
||||
@Override
|
||||
public ActionHint parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
|
||||
return LightQuickFixTestCase.this.parseActionHintImpl(file, contents);
|
||||
return ActionHint.parse(file, contents);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+21
-9
@@ -21,7 +21,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
||||
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerManagerImpl;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
import com.intellij.debugger.impl.PrioritizedTask;
|
||||
import com.intellij.debugger.impl.SynchronizationBasedSemaphore;
|
||||
@@ -47,9 +46,9 @@ import com.intellij.util.SmartList;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
import com.intellij.util.lang.CompoundRuntimeException;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ThreadReference;
|
||||
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -379,33 +378,41 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
|
||||
|
||||
public void createBreakpoints(final PsiFile file) {
|
||||
Runnable runnable = () -> {
|
||||
BreakpointManager breakpointManager = DebuggerManagerImpl.getInstanceEx(myProject).getBreakpointManager();
|
||||
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager();
|
||||
Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);
|
||||
String text = document.getText();
|
||||
int offset = -1;
|
||||
for (; ;) {
|
||||
offset = document.getText().indexOf("Breakpoint!", offset + 1);
|
||||
while (true) {
|
||||
offset = text.indexOf("Breakpoint!", offset + 1);
|
||||
if (offset == -1) break;
|
||||
|
||||
int commentLine = document.getLineNumber(offset);
|
||||
|
||||
String comment = document.getText().substring(document.getLineStartOffset(commentLine), document.getLineEndOffset(commentLine));
|
||||
String comment = text.substring(document.getLineStartOffset(commentLine), document.getLineEndOffset(commentLine));
|
||||
|
||||
Breakpoint breakpoint;
|
||||
|
||||
if (comment.indexOf("Method") != -1) {
|
||||
if (comment.contains("Method")) {
|
||||
breakpoint = breakpointManager.addMethodBreakpoint(document, commentLine + 1);
|
||||
if (breakpoint != null) {
|
||||
println("MethodBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2),
|
||||
ProcessOutputTypes.SYSTEM);
|
||||
|
||||
String emulated = readValue(comment, "Emulated");
|
||||
if (emulated != null) {
|
||||
((JavaMethodBreakpointProperties)breakpoint.getXBreakpoint().getProperties()).EMULATED = Boolean.valueOf(emulated);
|
||||
println("Emulated = " + emulated, ProcessOutputTypes.SYSTEM);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (comment.indexOf("Field") != -1) {
|
||||
else if (comment.contains("Field")) {
|
||||
breakpoint = breakpointManager.addFieldBreakpoint(document, commentLine + 1, readValue(comment, "Field"));
|
||||
if (breakpoint != null) {
|
||||
println("FieldBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2), ProcessOutputTypes.SYSTEM);
|
||||
}
|
||||
}
|
||||
else if (comment.indexOf("Exception") != -1) {
|
||||
else if (comment.contains("Exception")) {
|
||||
breakpoint = breakpointManager.addExceptionBreakpoint(readValue(comment, "Exception"), "");
|
||||
if (breakpoint != null) {
|
||||
println("ExceptionBreakpoint created at " + file.getVirtualFile().getName() + ":" + (commentLine + 2),
|
||||
@@ -419,6 +426,11 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa
|
||||
}
|
||||
}
|
||||
|
||||
if (breakpoint == null) {
|
||||
LOG.error("Unable to set a breakpoint at line " + (commentLine + 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
String suspendPolicy = readValue(comment, "suspendPolicy");
|
||||
if (suspendPolicy != null) {
|
||||
//breakpoint.setSuspend(!DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy));
|
||||
|
||||
@@ -31,6 +31,12 @@ public abstract class PathMacroMap {
|
||||
|
||||
public abstract String substitute(String text, boolean caseSensitive);
|
||||
|
||||
public final String substitute(String text, boolean caseSensitive, boolean recursively) {
|
||||
return recursively
|
||||
? substituteRecursively(text, caseSensitive)
|
||||
: substitute(text, caseSensitive);
|
||||
}
|
||||
|
||||
public final void substitute(@NotNull Element e, boolean caseSensitive) {
|
||||
substitute(e, caseSensitive, false);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ import java.util.List;
|
||||
* Date: Dec 7, 2004
|
||||
*/
|
||||
public interface InspectionProfile extends Comparable {
|
||||
void setName(@NotNull String name);
|
||||
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
@@ -56,8 +54,7 @@ public interface InspectionProfile extends Comparable {
|
||||
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
|
||||
|
||||
/** Returns (unwrapped) inspection */
|
||||
<T extends InspectionProfileEntry>
|
||||
T getUnwrappedTool(@NotNull Key<T> shortNameKey, @NotNull PsiElement element);
|
||||
<T extends InspectionProfileEntry> T getUnwrappedTool(@NotNull Key<T> shortNameKey, @NotNull PsiElement element);
|
||||
|
||||
/**
|
||||
* Allows a plugin to modify the settings of the inspection tool with the specified ID programmatically, without going through
|
||||
|
||||
@@ -13,42 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.ex.InspectionToolWrapper;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 15-Feb-2006
|
||||
*/
|
||||
public interface ModifiableModel extends InspectionProfile {
|
||||
void enableTool(@NotNull String inspectionTool, NamedScope namedScope, Project project);
|
||||
|
||||
void setErrorLevel(HighlightDisplayKey key, @NotNull HighlightDisplayLevel level, Project project);
|
||||
|
||||
@Override
|
||||
HighlightDisplayLevel getErrorLevel(HighlightDisplayKey inspectionToolKey, PsiElement element);
|
||||
|
||||
@Override
|
||||
boolean isToolEnabled(HighlightDisplayKey key);
|
||||
|
||||
@Override
|
||||
boolean isToolEnabled(@Nullable HighlightDisplayKey key, @Nullable PsiElement element);
|
||||
|
||||
@Override
|
||||
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
|
||||
|
||||
@Override
|
||||
InspectionToolWrapper[] getInspectionTools(PsiElement element);
|
||||
|
||||
/**
|
||||
* @see InspectionProfile#getSingleTool()
|
||||
*/
|
||||
|
||||
@@ -40,10 +40,10 @@ public abstract class RainbowVisitor implements HighlightVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean analyze(@NotNull PsiFile file,
|
||||
boolean updateWholeFile,
|
||||
@NotNull HighlightInfoHolder holder,
|
||||
@NotNull Runnable action) {
|
||||
public boolean analyze(@NotNull PsiFile file,
|
||||
boolean updateWholeFile,
|
||||
@NotNull HighlightInfoHolder holder,
|
||||
@NotNull Runnable action) {
|
||||
myHolder = holder;
|
||||
myRainbowHighlighter = new RainbowHighlighter(myHolder.getColorsScheme());
|
||||
try {
|
||||
|
||||
+9
-4
@@ -30,6 +30,10 @@ import org.jetbrains.jps.model.module.JpsModuleReference
|
||||
import org.jetbrains.jps.util.JpsPathUtil
|
||||
|
||||
/**
|
||||
* Assembles output of modules to platform JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/lib directory),
|
||||
* bunlded plugins' JARs (in {@link org.jetbrains.intellij.build.BuildPaths#distAll distAll}/plugins directory) and zip archives with
|
||||
* non-bundled plugins (in {@link org.jetbrains.intellij.build.BuildPaths#artifacts artifacts}/plugins directory).
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
class DistributionJARsBuilder {
|
||||
@@ -399,10 +403,11 @@ class DistributionJARsBuilder {
|
||||
replace: "<version>${buildNumber}</version>")
|
||||
def sinceBuild
|
||||
def untilBuild
|
||||
/* Use relaxed build numbers range for EAP/release branches, i.e. plugins for 163.1111.22 build will be marked as compatible with 163.1111.* builds.
|
||||
Usually there are no API changes in EAP/release branches so it's convenient to be able to publish a single plugin for different IDEs built
|
||||
from the same EAP/release branch. */
|
||||
if (!setExactNumberInUntilBuild && buildNumber.matches(/(\d+\.)+\d+\.\d+/)) {
|
||||
/* Plugins from builds with numbers like 163.1111 (nightly builds) will be marked as compatible with all 163.* builds; it's required to
|
||||
allow us to use such plugins in other nightly builds and in IDEA built from sources (with build number 163.SNAPSHOT).
|
||||
Plugins from builds with numbers like 163.1111.22 (EAP/release builds) will be marked as compatible with all 163.1111.* builds. Usually there are no API changes in EAP/release branches so it's convenient to be able to publish a single plugin for different IDEs built
|
||||
from the same EAP/release branch. */
|
||||
if (!setExactNumberInUntilBuild && buildNumber.matches(/(\d+\.)+\d+/)) {
|
||||
sinceBuild = buildNumber.substring(0, buildNumber.lastIndexOf('.'))
|
||||
untilBuild = sinceBuild + ".*"
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ import org.jetbrains.jps.model.module.JpsModuleReference
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* Describes layout of the platform (*.jar files in IDE_HOME/lib directory). By default it includes all modules specified in {@link org.jetbrains.intellij.build.ProductModulesLayout},
|
||||
* all libraries these modules depend on with scope 'Compile' or 'Runtime', and all project libraries from dependencies (with scope 'Compile'
|
||||
* or 'Runtime') of plugin modules for plugins which are {@link org.jetbrains.intellij.build.ProductModulesLayout#bundledPluginModules bundled}
|
||||
* (or prepared to be {@link org.jetbrains.intellij.build.ProductModulesLayout#pluginModulesToPublish published}) with the product.
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
class PlatformLayout extends BaseLayout {
|
||||
|
||||
@@ -72,10 +72,7 @@ private class ExportSettingsAction : AnAction(), DumbAware {
|
||||
return
|
||||
}
|
||||
|
||||
val exportFiles = THashSet<Path>()
|
||||
for ((files) in markedComponents) {
|
||||
exportFiles.addAll(files)
|
||||
}
|
||||
val exportFiles = markedComponents.mapTo(THashSet()) { it.file }
|
||||
|
||||
val saveFile = dialog.exportFile
|
||||
try {
|
||||
|
||||
@@ -60,7 +60,7 @@ open class StateStorageManagerImpl(private val rootTagName: String,
|
||||
var streamProvider: StreamProvider?
|
||||
get() = streamWrapper
|
||||
set (value) {
|
||||
streamWrapper.setStreamProvider(value)
|
||||
streamWrapper.streamProvider = value
|
||||
}
|
||||
|
||||
// access under storageLock
|
||||
|
||||
@@ -22,6 +22,10 @@ public class StreamProviderWrapper implements StreamProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
public StreamProvider getStreamProvider() {
|
||||
return myStreamProvider;
|
||||
}
|
||||
|
||||
public void setStreamProvider(@Nullable StreamProvider streamProvider) {
|
||||
myStreamProvider = streamProvider;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.intellij.configurationStore
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateSettings
|
||||
import com.intellij.testFramework.InMemoryFsRule
|
||||
import com.intellij.testFramework.ProjectRule
|
||||
import com.intellij.util.io.readText
|
||||
import com.intellij.util.io.write
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class TemplateSchemeTest {
|
||||
companion object {
|
||||
@JvmField
|
||||
@ClassRule
|
||||
val projectRule = ProjectRule()
|
||||
}
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
val fsRule = InMemoryFsRule()
|
||||
|
||||
// https://youtrack.jetbrains.com/issue/IDEA-155623#comment=27-1721029
|
||||
@Test fun `do not remove unknown context`() {
|
||||
val schemeFile = fsRule.fs.getPath("templates/Groovy.xml")
|
||||
val schemeManagerFactory = SchemeManagerFactoryBase.TestSchemeManagerFactory(fsRule.fs.getPath(""))
|
||||
val schemeData = """
|
||||
<templateSet group="Groovy">
|
||||
<template name="serr" value="System.err.println("$\END$")dwed" description="Prints a string to System.errwefwe" toReformat="true" toShortenFQNames="true" deactivated="true">
|
||||
<context>
|
||||
<option name="__DO_NOT_DELETE_ME__" value="true" />
|
||||
<option name="GROOVY_STATEMENT" value="false" />
|
||||
</context>
|
||||
</template>
|
||||
</templateSet>""".trimIndent()
|
||||
|
||||
schemeFile.write(schemeData)
|
||||
|
||||
TemplateSettings(schemeManagerFactory)
|
||||
schemeManagerFactory.save()
|
||||
assertThat(schemeFile.readText()).isEqualTo(schemeData)
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -33,17 +35,84 @@ import java.util.Collection;
|
||||
public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.command.WriteCommandAction");
|
||||
|
||||
private static final String DEFAULT_COMMAND_NAME = "Undefined";
|
||||
private static final String DEFAULT_GROUP_ID = null;
|
||||
|
||||
public interface Builder {
|
||||
@NotNull Builder withName(@Nullable String name);
|
||||
@NotNull Builder withGroupId(@Nullable String groupId);
|
||||
|
||||
<E extends Throwable> void run(@NotNull ThrowableRunnable<E> action) throws E;
|
||||
<R, E extends Throwable> R compute(@NotNull ThrowableComputable<R, E> action) throws E;
|
||||
}
|
||||
|
||||
private static class BuilderImpl implements Builder {
|
||||
private final Project myProject;
|
||||
private final PsiFile[] myFiles;
|
||||
private String myCommandName = DEFAULT_COMMAND_NAME;
|
||||
private String myGroupId = DEFAULT_GROUP_ID;
|
||||
|
||||
private BuilderImpl(Project project, PsiFile... files) {
|
||||
myProject = project;
|
||||
myFiles = files;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Builder withName(String name) {
|
||||
myCommandName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Builder withGroupId(String groupId) {
|
||||
myGroupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends Throwable> void run(@NotNull final ThrowableRunnable<E> action) throws E {
|
||||
new WriteCommandAction(myProject, myCommandName, myGroupId, myFiles) {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
action.run();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, E extends Throwable> R compute(@NotNull final ThrowableComputable<R, E> action) throws E {
|
||||
return new WriteCommandAction<R>(myProject, myCommandName, myGroupId, myFiles) {
|
||||
@Override
|
||||
protected void run(@NotNull Result<R> result) throws Throwable {
|
||||
result.setResult(action.compute());
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Builder writeCommandAction(Project project) {
|
||||
return new BuilderImpl(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Builder writeCommandAction(@NotNull PsiFile first, @NotNull PsiFile... others) {
|
||||
return new BuilderImpl(first.getProject(), ArrayUtil.prepend(first, others));
|
||||
}
|
||||
|
||||
private final String myCommandName;
|
||||
private final String myGroupID;
|
||||
private final Project myProject;
|
||||
private final PsiFile[] myPsiFiles;
|
||||
|
||||
protected WriteCommandAction(@Nullable Project project, /*@NotNull*/ PsiFile... files) {
|
||||
this(project, "Undefined", files);
|
||||
this(project, DEFAULT_COMMAND_NAME, files);
|
||||
}
|
||||
|
||||
protected WriteCommandAction(@Nullable Project project, @Nullable String commandName, /*@NotNull*/ PsiFile... files) {
|
||||
this(project, commandName, null, files);
|
||||
this(project, commandName, DEFAULT_GROUP_ID, files);
|
||||
}
|
||||
|
||||
protected WriteCommandAction(@Nullable Project project, @Nullable String commandName, @Nullable String groupID, /*@NotNull*/ PsiFile... files) {
|
||||
@@ -186,7 +255,7 @@ public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
|
||||
}
|
||||
|
||||
public static void runWriteCommandAction(Project project, @NotNull Runnable runnable) {
|
||||
runWriteCommandAction(project, "Undefined", null, runnable);
|
||||
runWriteCommandAction(project, DEFAULT_COMMAND_NAME, DEFAULT_GROUP_ID, runnable);
|
||||
}
|
||||
|
||||
public static void runWriteCommandAction(Project project,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user