Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vassiliy Kudryashov
2012-10-12 20:18:38 +04:00
53 changed files with 362 additions and 224 deletions
@@ -263,6 +263,10 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
}
public void addMessage(CompilerMessage msg) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
LOG.info("addMessage: " + msg);
}
Collection<CompilerMessage> messages = myMessages.get(msg.getCategory());
if (messages == null) {
messages = new LinkedHashSet<CompilerMessage>();
@@ -125,6 +125,9 @@ class BuildMessageDispatcher extends SimpleChannelHandler {
}
}
else {
if (ApplicationManager.getApplication().isUnitTestMode()) {
LOG.info("messageReceived: " + builderMessage);
}
handler.handleBuildMessage(ctx.getChannel(), sessionId, builderMessage);
}
break;
@@ -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;
}
@@ -17,7 +17,6 @@ package com.intellij.platform.templates;
import com.intellij.ide.util.newProjectWizard.modes.ImportImlMode;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
@@ -26,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;
@@ -37,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;
@@ -90,7 +91,7 @@ public class ArchivedProjectTemplate implements ProjectTemplate {
@NotNull
@Override
public ProjectBuilder createModuleBuilder() {
public ModuleBuilder createModuleBuilder() {
return new ModuleBuilder() {
@Override
public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException {
@@ -130,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());
}
@@ -16,8 +16,8 @@
package com.intellij.platform.templates;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
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;
@@ -70,9 +70,15 @@ public class EmptyModuleTemplatesFactory implements ProjectTemplatesFactory {
@NotNull
@Override
public ProjectBuilder createModuleBuilder() {
public ModuleBuilder createModuleBuilder() {
return builder;
}
@Nullable
@Override
public ValidationInfo validateSettings() {
return null;
}
};
}
});
@@ -111,6 +111,8 @@ public class TargetElementUtil extends TargetElementUtilBase {
PsiMethod constructor = ((PsiNewExpression)parent).resolveConstructor();
if (constructor != null) {
refElement = constructor;
} else if (refElement instanceof PsiClass && ((PsiClass)refElement).getConstructors().length > 0) {
return null;
}
}
}
@@ -194,10 +196,11 @@ public class TargetElementUtil extends TargetElementUtilBase {
public Collection<PsiElement> getTargetCandidates(final PsiReference reference) {
PsiElement parent = reference.getElement().getParent();
if (parent instanceof PsiMethodCallExpression) {
PsiMethodCallExpression callExpr = (PsiMethodCallExpression)parent;
if (parent instanceof PsiCallExpression) {
PsiCallExpression callExpr = (PsiCallExpression)parent;
boolean allowStatics = false;
PsiExpression qualifier = callExpr.getMethodExpression().getQualifierExpression();
PsiExpression qualifier = callExpr instanceof PsiMethodCallExpression ? ((PsiMethodCallExpression)callExpr).getMethodExpression().getQualifierExpression()
: callExpr instanceof PsiNewExpression ? ((PsiNewExpression)callExpr).getQualifier() : null;
if (qualifier == null) {
allowStatics = true;
}
@@ -538,11 +538,14 @@ public class JavaCompletionData extends JavaAwareCompletionData {
return false;
}
if (psiElement().afterLeaf(
or(
psiElement().withoutText(".").inside(psiElement(PsiModifierList.class).withParent(not(psiElement(PsiParameter.class)))).andNot(
psiElement().inside(PsiAnnotationParameterList.class)),
psiElement().isNull())).accepts(position)) {
PsiElement prev = PsiTreeUtil.prevVisibleLeaf(position);
if (prev == null) {
return true;
}
if (psiElement().withoutText(".").inside(
psiElement(PsiModifierList.class).withParent(
not(psiElement(PsiParameter.class)).andNot(psiElement(PsiParameterList.class)))).accepts(prev) &&
!psiElement().inside(PsiAnnotationParameterList.class).accepts(prev)) {
return true;
}
@@ -1292,7 +1292,7 @@ public class GenericsHighlightUtil {
if (((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) return null;
PsiClass containingClass = ((PsiMember)element).getContainingClass();
if (containingClass != null && PsiUtil.isRawSubstitutor(containingClass, resolveResult.getSubstitutor())) {
if (parent instanceof PsiCallExpression && PsiUtil.isLanguageLevel7OrHigher(parent)) {
if ((parent instanceof PsiCallExpression || parent instanceof PsiMethodReferenceExpression) && PsiUtil.isLanguageLevel7OrHigher(parent)) {
return null;
}
final String message = element instanceof PsiClass
@@ -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();
@@ -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 =
@@ -306,6 +306,8 @@ public class MethodSignatureUtil {
for (PsiClassType superSuper : superTypeParameter.getSuperTypes()) {
superSupers.add(methodSubstitutor.substitute(PsiUtil.captureToplevelWildcards(result.substitute(superSuper), methodTypeParameter)));
}
methodSupers.remove(PsiType.getJavaLangObject(methodTypeParameter.getManager(), methodTypeParameter.getResolveScope()));
superSupers.remove(PsiType.getJavaLangObject(superTypeParameter.getManager(), superTypeParameter.getResolveScope()));
if (!methodSupers.equals(superSupers)) return null;
}
@@ -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;
}
}
}
@@ -0,0 +1,3 @@
public class Util {
void foo(@Foo <caret> int args) { }
}
@@ -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);
}
}
@@ -0,0 +1,17 @@
class Test<T> {
void foo(String p) {}
<U> void foo1(String p) {}
static void foo2(String p) {}
static <U> void foo3(String p) {}
void test() {
Test test = new Test<String>();
BlahBlah<String> blahBlah = test::<String>foo;
BlahBlah<String> blahBlah1 = test::<String>foo1;
BlahBlah<String> blahBlah2 = test::<String>foo2;
BlahBlah<String> blahBlah3 = test::<String>foo3;
}
}
interface BlahBlah<T> {
void bar(T i);
}
@@ -105,6 +105,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); }
public void testReturnInTernary() throws Exception { doTest(1, "return"); }
public void testFinalAfterParameterAnno() throws Exception { doTest(2, "final", "float", "class"); }
public void testFinalAfterParameterAnno2() throws Exception { doTest(2, "final", "float", "class"); }
public void testClassInMethod() throws Exception { doTest(2, "class", "char"); }
public void testIntInClassArray() throws Throwable { doTest(2, "int", "char", "final"); }
public void testIntInClassArray2() throws Throwable { doTest(2, "int", "char", "final"); }
@@ -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);
}
@@ -125,6 +125,10 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testTypeArgumentsOnMethodRefs() throws Exception {
doTest();
}
public void testInferenceFromReturnType() throws Exception {
doTest(true);
}
@@ -109,6 +109,9 @@ final class BuildSession implements Runnable, CanceledStatus {
if (kind == BuildMessage.Kind.ERROR) {
hasErrors.set(true);
}
if (Utils.IS_TEST_MODE) {
LOG.info("Processing message: " + buildMessage);
}
response = CmdlineProtoUtil.createCompileMessage(
kind, text, compilerMessage.getSourcePath(),
compilerMessage.getProblemBeginOffset(), compilerMessage.getProblemEndOffset(),
@@ -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]);
}
}
}
});
@@ -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")
@@ -17,9 +17,13 @@ package com.intellij.ide.util.projectWizard;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.WebModuleType;
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;
@@ -50,10 +54,19 @@ public abstract class WebProjectTemplate<T> extends WebProjectGenerator<T> imple
@NotNull
@Override
public ProjectBuilder createModuleBuilder() {
public ModuleBuilder createModuleBuilder() {
final ModuleBuilder builder = WebModuleType.getInstance().createModuleBuilder();
return new ProjectBuilder() {
@Nullable
return new ModuleBuilder() {
@Override
public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException {
builder.setupRootModel(modifiableRootModel);
}
@Override
public ModuleType getModuleType() {
return builder.getModuleType();
}
@Override
public List<Module> commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) {
List<Module> modules = builder.commit(project, model, modulesProvider);
@@ -65,4 +78,10 @@ public abstract class WebProjectTemplate<T> extends WebProjectGenerator<T> imple
}
};
}
@Nullable
@Override
public ValidationInfo validateSettings() {
return myPeer.getValue().validate();
}
}
@@ -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
@@ -62,8 +62,6 @@ public class LanguageTextField extends EditorTextField {
myProject = project;
setEnabled(language != null);
ShiftTabAction.attachTo(this);
}
public interface DocumentCreator {
@@ -1,70 +0,0 @@
/*
* Copyright 2006 Sascha Weinreuter
*
* 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.ui;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
/**
* Provides Shift-Tab support in EditorTextFields which otherwise don't support this keystroke to
* move the input focus to the previous component.
*/
@SuppressWarnings({"ComponentNotRegistered"})
public class ShiftTabAction extends AnAction {
private static final CustomShortcutSet SHIFT_TAB;
static {
final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
SHIFT_TAB = new CustomShortcutSet(keyStroke);
}
private final EditorTextField myEditor;
private ShiftTabAction(EditorTextField editor) {
super("Shift-Tab");
myEditor = editor;
}
public void actionPerformed(AnActionEvent event) {
Container container = myEditor.getParent();
while (container != null && container.getFocusTraversalPolicy() == null) {
container = container.getParent();
}
if (container != null) {
final FocusTraversalPolicy ftp = container.getFocusTraversalPolicy();
if (ftp != null) {
final Component prev = ftp.getComponentBefore(container, myEditor);
if (prev != null) {
prev.requestFocus();
}
}
}
}
/**
* Call this method to enable Sift-Tab support for the supplied EditorTextField.
*/
public static void attachTo(EditorTextField textField) {
// TODO following code seems not needed due to textField.pleaseHandleShiftTab()
new ShiftTabAction(textField).registerCustomShortcutSet(SHIFT_TAB, textField);
}
}
@@ -283,6 +283,11 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
return myTree.findConfigurable(configurableClass);
}
@Nullable
public SearchableConfigurable findConfigurableById(@NotNull String configurableId) {
return myTree.findConfigurableById(configurableId);
}
public ActionCallback clearSearchAndSelect(Configurable configurable) {
clearFilter();
return select(configurable, "");
@@ -34,6 +34,7 @@ import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -271,6 +272,19 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
return null;
}
@Nullable
public SearchableConfigurable findConfigurableById(@NotNull String configurableId) {
for (Configurable configurable : myConfigurable2Node.keySet()) {
if (configurable instanceof SearchableConfigurable) {
SearchableConfigurable searchableConfigurable = (SearchableConfigurable) configurable;
if (configurableId.equals(searchableConfigurable.getId())) {
return searchableConfigurable;
}
}
}
return null;
}
class Renderer extends GroupedElementsRenderer.Tree {
@@ -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();
@@ -15,7 +15,8 @@
*/
package com.intellij.platform;
import com.intellij.ide.util.projectWizard.ProjectBuilder;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.openapi.ui.ValidationInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,5 +38,11 @@ public interface ProjectTemplate {
JComponent getSettingsPanel();
@NotNull
ProjectBuilder createModuleBuilder();
ModuleBuilder createModuleBuilder();
/**
* @return null if ok, error message otherwise
*/
@Nullable
ValidationInfo validateSettings();
}
@@ -1,7 +1,7 @@
<html>
<body>
This inspection reports any attempts to reflectively check for the presence of an
annotation which is not defined has being retained at runtime.
annotation which is not defined as being retained at runtime.
Using <b>Class.isAnnotationPresent()</b> to test for an annotation
which has source retention or class-file retention (the default) will always result in a negative result,
but is easy to do inadvertently.
@@ -27,7 +27,6 @@ import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.ReferenceEditorWithBrowseButton;
import com.intellij.ui.ShiftTabAction;
import com.intellij.util.Function;
import org.intellij.plugins.intelliLang.util.PsiUtilEx;
import org.jetbrains.annotations.Nls;
@@ -75,7 +74,6 @@ public class AdvancedSettingsUI implements Configurable {
}, myConfiguration.getLanguageAnnotationClass());
myAnnotationField.addActionListener(new BrowseClassListener(project, myAnnotationField));
myAnnotationField.setEnabled(!project.isDefault());
ShiftTabAction.attachTo(myAnnotationField.getEditorTextField());
addField(myLanguageAnnotationPanel, myAnnotationField);
myPatternField = new ReferenceEditorWithBrowseButton(null, project, new Function<String, Document>() {
@@ -85,7 +83,6 @@ public class AdvancedSettingsUI implements Configurable {
}, myConfiguration.getPatternAnnotationClass());
myPatternField.addActionListener(new BrowseClassListener(project, myPatternField));
myPatternField.setEnabled(!project.isDefault());
ShiftTabAction.attachTo(myPatternField.getEditorTextField());
addField(myPatternAnnotationPanel, myPatternField);
mySubstField = new ReferenceEditorWithBrowseButton(null, project, new Function<String, Document>() {
@@ -95,10 +92,9 @@ public class AdvancedSettingsUI implements Configurable {
}, myConfiguration.getPatternAnnotationClass());
mySubstField.addActionListener(new BrowseClassListener(project, mySubstField));
mySubstField.setEnabled(!project.isDefault());
ShiftTabAction.attachTo(mySubstField.getEditorTextField());
addField(mySubstAnnotationPanel, mySubstField);
}
//
/**
* Adds textfield into placeholder panel and assigns a directly preceding label
*/
@@ -26,7 +26,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.ui.ColoredListCellRendererWrapper;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.ShiftTabAction;
import com.intellij.ui.SimpleTextAttributes;
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
@@ -94,9 +93,6 @@ public class LanguagePanel extends AbstractInjectionPanel<BaseInjection> {
public void ancestorMoved(AncestorEvent event) {
}
});
ShiftTabAction.attachTo(myPrefix);
ShiftTabAction.attachTo(mySuffix);
}
private void updateHighlighters() {
@@ -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());
@@ -0,0 +1,9 @@
class Test<T> {
static void foo() {}
}
class Bar {
void test() {
Runnable runnable = Test<String>:<caret>:foo;
}
}
@@ -0,0 +1,9 @@
class Test<T> {
static void foo() {}
}
class Bar {
void test() {
Runnable runnable = () -> Test.foo();
}
}
@@ -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";
@@ -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();
@@ -44,7 +44,7 @@ public interface JpsAndroidModuleExtension extends JpsElement {
boolean isPackTestCode();
boolean isPackAssetsFromLibraries();
boolean isIncludeAssetsFromLibraries();
boolean isRunProcessResourcesMavenTask();
@@ -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
@@ -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>();
@@ -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. " +
@@ -207,26 +207,26 @@ public abstract class GroovyCompilerTest extends GroovyCompilerTestCase {
}
@Override
void runTest() {
def ideaLog = new File(TestLoggerFactory.testLogDir, "idea.log")
def makeLog = new File(PathManager.systemPath, "compile-server/server.log")
if (ideaLog.exists()) {
FileUtil.delete(ideaLog)
}
if (makeLog.exists()) {
FileUtil.delete(makeLog)
}
void runBare() {
new File(TestLoggerFactory.testLogDir, "idea.log").delete()
new File(PathManager.systemPath, "compile-server/server.log").delete()
super.runBare()
}
@Override
void runTest() {
try {
super.runTest()
}
catch (Throwable e) {
def ideaLog = new File(TestLoggerFactory.testLogDir, "idea.log")
if (ideaLog.exists()) {
//println "Idea Log:"
//println ideaLog.text
println "\n\nIdea Log:"
println ideaLog.text
}
def makeLog = new File(PathManager.systemPath, "compile-server/server.log")
if (makeLog.exists()) {
println "Server Log:"
println "\n\nServer Log:"
println makeLog.text
}
throw e
+1
View File
@@ -19,6 +19,7 @@
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/axis-1.4.jar!/" />
<root url="jar://$MODULE_DIR$/lib/axis-jaxrpc-1.4.jar!/" />
<root url="jar://$MODULE_DIR$/lib/wsdl4j-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
@@ -19,9 +19,8 @@ public class MantisIntegrationTest extends TaskManagerTestCase {
public void testMantis12() throws Exception {
MantisRepository mantisRepository = new MantisRepository(new MantisRepositoryType());
mantisRepository.setUrl("http://trackers-tests.labs.intellij.net:8142/");
mantisRepository.setUsername("guest");
mantisRepository.setPassword("guest");
myManager.testConnection(mantisRepository);
mantisRepository.setUsername("deva");
mantisRepository.setPassword("deva");
assertTrue(mantisRepository.getProjects().size() >= 2);
final MantisProject mantisProject = mantisRepository.getProjects().get(1);