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:
@@ -26,6 +26,7 @@ import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -251,9 +252,14 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ConfigurationException {
|
||||
if (getSelectedTemplate() == null) {
|
||||
ProjectTemplate template = getSelectedTemplate();
|
||||
if (template == null) {
|
||||
throw new ConfigurationException(ProjectBundle.message("project.new.wizard.from.template.error", myContext.getPresentationName()));
|
||||
}
|
||||
ValidationInfo info = template.validateSettings();
|
||||
if (info != null) {
|
||||
throw new ConfigurationException(info.message);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.module.ModuleWithNameAlreadyExists;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
@@ -36,6 +37,7 @@ import com.intellij.platform.templates.github.ZipUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
@@ -129,6 +131,12 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ZipInputStream getStream() throws IOException {
|
||||
return new ZipInputStream(myArchivePath.openStream());
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.platform.templates;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.ProjectTemplatesFactory;
|
||||
import com.intellij.util.Function;
|
||||
@@ -72,6 +73,12 @@ public class EmptyModuleTemplatesFactory implements ProjectTemplatesFactory {
|
||||
public ModuleBuilder createModuleBuilder() {
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ public class AnonymousCanBeMethodReferenceInspection extends BaseJavaLocalInspec
|
||||
final PsiCallExpression callExpression = LambdaCanBeMethReferenceInspection.canBeMethodReferenceProblem(methods[0].getBody(), parameters, anonymousClass.getBaseClassType());
|
||||
if (callExpression == null) return;
|
||||
final String methodRefText =
|
||||
LambdaCanBeMethReferenceInspection.createMethodReferenceText(callExpression, parameters, anonymousClass.getBaseClassType());
|
||||
LambdaCanBeMethReferenceInspection.createMethodReferenceText(callExpression, anonymousClass.getBaseClassType());
|
||||
|
||||
if (methodRefText != null) {
|
||||
final String canonicalText = anonymousClass.getBaseClassType().getCanonicalText();
|
||||
|
||||
+3
-3
@@ -168,12 +168,12 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static String createMethodReferenceText(PsiElement element, final PsiParameter[] parameters, PsiType functionalInterfaceType) {
|
||||
protected static String createMethodReferenceText(PsiElement element, PsiType functionalInterfaceType) {
|
||||
String methodRefText = null;
|
||||
if (element instanceof PsiMethodCallExpression) {
|
||||
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
|
||||
final PsiMethod psiMethod = methodCall.resolveMethod();
|
||||
LOG.assertTrue(psiMethod != null);
|
||||
if (psiMethod == null) return null;
|
||||
final PsiClass containingClass = psiMethod.getContainingClass();
|
||||
LOG.assertTrue(containingClass != null);
|
||||
final PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
|
||||
@@ -227,7 +227,7 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class);
|
||||
if (lambdaExpression == null) return;
|
||||
final String methodRefText = createMethodReferenceText(element, lambdaExpression.getParameterList().getParameters(), lambdaExpression.getFunctionalInterfaceType());
|
||||
final String methodRefText = createMethodReferenceText(element, lambdaExpression.getFunctionalInterfaceType());
|
||||
|
||||
if (methodRefText != null) {
|
||||
final PsiExpression psiExpression =
|
||||
|
||||
+4
-1
@@ -993,7 +993,10 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
if (method == null || methodParamsDependOn(typeParameter, expression,
|
||||
functionalInterfaceType, method.getParameterList().getParameters(),
|
||||
LambdaUtil.getSubstitutor(method, resolveResult))) {
|
||||
return getFailedInferenceConstraint(typeParameter);
|
||||
if (expression instanceof PsiMethodReferenceExpression) {
|
||||
return getFailedInferenceConstraint(typeParameter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
class LambdaTest {
|
||||
|
||||
public void highlightsTheBug(Stream<String> stream) {
|
||||
stream.flatMap((Block<? super String> sink, String element) -> {});
|
||||
}
|
||||
|
||||
public interface Block<B> {
|
||||
void apply(B t);
|
||||
}
|
||||
|
||||
public interface Stream<S> {
|
||||
<R> Stream<R> flatMap(FlatMapper<? super S, R> mapper);
|
||||
|
||||
}
|
||||
|
||||
public interface FlatMapper<F, R> {
|
||||
void flatMapInto(Block<? super R> sink, F element);
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -152,7 +152,11 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testRecursiveAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testIncompatibleFormalParameterTypes() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Utils {
|
||||
|
||||
public static String formatDuration(long duration) {
|
||||
final long minutes = duration / 60000;
|
||||
final long seconds = (duration % 60000) / 1000;
|
||||
final long seconds = ((duration + 500L) % 60000) / 1000;
|
||||
if (minutes > 0L) {
|
||||
return minutes + " min " + seconds + " sec";
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.execution.ui.layout.impl;
|
||||
|
||||
import com.intellij.execution.ui.layout.*;
|
||||
import com.intellij.execution.ui.layout.actions.CloseViewAction;
|
||||
import com.intellij.execution.ui.layout.actions.MinimizeViewAction;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
@@ -119,7 +120,8 @@ public class GridCellImpl implements GridCell {
|
||||
myTabs.addTabMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
if (UIUtil.isCloseClick(e)) {
|
||||
minimize(e);
|
||||
// see RunnerContentUi tabMouseListener as well
|
||||
closeOrMinimize(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -250,7 +252,8 @@ public class GridCellImpl implements GridCell {
|
||||
if (myTabs.getSelectedInfo() != tab) {
|
||||
if (activate) {
|
||||
tab.fireAlert();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
tab.stopAlerting();
|
||||
}
|
||||
}
|
||||
@@ -337,7 +340,8 @@ public class GridCellImpl implements GridCell {
|
||||
tab.setDetached(myPlaceInGrid, false);
|
||||
}
|
||||
myContext.detachTo(window, this).notifyWhenDone(result);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result.setDone();
|
||||
}
|
||||
|
||||
@@ -432,7 +436,7 @@ public class GridCellImpl implements GridCell {
|
||||
public Dimension getSize() {
|
||||
return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject());
|
||||
}
|
||||
|
||||
|
||||
private String getDimensionKey() {
|
||||
return "GridCell.Tab." + myContainer.getTab().getIndex() + "." + myPlaceInGrid.name();
|
||||
}
|
||||
@@ -445,12 +449,16 @@ public class GridCellImpl implements GridCell {
|
||||
minimize(new Content[]{content});
|
||||
}
|
||||
|
||||
public void minimize(MouseEvent e) {
|
||||
if (!MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) return;
|
||||
|
||||
public void closeOrMinimize(MouseEvent e) {
|
||||
TabInfo tabInfo = myTabs.findInfo(e);
|
||||
if (tabInfo != null) {
|
||||
minimize(getContentFor(tabInfo));
|
||||
if (tabInfo == null) return;
|
||||
|
||||
Content content = getContentFor(tabInfo);
|
||||
if (CloseViewAction.isEnabled(new Content[]{content})) {
|
||||
CloseViewAction.perform(myContext, content);
|
||||
}
|
||||
else if (MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) {
|
||||
minimize(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.execution.ui.layout.impl;
|
||||
import com.intellij.execution.ui.RunnerLayoutUi;
|
||||
import com.intellij.execution.ui.layout.*;
|
||||
import com.intellij.execution.ui.layout.actions.CloseViewAction;
|
||||
import com.intellij.execution.ui.layout.actions.MinimizeViewAction;
|
||||
import com.intellij.execution.ui.layout.actions.RestoreViewAction;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -249,11 +250,16 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (UIUtil.isCloseClick(e)) {
|
||||
final TabInfo tabInfo = myTabs.findInfo(e);
|
||||
final GridImpl grid = getGridFor(tabInfo);
|
||||
final GridImpl grid = tabInfo == null? null : getGridFor(tabInfo);
|
||||
final Content[] contents = grid != null ? CONTENT_KEY.getData(grid) : null;
|
||||
if (contents != null && CloseViewAction.isEnabled(contents)) {
|
||||
if (contents == null) return;
|
||||
// see GridCellImpl.closeOrMinimize as well
|
||||
if (CloseViewAction.isEnabled(contents)) {
|
||||
CloseViewAction.perform(RunnerContentUi.this, contents[0]);
|
||||
}
|
||||
else if (MinimizeViewAction.isEnabled(RunnerContentUi.this, contents, ViewContext.TAB_TOOLBAR_PLACE)) {
|
||||
grid.getCellFor(contents[0]).minimize(contents[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+5
-1
@@ -189,7 +189,11 @@ public class WebModuleGenerationStep extends ModuleWizardStep {
|
||||
if (peer == null) {
|
||||
throw new ConfigurationException("Peer should be not-null for " + myCurrentGenerator.getName());
|
||||
}
|
||||
return peer.validate() == null;
|
||||
ValidationInfo validate = peer.validate();
|
||||
if (validate != null) {
|
||||
throw new ConfigurationException(validate.message);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.WebProjectGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
@@ -76,4 +78,10 @@ public abstract class WebProjectTemplate<T> extends WebProjectGenerator<T> imple
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return myPeer.getValue().validate();
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -157,7 +157,11 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator
|
||||
@Override
|
||||
@Nullable
|
||||
public ValidationInfo validate() {
|
||||
return null;
|
||||
Object obj = myComboBox.getSelectedItem();
|
||||
if (obj instanceof GithubTagInfo) {
|
||||
return null;
|
||||
}
|
||||
return new ValidationInfo("Can't handle selected version: " + obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -212,44 +212,45 @@ class CacheUpdateRunner {
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
if (myProject.isDisposed()) return;
|
||||
if (myInnerIndicator.isCanceled()) return;
|
||||
|
||||
final FileContent fileContent = myQueue.take();
|
||||
if (fileContent == null) {
|
||||
myFinished.set(Boolean.TRUE);
|
||||
if (myProject.isDisposed() || myInnerIndicator.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
myQueue.waitForOtherContentReleaseToPreventOOM(myInnerIndicator, fileContent);
|
||||
final FileContent fileContent = myQueue.take(myInnerIndicator);
|
||||
if (fileContent == null) {
|
||||
myFinished.set(Boolean.TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
final Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
myInnerIndicator.checkCanceled();
|
||||
|
||||
if (myProject.isDisposed()) return;
|
||||
|
||||
final VirtualFile file = fileContent.getVirtualFile();
|
||||
myProgressUpdater.consume(file);
|
||||
mySession.processFile(fileContent);
|
||||
if (!myProject.isDisposed()) {
|
||||
final VirtualFile file = fileContent.getVirtualFile();
|
||||
myProgressUpdater.consume(file);
|
||||
mySession.processFile(fileContent);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (myProcessInReadAction) {
|
||||
myApplication.runReadAction(action);
|
||||
try {
|
||||
if (myProcessInReadAction) {
|
||||
myApplication.runReadAction(action);
|
||||
}
|
||||
else {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
else {
|
||||
action.run();
|
||||
catch (ProcessCanceledException e) {
|
||||
myQueue.pushback(fileContent);
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
myQueue.release(fileContent);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
myQueue.pushback(fileContent);
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
if (fileContent != null) {
|
||||
myQueue.release(fileContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ public class DumbServiceImpl extends DumbService {
|
||||
private volatile int myTotalItems;
|
||||
private double myCurrentBaseTotal;
|
||||
|
||||
public IndexUpdateRunnable(CacheUpdateRunner action) {
|
||||
public IndexUpdateRunnable(@NotNull CacheUpdateRunner action) {
|
||||
myAction = action;
|
||||
myTotalItems = 0;
|
||||
myCurrentBaseTotal = 0;
|
||||
@@ -359,21 +359,28 @@ public class DumbServiceImpl extends DumbService {
|
||||
|
||||
private void runAction(ProgressIndicator indicator, CacheUpdateRunner updateRunner) {
|
||||
while (updateRunner != null) {
|
||||
indicator.setIndeterminate(true);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
int count = updateRunner.queryNeededFiles(indicator);
|
||||
try {
|
||||
indicator.checkCanceled();
|
||||
indicator.setIndeterminate(true);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
|
||||
int count = updateRunner.queryNeededFiles(indicator);
|
||||
|
||||
myCurrentBaseTotal = count;
|
||||
myTotalItems += count;
|
||||
myCurrentBaseTotal = count;
|
||||
myTotalItems += count;
|
||||
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updating"));
|
||||
if (count > 0) {
|
||||
updateRunner.processFiles(indicator, true);
|
||||
indicator.setIndeterminate(false);
|
||||
indicator.setText(IdeBundle.message("progress.indexing.updating"));
|
||||
if (count > 0) {
|
||||
updateRunner.processFiles(indicator, true);
|
||||
}
|
||||
updateRunner.updatingDone();
|
||||
myProcessedItems += count;
|
||||
}
|
||||
catch (ProcessCanceledException ignored) {
|
||||
}
|
||||
catch (Throwable unexpected) {
|
||||
LOG.error(unexpected);
|
||||
}
|
||||
updateRunner.updatingDone();
|
||||
myProcessedItems += count;
|
||||
|
||||
updateRunner = getNextUpdateRunner();
|
||||
}
|
||||
}
|
||||
@@ -398,7 +405,7 @@ public class DumbServiceImpl extends DumbService {
|
||||
// try to obtain the next action or terminate if no actions left
|
||||
while (!myProject.isDisposed()) {
|
||||
try {
|
||||
Ref<CacheUpdateRunner> ref = actionQueue.poll(500, TimeUnit.MILLISECONDS);
|
||||
Ref<CacheUpdateRunner> ref = actionQueue.poll(500L, TimeUnit.MILLISECONDS);
|
||||
if (ref != null) {
|
||||
return ref.get();
|
||||
}
|
||||
|
||||
@@ -139,36 +139,46 @@ public class FileContentQueue {
|
||||
}
|
||||
}
|
||||
|
||||
void waitForOtherContentReleaseToPreventOOM(ProgressIndicator indicator, FileContent content) {
|
||||
final long length = content.getLength();
|
||||
while (true) {
|
||||
indicator.checkCanceled();
|
||||
synchronized (this) {
|
||||
boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = true;
|
||||
}
|
||||
@Nullable
|
||||
public FileContent take(@NotNull ProgressIndicator indicator) throws ProcessCanceledException{
|
||||
final FileContent content = doTake();
|
||||
if (content != null) {
|
||||
final long length = content.getLength();
|
||||
while (true) {
|
||||
try {
|
||||
if (myLargeSizeRequested && !requestingLargeSize ||
|
||||
myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length))
|
||||
wait(300L);
|
||||
else {
|
||||
myTakenSize += length;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
catch (InterruptedException ignore) {
|
||||
|
||||
catch (ProcessCanceledException e) {
|
||||
pushback(content);
|
||||
throw e;
|
||||
}
|
||||
synchronized (this) {
|
||||
final boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = true;
|
||||
}
|
||||
try {
|
||||
if (myLargeSizeRequested && !requestingLargeSize || myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length)) {
|
||||
wait(300L);
|
||||
}
|
||||
else {
|
||||
myTakenSize += length;
|
||||
if (requestingLargeSize) {
|
||||
myLargeSizeRequested = false;
|
||||
}
|
||||
return content;
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
FileContent take() {
|
||||
private FileContent doTake() {
|
||||
FileContent result;
|
||||
synchronized (this) {
|
||||
result = myPushbackBuffer.poll();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.platform;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -38,4 +39,10 @@ public interface ProjectTemplate {
|
||||
|
||||
@NotNull
|
||||
ModuleBuilder createModuleBuilder();
|
||||
|
||||
/**
|
||||
* @return null if ok, error message otherwise
|
||||
*/
|
||||
@Nullable
|
||||
ValidationInfo validateSettings();
|
||||
}
|
||||
|
||||
+12
-5
@@ -92,11 +92,18 @@ public class ReplaceMethodRefWithLambdaIntention extends Intention {
|
||||
final PsiElement referenceNameElement = referenceExpression.getReferenceNameElement();
|
||||
if (isReceiver){
|
||||
buf.append(parameters[0].getName()).append(".");
|
||||
} else if (qualifier != null &&
|
||||
!(qualifier instanceof PsiThisExpression && ((PsiThisExpression)qualifier).getQualifier() == null) &&
|
||||
!(referenceNameElement instanceof PsiKeyword)){
|
||||
buf.append(qualifier.getText()).append(".");
|
||||
}
|
||||
} else {
|
||||
if (!(referenceNameElement instanceof PsiKeyword)) {
|
||||
if (qualifier instanceof PsiTypeElement) {
|
||||
final PsiJavaCodeReferenceElement referenceElement = ((PsiTypeElement)qualifier).getInnermostComponentReferenceElement();
|
||||
LOG.assertTrue(referenceElement != null);
|
||||
buf.append(referenceElement.getReferenceName()).append(".");
|
||||
}
|
||||
else if (qualifier != null && !(qualifier instanceof PsiThisExpression && ((PsiThisExpression)qualifier).getQualifier() == null)) {
|
||||
buf.append(qualifier.getText()).append(".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//new or method name
|
||||
buf.append(referenceExpression.getReferenceName());
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test<T> {
|
||||
static void foo() {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
void test() {
|
||||
Runnable runnable = Test<String>:<caret>:foo;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test<T> {
|
||||
static void foo() {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
void test() {
|
||||
Runnable runnable = () -> Test.foo();
|
||||
}
|
||||
}
|
||||
+4
@@ -81,4 +81,8 @@ public class ReplaceMethodReferenceWithLambdaIntentionTest extends IPPTestCase {
|
||||
public void testSubst() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeElementOnTheLeft() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ public class AndroidCommonUtils {
|
||||
};
|
||||
|
||||
@NonNls public static final String INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME = "includeSystemProguardFile";
|
||||
@NonNls public static final String INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME = "includeAssetsFromLibraraies";
|
||||
@NonNls public static final String ADDITIONAL_NATIVE_LIBS_ELEMENT = "additionalNativeLibs";
|
||||
@NonNls public static final String ITEM_ELEMENT = "item";
|
||||
@NonNls public static final String ARCHITECTURE_ATTRIBUTE = "architecture";
|
||||
|
||||
+2
-2
@@ -257,7 +257,7 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
|
||||
if (!extension.isLibrary() &&
|
||||
!(context.isMake() &&
|
||||
checkUpToDate(module, resourcesStates, resourcesStorage, true) &&
|
||||
checkUpToDate(module, assetsStates, assetsStorage, extension.isPackAssetsFromLibraries()) &&
|
||||
checkUpToDate(module, assetsStates, assetsStorage, extension.isIncludeAssetsFromLibraries()) &&
|
||||
manifestFile.lastModified() == manifestStorage.getStamp(manifestFile, new ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)))) {
|
||||
|
||||
updateState = packageResources(extension, manifestFile, context);
|
||||
@@ -565,7 +565,7 @@ public class AndroidPackagingBuilder extends TargetBuilder<BuildRootDescriptor,
|
||||
result.add(assetsDir.getPath());
|
||||
}
|
||||
|
||||
if (extension.isPackAssetsFromLibraries()) {
|
||||
if (extension.isIncludeAssetsFromLibraries()) {
|
||||
for (JpsAndroidModuleExtension depExtension : AndroidJpsUtil.getAllAndroidDependencies(extension.getModule(), true)) {
|
||||
final File depAssetsDir = depExtension.getAssetsDir();
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public interface JpsAndroidModuleExtension extends JpsElement {
|
||||
|
||||
boolean isPackTestCode();
|
||||
|
||||
boolean isPackAssetsFromLibraries();
|
||||
boolean isIncludeAssetsFromLibraries();
|
||||
|
||||
boolean isRunProcessResourcesMavenTask();
|
||||
|
||||
|
||||
+2
-2
@@ -178,8 +178,8 @@ public class JpsAndroidModuleExtensionImpl extends JpsElementBase<JpsAndroidModu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackAssetsFromLibraries() {
|
||||
return myProperties.PACK_ASSETS_FROM_LIBRARIES;
|
||||
public boolean isIncludeAssetsFromLibraries() {
|
||||
return myProperties.myIncludeAssetsFromLibraries;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -54,14 +54,15 @@ public class JpsAndroidModuleProperties {
|
||||
|
||||
public boolean PACK_TEST_CODE;
|
||||
|
||||
public boolean PACK_ASSETS_FROM_LIBRARIES;
|
||||
|
||||
public boolean RUN_PROGUARD;
|
||||
public String PROGUARD_CFG_PATH;
|
||||
|
||||
@Tag(AndroidCommonUtils.INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME)
|
||||
public boolean myIncludeSystemProguardCfgPath = true;
|
||||
|
||||
@Tag(AndroidCommonUtils.INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME)
|
||||
public boolean myIncludeAssetsFromLibraries = false;
|
||||
|
||||
@Tag("resOverlayFolders")
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "path", elementValueAttribute = "")
|
||||
public List<String> RES_OVERLAY_FOLDERS = new ArrayList<String>();
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom
|
||||
if (assetsDir != null) {
|
||||
result.add(FileUtil.toSystemDependentName(assetsDir.getPath()));
|
||||
}
|
||||
if (facet.getConfiguration().PACK_ASSETS_FROM_LIBRARIES) {
|
||||
if (facet.getConfiguration().isIncludeAssetsFromLibraries()) {
|
||||
for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) {
|
||||
final VirtualFile depAssetsDir = AndroidRootUtil.getAssetsDir(depFacet);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ResourcesValidityState implements ValidityState {
|
||||
if (depResDir != null) {
|
||||
collectFiles(depResDir);
|
||||
}
|
||||
if (configuration.PACK_ASSETS_FROM_LIBRARIES) {
|
||||
if (configuration.isIncludeAssetsFromLibraries()) {
|
||||
final VirtualFile depAssetDir = AndroidRootUtil.getAssetsDir(depFacet);
|
||||
if (depAssetDir != null) {
|
||||
collectFiles(depAssetDir);
|
||||
|
||||
@@ -62,8 +62,6 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
|
||||
public String ASSETS_FOLDER_RELATIVE_PATH = "/" + SdkConstants.FD_ASSETS;
|
||||
public String LIBS_FOLDER_RELATIVE_PATH = "/" + SdkConstants.FD_NATIVE_LIBS;
|
||||
|
||||
public boolean PACK_ASSETS_FROM_LIBRARIES = false;
|
||||
|
||||
public List<String> RES_OVERLAY_FOLDERS = Arrays.asList("/res-overlay");
|
||||
|
||||
public boolean USE_CUSTOM_APK_RESOURCE_FOLDER = false;
|
||||
@@ -88,6 +86,7 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
|
||||
public String PROGUARD_CFG_PATH = "/" + AndroidCompileUtil.PROGUARD_CFG_FILE_NAME;
|
||||
|
||||
private boolean myIncludeSystemProguardCfgPath = true;
|
||||
private boolean myIncludeAssetsFromLibraries = false;
|
||||
|
||||
private List<AndroidNativeLibData> myAdditionalNativeLibraries = Collections.emptyList();
|
||||
|
||||
@@ -167,15 +166,18 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
|
||||
}
|
||||
|
||||
final Element includeSystemProguardFile = element.getChild(AndroidCommonUtils.INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME);
|
||||
if (includeSystemProguardFile != null) {
|
||||
final String includeSystemProguardFileValue = includeSystemProguardFile.getValue();
|
||||
final String includeSystemProguardFileValue = includeSystemProguardFile != null
|
||||
? includeSystemProguardFile.getValue()
|
||||
: null;
|
||||
myIncludeSystemProguardCfgPath = includeSystemProguardFileValue != null &&
|
||||
Boolean.parseBoolean(includeSystemProguardFileValue);
|
||||
|
||||
if (includeSystemProguardFileValue != null) {
|
||||
myIncludeSystemProguardCfgPath = Boolean.parseBoolean(includeSystemProguardFileValue);
|
||||
return;
|
||||
}
|
||||
}
|
||||
myIncludeSystemProguardCfgPath = false;
|
||||
final Element includeAssetsFromLibraries = element.getChild(AndroidCommonUtils.INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME);
|
||||
final String includeAssetsFromLibrariesValue = includeAssetsFromLibraries != null
|
||||
? includeAssetsFromLibraries.getValue()
|
||||
: null;
|
||||
myIncludeAssetsFromLibraries = includeAssetsFromLibrariesValue == null ||
|
||||
Boolean.parseBoolean(includeAssetsFromLibrariesValue);
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
@@ -186,6 +188,10 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
|
||||
includeSystemProguerdFile.setText(Boolean.toString(myIncludeSystemProguardCfgPath));
|
||||
element.addContent(includeSystemProguerdFile);
|
||||
|
||||
final Element includeAssetsFromLibraries = new Element(AndroidCommonUtils.INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME);
|
||||
includeAssetsFromLibraries.setText(Boolean.toString(myIncludeAssetsFromLibraries));
|
||||
element.addContent(includeAssetsFromLibraries);
|
||||
|
||||
final Element additionalNativeLibs = new Element(AndroidCommonUtils.ADDITIONAL_NATIVE_LIBS_ELEMENT);
|
||||
|
||||
for (AndroidNativeLibData lib : myAdditionalNativeLibraries) {
|
||||
@@ -238,4 +244,12 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
|
||||
public void setAdditionalNativeLibraries(@NotNull List<AndroidNativeLibData> additionalNativeLibraries) {
|
||||
myAdditionalNativeLibraries = additionalNativeLibraries;
|
||||
}
|
||||
|
||||
public boolean isIncludeAssetsFromLibraries() {
|
||||
return myIncludeAssetsFromLibraries;
|
||||
}
|
||||
|
||||
public void setIncludeAssetsFromLibraries(boolean includeAssetsFromLibraries) {
|
||||
myIncludeAssetsFromLibraries = includeAssetsFromLibraries;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
|
||||
if (myConfiguration.PACK_TEST_CODE != myIncludeTestCodeAndCheckBox.isSelected()) {
|
||||
return true;
|
||||
}
|
||||
if (myConfiguration.PACK_ASSETS_FROM_LIBRARIES != myIncludeAssetsFromLibraries.isSelected()) {
|
||||
if (myConfiguration.isIncludeAssetsFromLibraries() != myIncludeAssetsFromLibraries.isSelected()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
|
||||
|
||||
myConfiguration.PACK_TEST_CODE = myIncludeTestCodeAndCheckBox.isSelected();
|
||||
|
||||
myConfiguration.PACK_ASSETS_FROM_LIBRARIES = myIncludeAssetsFromLibraries.isSelected();
|
||||
myConfiguration.setIncludeAssetsFromLibraries(myIncludeAssetsFromLibraries.isSelected());
|
||||
|
||||
String absProguardPath = myProguardConfigFileTextField.getText().trim();
|
||||
if (absProguardPath.length() == 0) {
|
||||
@@ -566,7 +566,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
|
||||
|
||||
myGenerateUnsignedApk.setSelected(myConfiguration.GENERATE_UNSIGNED_APK);
|
||||
myIncludeTestCodeAndCheckBox.setSelected(myConfiguration.PACK_TEST_CODE);
|
||||
myIncludeAssetsFromLibraries.setSelected(myConfiguration.PACK_ASSETS_FROM_LIBRARIES);
|
||||
myIncludeAssetsFromLibraries.setSelected(myConfiguration.isIncludeAssetsFromLibraries());
|
||||
|
||||
updateAptPanel();
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
|
||||
if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(mavenProject.getPackaging())) {
|
||||
facet.getConfiguration().LIBRARY_PROJECT = true;
|
||||
}
|
||||
facet.getConfiguration().PACK_ASSETS_FROM_LIBRARIES = true;
|
||||
facet.getConfiguration().setIncludeAssetsFromLibraries(true);
|
||||
|
||||
if (hasApkSources) {
|
||||
reportError("'apksources' dependency is deprecated and can be poorly supported by IDE. " +
|
||||
|
||||
Reference in New Issue
Block a user