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:
+1
-1
@@ -246,7 +246,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
private InvalidArtifact createInvalidArtifact(ArtifactState state, String errorMessage) {
|
||||
final InvalidArtifact artifact = new InvalidArtifact(state, errorMessage);
|
||||
ProjectLoadingErrorsNotifier.getInstance(myProject).registerError(new ArtifactLoadingErrorDescription(myProject, artifact));
|
||||
UnknownFeaturesCollector.getInstance(myProject).registerUnknownFeature("com.intellij.packaging.artifacts.ArtifactType", state.getArtifactType());
|
||||
UnknownFeaturesCollector.getInstance(myProject).registerUnknownFeature("com.intellij.packaging.artifacts.ArtifactType", state.getArtifactType(), "Artifact");
|
||||
return artifact;
|
||||
}
|
||||
|
||||
|
||||
+14
-13
@@ -70,16 +70,6 @@ public class BuildElementsEditor extends ModuleElementsEditor {
|
||||
group.add(myInheritCompilerOutput);
|
||||
group.add(myPerModuleCompilerOutput);
|
||||
|
||||
final ActionListener listener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
enableCompilerSettings(!myInheritCompilerOutput.isSelected());
|
||||
}
|
||||
};
|
||||
|
||||
myInheritCompilerOutput.addActionListener(listener);
|
||||
myPerModuleCompilerOutput.addActionListener(listener);
|
||||
|
||||
myOutputPathPanel = createOutputPathPanel(ProjectBundle.message("module.paths.output.title"), new CommitPathRunnable() {
|
||||
@Override
|
||||
public void saveUrl(String url) {
|
||||
@@ -129,15 +119,26 @@ public class BuildElementsEditor extends ModuleElementsEditor {
|
||||
outputPathsPanel.add(myCbExcludeOutput, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
|
||||
GridBagConstraints.NONE, new Insets(6, 16, 0, 0), 0, 0));
|
||||
|
||||
final boolean outputPathInherited = getCompilerExtension().isCompilerOutputPathInherited();
|
||||
myInheritCompilerOutput.setSelected(outputPathInherited);
|
||||
myPerModuleCompilerOutput.setSelected(!outputPathInherited);
|
||||
|
||||
// fill with data
|
||||
updateOutputPathPresentation();
|
||||
|
||||
//compiler settings
|
||||
final boolean outputPathInherited = getCompilerExtension().isCompilerOutputPathInherited();
|
||||
myInheritCompilerOutput.setSelected(outputPathInherited);
|
||||
myPerModuleCompilerOutput.setSelected(!outputPathInherited);
|
||||
enableCompilerSettings(!outputPathInherited);
|
||||
|
||||
final ActionListener listener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
enableCompilerSettings(!myInheritCompilerOutput.isSelected());
|
||||
}
|
||||
};
|
||||
|
||||
myInheritCompilerOutput.addActionListener(listener);
|
||||
myPerModuleCompilerOutput.addActionListener(listener);
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setBorder(IdeBorderFactory.createTitledBorder(ProjectBundle.message("project.roots.output.compiler.title"),
|
||||
true));
|
||||
|
||||
+21
-4
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.util.RefactoringChangeUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -38,14 +39,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class SurroundWithTryCatchFix implements IntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.SurroundWithTryCatchFix");
|
||||
|
||||
private PsiStatement myStatement = null;
|
||||
private PsiElement myStatement = null;
|
||||
|
||||
public SurroundWithTryCatchFix(@NotNull PsiElement element) {
|
||||
final PsiFunctionalExpression functionalExpression = PsiTreeUtil.getParentOfType(element, PsiFunctionalExpression.class, false);
|
||||
if (functionalExpression == null ||
|
||||
(functionalExpression instanceof PsiLambdaExpression && ((PsiLambdaExpression)functionalExpression).getBody() instanceof PsiCodeBlock)) {
|
||||
final PsiFunctionalExpression functionalExpression = PsiTreeUtil.getParentOfType(element, PsiFunctionalExpression.class, false, PsiStatement.class);
|
||||
if (functionalExpression == null) {
|
||||
myStatement = PsiTreeUtil.getNonStrictParentOfType(element, PsiStatement.class);
|
||||
}
|
||||
else if (functionalExpression instanceof PsiLambdaExpression) {
|
||||
myStatement = functionalExpression;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,6 +85,20 @@ public class SurroundWithTryCatchFix implements IntentionAction {
|
||||
myStatement = forStatement;
|
||||
}
|
||||
}
|
||||
|
||||
if (myStatement instanceof PsiLambdaExpression) {
|
||||
PsiElement body = ((PsiLambdaExpression)myStatement).getBody();
|
||||
if (body instanceof PsiExpression) {
|
||||
myStatement = RefactoringUtil.expandExpressionLambdaToCodeBlock(body);
|
||||
}
|
||||
|
||||
body = ((PsiLambdaExpression)myStatement).getBody();
|
||||
LOG.assertTrue(body instanceof PsiCodeBlock);
|
||||
final PsiStatement[] statements = ((PsiCodeBlock)body).getStatements();
|
||||
LOG.assertTrue(statements.length == 1);
|
||||
myStatement = statements[0];
|
||||
}
|
||||
|
||||
TextRange range = null;
|
||||
|
||||
try{
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.siyeh.ipp.types.ExpandOneLineLambda2CodeBlockIntention;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -936,6 +937,21 @@ public class RefactoringUtil {
|
||||
return element instanceof PsiLoopStatement || element instanceof PsiIfStatement;
|
||||
}
|
||||
|
||||
public static PsiElement expandExpressionLambdaToCodeBlock(@NotNull PsiElement element) {
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class);
|
||||
LOG.assertTrue(lambdaExpression != null);
|
||||
final PsiElement body = lambdaExpression.getBody();
|
||||
LOG.assertTrue(body instanceof PsiExpression);
|
||||
String blockText = "{";
|
||||
blockText += PsiType.VOID.equals(LambdaUtil.getFunctionalInterfaceReturnType(lambdaExpression)) ? "" : "return ";
|
||||
blockText += body.getText() + ";}";
|
||||
|
||||
final String resultedLambdaText = lambdaExpression.getParameterList().getText() + "->" + blockText;
|
||||
final PsiExpression expressionFromText =
|
||||
JavaPsiFacade.getElementFactory(element.getProject()).createExpressionFromText(resultedLambdaText, lambdaExpression);
|
||||
return CodeStyleManager.getInstance(element.getProject()).reformat(lambdaExpression.replace(expressionFromText));
|
||||
}
|
||||
|
||||
public interface ImplicitConstructorUsageVisitor {
|
||||
void visitConstructor(PsiMethod constructor, PsiMethod baseConstructor);
|
||||
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "Surround with try/catch" "true"
|
||||
public class ExTest {
|
||||
public static void maybeThrow(String data) throws Ex {
|
||||
throw new Ex(data);
|
||||
}
|
||||
|
||||
{
|
||||
Block<String> b = (t) -> {
|
||||
try {
|
||||
ExTest.maybeThrow(t);
|
||||
} catch (Ex ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private static class Ex extends Throwable {
|
||||
public Ex(String s) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Block<T> {
|
||||
public void accept(T t);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Surround with try/catch" "false"
|
||||
// "Surround with try/catch" "true"
|
||||
public class ExTest {
|
||||
public static void maybeThrow(String data) throws Ex {
|
||||
throw new Ex(data);
|
||||
|
||||
+5
-1
@@ -30,11 +30,13 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.FreeThreadedFileViewProvider;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx<E> {
|
||||
private Reference<E> myElement;
|
||||
@@ -91,7 +93,9 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
|
||||
}
|
||||
|
||||
private void cacheElement(E element) {
|
||||
myElement = element == null ? null : new SoftReference<E>(element);
|
||||
myElement = element == null ? null :
|
||||
((PsiManagerEx)element.getManager()).isBatchFilesProcessingMode() ? new WeakReference<E>(element) :
|
||||
new SoftReference<E>(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -238,7 +238,7 @@ public class FacetManagerImpl extends FacetManager implements ModuleComponent, P
|
||||
FacetLoadingErrorDescription description = new FacetLoadingErrorDescription(facet);
|
||||
ProjectLoadingErrorsNotifier.getInstance(myModule.getProject()).registerError(description);
|
||||
if (typeId != null) {
|
||||
UnknownFeaturesCollector.getInstance(myModule.getProject()).registerUnknownFeature("com.intellij.facetType", typeId);
|
||||
UnknownFeaturesCollector.getInstance(myModule.getProject()).registerUnknownFeature("com.intellij.facetType", typeId, "Facet");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.BundleBase;
|
||||
import com.intellij.facet.ui.ValidationResult;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
@@ -265,7 +266,7 @@ public class ProjectSettingsStepBase extends AbstractActionWithPanel implements
|
||||
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
myLocationField.addBrowseFolderListener("Select base directory", "Select base directory for the Project",
|
||||
null, descriptor);
|
||||
return LabeledComponent.create(myLocationField, "&Location");
|
||||
return LabeledComponent.create(myLocationField, BundleBase.replaceMnemonicAmpersand("&Location"));
|
||||
}
|
||||
|
||||
private static File findSequentNonExistingUntitled() {
|
||||
|
||||
+1
-1
@@ -183,6 +183,6 @@ public class PluginAdvertiserEditorNotificationProvider extends EditorNotificati
|
||||
}
|
||||
|
||||
private static UnknownFeature createExtensionFeature(String extension) {
|
||||
return new UnknownFeature(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), extension);
|
||||
return new UnknownFeature(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), "File Type", extension);
|
||||
}
|
||||
}
|
||||
|
||||
+36
-3
@@ -39,7 +39,10 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.ui.EditorNotifications;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.containers.LinkedMultiMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.io.HttpRequests;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.util.xmlb.annotations.MapAnnotation;
|
||||
@@ -238,6 +241,7 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
|
||||
private final Map<Plugin, IdeaPluginDescriptor> myDisabledPlugins = new HashMap<Plugin, IdeaPluginDescriptor>();
|
||||
private List<String> myBundledPlugin;
|
||||
private final MultiMap<String, UnknownFeature> myFeatures = new MultiMap<String, UnknownFeature>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -256,6 +260,7 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
if (pluginId != null) {
|
||||
for (Plugin plugin : pluginId) {
|
||||
ids.put(plugin.myPluginId, plugin);
|
||||
myFeatures.putValue(plugin.myPluginId, feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,8 +304,7 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
private void onSuccess() {
|
||||
String message = null;
|
||||
if (!myPlugins.isEmpty() || !myDisabledPlugins.isEmpty()) {
|
||||
message = "Features covered by non-bundled plugins are detected.<br>";
|
||||
|
||||
message = getAddressedMessagePresentation();
|
||||
if (!myDisabledPlugins.isEmpty()) {
|
||||
message += "<a href=\"enable\">Enable plugins...</a><br>";
|
||||
}
|
||||
@@ -308,7 +312,7 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
message += "<a href=\"configure\">Configure plugins...</a><br>";
|
||||
}
|
||||
|
||||
message += "<a href=\"ignore\">Ignore All</a>";
|
||||
message += "<a href=\"ignore\">Ignore Unknown Features</a>";
|
||||
}
|
||||
else if (myBundledPlugin != null && !PropertiesComponent.getInstance().isTrueValue(IGNORE_ULTIMATE_EDITION)) {
|
||||
message = "Features covered by " + IDEA_ULTIMATE_EDITION +
|
||||
@@ -322,6 +326,35 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
NOTIFICATION_GROUP.createNotification(DISPLAY_ID, message, NotificationType.INFORMATION, notificationListener).notify(project);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getAddressedMessagePresentation() {
|
||||
final MultiMap<String, String> addressedFeatures = MultiMap.createSet();
|
||||
final Set<String> ids = new LinkedHashSet<String>();
|
||||
for (PluginDownloader plugin : myPlugins) {
|
||||
ids.add(plugin.getPluginId());
|
||||
}
|
||||
for (Plugin plugin : myDisabledPlugins.keySet()) {
|
||||
ids.add(plugin.myPluginId);
|
||||
}
|
||||
for (String id : ids) {
|
||||
for (UnknownFeature feature : myFeatures.get(id)) {
|
||||
addressedFeatures.putValue(feature.getFeatureDisplayName(), feature.getImplementationName());
|
||||
}
|
||||
}
|
||||
final String addressedFeaturesPresentation = StringUtil.join(addressedFeatures.entrySet(),
|
||||
new Function<Map.Entry<String, Collection<String>>, String>() {
|
||||
@Override
|
||||
public String fun(Map.Entry<String, Collection<String>> entry) {
|
||||
return entry.getKey() + "[" + StringUtil.join(entry.getValue(), ", ") + "]";
|
||||
}
|
||||
}, ", ");
|
||||
final int addressedFeaturesNumber = addressedFeatures.keySet().size();
|
||||
final int pluginsNumber = ids.size();
|
||||
return "Unknown feature" + (addressedFeaturesNumber == 1 ? "" : "s") +
|
||||
" (" + addressedFeaturesPresentation + ") covered by " + (myPlugins.isEmpty() ? "disabled" : "non-bundled") + " plugin" + (pluginsNumber == 1 ? "" : "s") +
|
||||
" detected.<br>";
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
+7
-1
@@ -22,10 +22,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class UnknownFeature {
|
||||
private final String myFeatureType;
|
||||
private final String myFeatureDisplayName;
|
||||
private final String myImplementationName;
|
||||
|
||||
public UnknownFeature(@NotNull String featureType, @NotNull String implementationName) {
|
||||
public UnknownFeature(@NotNull String featureType, String featureDisplayName, @NotNull String implementationName) {
|
||||
myFeatureType = featureType;
|
||||
myFeatureDisplayName = featureDisplayName;
|
||||
myImplementationName = implementationName;
|
||||
}
|
||||
|
||||
@@ -37,6 +39,10 @@ public class UnknownFeature {
|
||||
return myImplementationName;
|
||||
}
|
||||
|
||||
public String getFeatureDisplayName() {
|
||||
return myFeatureDisplayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
+4
-4
@@ -46,11 +46,11 @@ public class UnknownFeaturesCollector implements PersistentStateComponent<Elemen
|
||||
}
|
||||
|
||||
public void registerUnknownRunConfiguration(String configurationName) {
|
||||
registerUnknownFeature("com.intellij.configurationType", configurationName);
|
||||
registerUnknownFeature("com.intellij.configurationType", configurationName, "Run Configuration");
|
||||
}
|
||||
|
||||
public void registerUnknownFeature(String featureType, String implementationName) {
|
||||
final UnknownFeature feature = new UnknownFeature(featureType, implementationName);
|
||||
public void registerUnknownFeature(String featureType, String implementationName, String featureDisplayName) {
|
||||
final UnknownFeature feature = new UnknownFeature(featureType, featureDisplayName, implementationName);
|
||||
if (!isIgnored(feature)) {
|
||||
myUnknownFeatures.add(feature);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class UnknownFeaturesCollector implements PersistentStateComponent<Elemen
|
||||
myIgnoredUnknownFeatures.clear();
|
||||
for (Element element : state.getChildren()) {
|
||||
myIgnoredUnknownFeatures.add(
|
||||
new UnknownFeature(element.getAttributeValue(FEATURE_ID), element.getAttributeValue(IMPLEMENTATION_NAME)));
|
||||
new UnknownFeature(element.getAttributeValue(FEATURE_ID), null, element.getAttributeValue(IMPLEMENTATION_NAME)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.win32.IdeaWin32;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.WeakStringInterner;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -46,6 +47,7 @@ public class UrlClassLoader extends ClassLoader {
|
||||
// Feature enabling flag for saving / restoring file system information for local class directories, see Builder#usePersistentClasspathIndexForLocalClassDirectories
|
||||
private static final boolean INDEX_PERSISTENCE_ENABLED = Boolean.parseBoolean(System.getProperty("idea.classpath.index.enabled", "true"));
|
||||
@NonNls static final String CLASS_EXTENSION = ".class";
|
||||
private static boolean ourParallel = false;
|
||||
|
||||
static {
|
||||
// Since Java 7 classloading is parallel on parallel capable classloader (http://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html)
|
||||
@@ -59,6 +61,7 @@ public class UrlClassLoader extends ClassLoader {
|
||||
Method registerAsParallelCapable = ClassLoader.class.getDeclaredMethod("registerAsParallelCapable");
|
||||
registerAsParallelCapable.setAccessible(true);
|
||||
registerAsParallelCapable.invoke(null);
|
||||
ourParallel = true;
|
||||
}
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
@@ -134,6 +137,7 @@ public class UrlClassLoader extends ClassLoader {
|
||||
|
||||
private final List<URL> myURLs;
|
||||
private final ClassPath myClassPath;
|
||||
private final WeakStringInterner myClassNameInterner;
|
||||
private final boolean myAllowBootstrapResources;
|
||||
|
||||
/** @deprecated use {@link #build()}, left for compatibility with java.system.class.loader setting */
|
||||
@@ -172,6 +176,7 @@ public class UrlClassLoader extends ClassLoader {
|
||||
});
|
||||
myClassPath = createClassPath(builder);
|
||||
myAllowBootstrapResources = builder.myAllowBootstrapResources;
|
||||
myClassNameInterner = ourParallel ? new WeakStringInterner() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -335,6 +340,10 @@ public class UrlClassLoader extends ClassLoader {
|
||||
else return "";
|
||||
}
|
||||
|
||||
protected Object getClassLoadingLock(String className) {
|
||||
return myClassNameInterner != null ? myClassNameInterner.intern(new String(className)) : this;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface for a pool to store internal class loader caches, that can be shared between several different class loaders,
|
||||
* if they contain the same URLs in their classpaths.<p/>
|
||||
|
||||
+4
-6
@@ -50,12 +50,10 @@ public class ReplaceConditionalWithIfIntention extends Intention {
|
||||
private static void replaceConditionalWithIf(PsiConditionalExpression expression) throws IncorrectOperationException {
|
||||
final PsiElement expressionParent = expression.getParent();
|
||||
if (expressionParent instanceof PsiLambdaExpression) {
|
||||
String blockText = "{";
|
||||
blockText += PsiType.VOID.equals(LambdaUtil.getFunctionalInterfaceReturnType((PsiLambdaExpression)expressionParent)) ? "" : "return ";
|
||||
blockText += expression.getText() + ";}";
|
||||
final PsiCodeBlock codeBlock = (PsiCodeBlock)expression.replace(
|
||||
JavaPsiFacade.getElementFactory(expression.getProject()).createCodeBlockFromText(blockText, expression));
|
||||
final PsiStatement statement = codeBlock.getStatements()[0];
|
||||
final PsiElement codeBlock =
|
||||
((PsiLambdaExpression)RefactoringUtil.expandExpressionLambdaToCodeBlock(expression)).getBody();
|
||||
LOG.assertTrue(codeBlock instanceof PsiCodeBlock, codeBlock);
|
||||
final PsiStatement statement = ((PsiCodeBlock)codeBlock).getStatements()[0];
|
||||
expression = (PsiConditionalExpression)(statement instanceof PsiReturnStatement ? ((PsiReturnStatement)statement).getReturnValue()
|
||||
: ((PsiExpressionStatement)statement).getExpression());
|
||||
}
|
||||
|
||||
+2
-14
@@ -17,8 +17,8 @@ package com.siyeh.ipp.types;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ipp.base.Intention;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
@@ -40,21 +40,9 @@ public class ExpandOneLineLambda2CodeBlockIntention extends Intention {
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class);
|
||||
LOG.assertTrue(lambdaExpression != null);
|
||||
final PsiElement body = lambdaExpression.getBody();
|
||||
LOG.assertTrue(body instanceof PsiExpression);
|
||||
String blockText = "{";
|
||||
blockText += PsiType.VOID.equals(LambdaUtil.getFunctionalInterfaceReturnType(lambdaExpression)) ? "" : "return ";
|
||||
blockText += body.getText() + ";}";
|
||||
|
||||
final String resultedLambdaText = lambdaExpression.getParameterList().getText() + "->" + blockText;
|
||||
final PsiExpression expressionFromText =
|
||||
JavaPsiFacade.getElementFactory(element.getProject()).createExpressionFromText(resultedLambdaText, lambdaExpression);
|
||||
CodeStyleManager.getInstance(element.getProject()).reformat(lambdaExpression.replace(expressionFromText));
|
||||
RefactoringUtil.expandExpressionLambdaToCodeBlock(element);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class LambdaExpressionPredicate implements PsiElementPredicate {
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ class ForkedGroovyc implements GroovycFlavor {
|
||||
}
|
||||
|
||||
List<String> vmParams = ContainerUtilRt.newArrayList();
|
||||
vmParams.add("-Xmx" + settings.heapSize + "m");
|
||||
vmParams.add("-Xmx" + System.getProperty("groovyc.heap.size", settings.heapSize) + "m");
|
||||
vmParams.add("-Dfile.encoding=" + System.getProperty("file.encoding"));
|
||||
//vmParams.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239");
|
||||
|
||||
|
||||
+15
-12
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.compiler.GroovyCompilerConfigurable">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="643" height="167"/>
|
||||
@@ -8,7 +8,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="838f2" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="838f2" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -25,6 +25,7 @@
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/CompilerBundle" key="javac.option.max.heap.size"/>
|
||||
<visible value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="22ced" class="javax.swing.JTextField" binding="myHeapSize">
|
||||
@@ -33,18 +34,28 @@
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<visible value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="5e141">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="52aeb" class="com.intellij.ui.components.JBCheckBox" binding="myInvokeDynamicSupportCB">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Invoke &dynamic support"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="4e3dc" binding="myExcludesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
@@ -53,14 +64,6 @@
|
||||
<border type="etched" title="Exclude from stub generation"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="52aeb" class="com.intellij.ui.components.JBCheckBox" binding="myInvokeDynamicSupportCB">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Invoke &dynamic support"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user