Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vladimir Orlov
2014-02-12 15:36:04 +04:00
64 changed files with 489 additions and 302 deletions
+1
View File
@@ -63,6 +63,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/gradle.iml" filepath="$PROJECT_DIR$/plugins/gradle/gradle.iml" group="community/plugins/gradle" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension/gradle-tooling-extension.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension/gradle-tooling-extension.iml" group="community/plugins/gradle" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension-v1.11/gradle-tooling-extension-v1.11.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension-v1.11/gradle-tooling-extension-v1.11.iml" group="community/plugins/gradle" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension-v1.12/gradle-tooling-extension-v1.12.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension-v1.12/gradle-tooling-extension-v1.12.iml" group="community/plugins/gradle" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension-v1.9/gradle-tooling-extension-v1.9.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension-v1.9/gradle-tooling-extension-v1.9.iml" group="community/plugins/gradle" />
<module fileurl="file://$PROJECT_DIR$/plugins/groovy/jps-plugin/groovy-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/groovy/jps-plugin/groovy-jps-plugin.iml" group="plugins/Groovy" />
<module fileurl="file://$PROJECT_DIR$/plugins/groovy/rt-constants/groovy-rt-constants.iml" filepath="$PROJECT_DIR$/plugins/groovy/rt-constants/groovy-rt-constants.iml" group="plugins/Groovy" />
@@ -58,7 +58,7 @@ public class ChooseTemplateStep extends ModuleWizardStep {
@Override
public boolean isStepVisible() {
return !myProjectTypeStep.getAvailableTemplates().isEmpty();
return myWizardContext.isCreatingNewProject() && !myProjectTypeStep.getAvailableTemplates().isEmpty();
}
@Override
@@ -20,10 +20,7 @@ import com.intellij.ide.DataManager;
import com.intellij.ide.util.treeView.AbstractTreeStructure;
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
@@ -53,8 +50,10 @@ import com.intellij.ui.AnActionButtonRunnable;
import com.intellij.ui.ToolbarDecorator;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IconUtil;
import com.intellij.util.PathUtil;
import com.intellij.util.containers.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.FilteringIterator;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -156,48 +155,15 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
myTreePanel.setLayout(new BorderLayout());
ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myTree).disableUpDownActions()
.setRemoveActionName(ProjectBundle.message("library.detach.action"))
.setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final Object[] selectedElements = getSelectedElements();
if (selectedElements.length == 0) {
return;
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
for (Object selectedElement : selectedElements) {
if (selectedElement instanceof ItemElement) {
final ItemElement itemElement = (ItemElement)selectedElement;
getLibraryEditor().removeRoot(itemElement.getUrl(), itemElement.getRootType());
}
else if (selectedElement instanceof OrderRootTypeElement) {
final OrderRootType rootType = ((OrderRootTypeElement)selectedElement).getOrderRootType();
final String[] urls = getLibraryEditor().getUrls(rootType);
for (String url : urls) {
getLibraryEditor().removeRoot(url, rootType);
}
}
else if (selectedElement instanceof ExcludedRootElement) {
getLibraryEditor().removeExcludedRoot(((ExcludedRootElement)selectedElement).getUrl());
}
}
}
});
libraryChanged(true);
}
});
.setRemoveActionName(ProjectBundle.message("library.remove.action"))
.disableRemoveAction();
List<String> actionsOrder = new ArrayList<String>();
actionsOrder.add("Add");
final List<AttachRootButtonDescriptor> popupItems = new ArrayList<AttachRootButtonDescriptor>();
for (AttachRootButtonDescriptor descriptor : myDescriptor.createAttachButtons()) {
Icon icon = descriptor.getToolbarIcon();
if (icon != null) {
AttachItemAction action = new AttachItemAction(descriptor, descriptor.getButtonText(), icon);
toolbarDecorator.addExtraAction(AnActionButton.fromAction(action));
actionsOrder.add(action.getTemplatePresentation().getText());
}
else {
popupItems.add(descriptor);
@@ -205,9 +171,55 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
}
myAddExcludedRootActionButton = new AddExcludedRootActionButton();
toolbarDecorator.addExtraAction(myAddExcludedRootActionButton);
actionsOrder.add(myAddExcludedRootActionButton.getTemplatePresentation().getText());
actionsOrder.add("Remove");
toolbarDecorator.addExtraAction(new AnActionButton("Remove", IconUtil.getRemoveIcon()) {
@Override
public void actionPerformed(AnActionEvent e) {
final Object[] selectedElements = getSelectedElements();
if (selectedElements.length == 0) {
return;
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
for (Object selectedElement : selectedElements) {
if (selectedElement instanceof ItemElement) {
final ItemElement itemElement = (ItemElement)selectedElement;
getLibraryEditor().removeRoot(itemElement.getUrl(), itemElement.getRootType());
}
else if (selectedElement instanceof OrderRootTypeElement) {
final OrderRootType rootType = ((OrderRootTypeElement)selectedElement).getOrderRootType();
final String[] urls = getLibraryEditor().getUrls(rootType);
for (String url : urls) {
getLibraryEditor().removeRoot(url, rootType);
}
}
else if (selectedElement instanceof ExcludedRootElement) {
getLibraryEditor().removeExcludedRoot(((ExcludedRootElement)selectedElement).getUrl());
}
}
}
});
libraryChanged(true);
}
@Override
public void updateButton(AnActionEvent e) {
super.updateButton(e);
Object[] elements = getSelectedElements();
Presentation presentation = e.getPresentation();
if (ContainerUtil.and(elements, new FilteringIterator.InstanceOf<ExcludedRootElement>(ExcludedRootElement.class))) {
presentation.setText("Cancel Exclusion");
}
else {
presentation.setText(getTemplatePresentation().getText());
}
}
@Override
public ShortcutSet getShortcut() {
return CommonShortcuts.DELETE;
}
});
toolbarDecorator.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
@@ -228,7 +240,6 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
.show(button.getPreferredPopupPoint());
}
});
toolbarDecorator.setButtonComparator(ArrayUtil.toStringArray(actionsOrder));
myTreePanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
Disposer.register(this, myTreeBuilder);
@@ -511,13 +522,13 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
private class AddExcludedRootActionButton extends AnActionButton {
public AddExcludedRootActionButton() {
super("Add Excluded", null, AllIcons.Modules.ExcludeRoot);
super("Exclude", null, AllIcons.Modules.AddExcludedRoot);
}
@Override
public void actionPerformed(AnActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
descriptor.setTitle("Add Excluded Roots");
descriptor.setTitle("Exclude from Library");
descriptor.setDescription("Select directories which should be excluded from the library content. Content of excluded directories won't be processed by IDE.");
Set<VirtualFile> roots = getNotExcludedRoots();
descriptor.setRoots(roots.toArray(new VirtualFile[roots.size()]));
@@ -20,7 +20,10 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementFactory;
import com.intellij.psi.PsiExpression;
import org.jetbrains.annotations.NotNull;
/**
@@ -46,7 +49,7 @@ public abstract class NullCheckPostfixTemplate extends PostfixTemplate {
Project project = expr.getProject();
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
PsiBinaryExpression condition = (PsiBinaryExpression)factory.createExpressionFromText(expr.getText() + getTail(), context);
PsiExpression condition = factory.createExpressionFromText(expr.getText() + getTail(), context);
PsiElement replace = expr.replace(condition);
assert replace instanceof PsiExpression;
@@ -53,12 +53,47 @@ public class InferenceIncorporationPhase {
final List<PsiType> lowerBounds = inferenceVariable.getBounds(InferenceBound.LOWER);
eqEq(eqBounds);
upperLower(upperBounds, lowerBounds);
upDown(lowerBounds, upperBounds);
upDown(eqBounds, upperBounds);
upDown(lowerBounds, eqBounds);
upUp(upperBounds);
for (PsiType eqBound : eqBounds) {
if (mySession.isProperType(eqBound)) {
final PsiSubstitutor substitutor = PsiSubstitutor.EMPTY.put(inferenceVariable.getParameter(), eqBound);
for (PsiType upperBound : upperBounds) {
if (!mySession.isProperType(upperBound)) {
addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), eqBound));
}
}
for (PsiType lowerBound : lowerBounds) {
if (!mySession.isProperType(lowerBound)) {
addConstraint(new StrictSubtypingConstraint(eqBound, substitutor.substitute(lowerBound)));
}
}
for (PsiType otherEqBound : eqBounds) {
if (eqBound != otherEqBound && !mySession.isProperType(otherEqBound)) {
addConstraint(new TypeEqualityConstraint(substitutor.substitute(otherEqBound), eqBound));
}
}
}
}
//todo no such a rule in spec?!
for (PsiType lowerBound : lowerBounds) {
if (mySession.isProperType(lowerBound)) {
final PsiSubstitutor substitutor = PsiSubstitutor.EMPTY.put(inferenceVariable.getParameter(), lowerBound);
for (PsiType upperBound : upperBounds) {
if (!mySession.isProperType(upperBound)) {
addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), lowerBound));
}
}
}
}
}
if (myCapture != null) {
@@ -219,24 +254,19 @@ public class InferenceIncorporationPhase {
* a = S & a <: T imply S <: T
* or
* a = S & T <: a imply T <: S
* or
* S <: a & a <: T imply S <: T
*/
private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds) {
for (PsiType upperBound : upperBounds) {
if (upperBound == null) continue;
for (PsiType eqBound : eqBounds) {
addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
if (mySession.isProperType(upperBound)) {
continue;
}
}
}
/**
* S <: a & a <: T imply S <: T
*/
private void upperLower(List<PsiType> upperBounds, List<PsiType> lowerBounds) {
for (PsiType upperBound : upperBounds) {
if (upperBound == null) continue;
for (PsiType lowerBound : lowerBounds) {
addConstraint(new StrictSubtypingConstraint(upperBound, lowerBound));
for (PsiType eqBound : eqBounds) {
if (mySession.isProperType(eqBound)) {
continue;
}
addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
}
}
}
@@ -247,10 +277,14 @@ public class InferenceIncorporationPhase {
private void eqEq(List<PsiType> eqBounds) {
for (int i = 0; i < eqBounds.size(); i++) {
PsiType sBound= eqBounds.get(i);
if (sBound == null) continue;
if (mySession.isProperType(sBound)) {
continue;
}
for (int j = i + 1; j < eqBounds.size(); j++) {
final PsiType tBound = eqBounds.get(j);
if (tBound == null) continue;
if (mySession.isProperType(tBound)) {
continue;
}
addConstraint(new TypeEqualityConstraint(tBound, sBound));
}
}
@@ -268,8 +302,10 @@ public class InferenceIncorporationPhase {
public boolean process(Pair<PsiType, PsiType> pair) {
final PsiType sType = pair.first;
final PsiType tType = pair.second;
if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
addConstraint(new TypeEqualityConstraint(sType, tType));
if (!mySession.isProperType(sType) && !mySession.isProperType(tType)) {
if (!(sType instanceof PsiWildcardType) && !(tType instanceof PsiWildcardType) && sType != null && tType != null) {
addConstraint(new TypeEqualityConstraint(sType, tType));
}
}
return true;
}
@@ -208,8 +208,10 @@ public class InferenceSession {
@Nullable PsiElement parent,
boolean acceptNonPertinentArgs,
ParameterTypeInferencePolicy policy) {
boolean doesNotContainFalseBound = repeatInferencePhases(parameters == null || !policy.allowPostponeInference());
// if (!doesNotContainFalseBound) return prepareSubstitution();
if (!repeatInferencePhases(parameters == null || !policy.allowPostponeInference())) {
return prepareSubstitution();
}
resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference());
@@ -219,8 +221,9 @@ public class InferenceSession {
for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
inferenceVariable.ignoreInstantiation();
}
doesNotContainFalseBound = repeatInferencePhases(true);
// if (!doesNotContainFalseBound) return prepareSubstitution();
if (!repeatInferencePhases(true)) {
return prepareSubstitution();
}
PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor, !policy.allowPostponeInference());
LOG.assertTrue(parent != null);
@@ -247,8 +250,9 @@ public class InferenceSession {
for (InferenceVariable inferenceVariable : myInferenceVariables.values()) {
inferenceVariable.ignoreInstantiation();
}
doesNotContainFalseBound = proceedWithAdditionalConstraints(additionalConstraints);
// if (!doesNotContainFalseBound) return prepareSubstitution();
if (!proceedWithAdditionalConstraints(additionalConstraints)) {
//return prepareSubstitution();
}
}
}
@@ -584,6 +588,13 @@ public class InferenceSession {
}
public boolean repeatInferencePhases(boolean incorporate) {
do {
if (!reduceConstraints()) {
//inference error occurred
return false;
}
} while (myConstraintIdx < myConstraints.size());
do {
if (!reduceConstraints()) {
//inference error occurred
@@ -753,50 +764,9 @@ public class InferenceSession {
private boolean proceedWithAdditionalConstraints(Set<ConstraintFormula> additionalConstraints) {
while (!additionalConstraints.isEmpty()) {
final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
for (ConstraintFormula constraint : additionalConstraints) {
if (constraint instanceof InputOutputConstraintFormula) {
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
final Set<InferenceVariable> outputVars = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this);
if (outputVars != null) {
outputVariables.addAll(outputVars);
}
}
}
Set<ConstraintFormula> subset = new HashSet<ConstraintFormula>();
final Set<InferenceVariable> varsToResolve = new HashSet<InferenceVariable>();
for (ConstraintFormula constraint : additionalConstraints) {
if (constraint instanceof InputOutputConstraintFormula) {
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
if (inputVariables != null) {
boolean dependsOnOutput = false;
for (InferenceVariable inputVariable : inputVariables) {
final Set<InferenceVariable> dependencies = inputVariable.getDependencies(this);
dependencies.add(inputVariable);
dependencies.retainAll(outputVariables);
if (!dependencies.isEmpty()) {
dependsOnOutput = true;
break;
}
}
if (!dependsOnOutput) {
subset.add(constraint);
varsToResolve.addAll(inputVariables);
}
}
else {
subset.add(constraint);
}
}
else {
subset.add(constraint);
}
}
if (subset.isEmpty()) {
subset = Collections.singleton(additionalConstraints.iterator().next()); //todo choose one constraint
}
final Set<InferenceVariable> varsToResolve = new HashSet<InferenceVariable>();
additionalConstraints.removeAll(subset);
final Set<ConstraintFormula> subset = buildSubset(additionalConstraints, varsToResolve);
PsiSubstitutor substitutor = resolveBounds(varsToResolve, mySiteSubstitutor, true);
@@ -819,6 +789,56 @@ public class InferenceSession {
return true;
}
private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints,
final Set<InferenceVariable> varsToResolve) {
final Set<ConstraintFormula> subset = new HashSet<ConstraintFormula>();
final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
for (ConstraintFormula constraint : additionalConstraints) {
if (constraint instanceof InputOutputConstraintFormula) {
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
final Set<InferenceVariable> outputVars = ((InputOutputConstraintFormula)constraint).getOutputVariables(inputVariables, this);
if (outputVars != null) {
outputVariables.addAll(outputVars);
}
}
}
for (ConstraintFormula constraint : additionalConstraints) {
if (constraint instanceof InputOutputConstraintFormula) {
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)constraint).getInputVariables(this);
if (inputVariables != null) {
boolean dependsOnOutput = false;
for (InferenceVariable inputVariable : inputVariables) {
final Set<InferenceVariable> dependencies = inputVariable.getDependencies(this);
dependencies.add(inputVariable);
dependencies.retainAll(outputVariables);
if (!dependencies.isEmpty()) {
dependsOnOutput = true;
break;
}
}
if (!dependsOnOutput) {
subset.add(constraint);
varsToResolve.addAll(inputVariables);
}
}
else {
subset.add(constraint);
}
}
else {
subset.add(constraint);
}
}
if (subset.isEmpty()) {
subset.add(additionalConstraints.iterator().next()); //todo choose one constraint
}
additionalConstraints.removeAll(subset);
return subset;
}
public void setErased() {
myErased = true;
}
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.source.tree.java;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerEx;
@@ -437,6 +438,13 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
if (interfaceMethod == null) return substitutor;
final PsiSubstitutor qualifierResultSubstitutor = qualifierResolveResult.getSubstitutor();
final InferenceSession session = new InferenceSession(method.getTypeParameters(), substitutor, getManager(), reference);
//lift parameters from outer call
final Pair<PsiMethod,PsiSubstitutor> methodSubstitutorPair = MethodCandidateInfo.getCurrentMethod(reference.getParent());
if (methodSubstitutorPair != null) {
session.initBounds(methodSubstitutorPair.first.getTypeParameters());
}
final PsiParameter[] functionalMethodParameters = interfaceMethod.getParameterList().getParameters();
final PsiParameter[] parameters = method.getParameterList().getParameters();
final boolean isStatic = method.hasModifierProperty(PsiModifier.STATIC);
@@ -4,7 +4,7 @@ class A<T> {
}
void bar(A<?> x){
baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
baz<error descr="'baz(A<A<? extends S>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
}
<S> void baz(A<A<? extends S>> x){}
@@ -2,6 +2,6 @@ class A<T> {
<T extends A<T>> void foo(T x){}
void bar(A<?> x){
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'A<capture<? extends A<capture<?>>>>'">foo(x)</error>;
foo<error descr="'foo(T)' in 'A' cannot be applied to '(A<capture<?>>)'">(x)</error>;
}
}
@@ -17,15 +17,15 @@ class B<T> extends A<A<T>> {
foo2(sb);
foo2(s);
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo5(b);
foo5(eb);
@@ -11,6 +11,6 @@ abstract class A1{
abstract <T> T baz(List<? super T> a);
void bar(List<?> x){
String o = baz<error descr="'baz(java.util.List<? super java.lang.Object>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
String o = baz<error descr="'baz(java.util.List<? super T>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
}
}
@@ -4,6 +4,6 @@ abstract class A {
abstract <T> T baz(List<? super List<? super T>> a);
void bar(C<?> x){
baz<error descr="'baz(java.util.List<? super java.util.List<? super java.lang.Object>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
baz<error descr="'baz(java.util.List<? super java.util.List<? super T>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
}
}
@@ -1,6 +1,6 @@
class C<T extends C<? extends C<? extends T>>>{
void foo(C<?> x){
<error descr="Inferred type 'capture<? extends C<? extends C<capture<?>>>>' for type parameter 'T' is not within its bound; should extend 'C<capture<? extends C<? extends C<capture<?>>>>>'">bar(x)</error>;
bar<error descr="'bar(C<T>)' in 'C' cannot be applied to '(C<capture<?>>)'">(x)</error>;
}
<T extends C<? extends T>> void bar(C<T> x){}
}
@@ -8,8 +8,8 @@ abstract class B {
void bar(List<List<?>> x, List<List<List<?>>> y){
foo(x) [0] = "";
foo1<error descr="'foo1(java.util.List<? extends java.util.List<java.lang.Object>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<java.lang.Object>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
foo1<error descr="'foo1(java.util.List<? extends java.util.List<T>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<T>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
String s = foo0(x);
}
@@ -8,7 +8,7 @@ public class GenericsTest98 {
List<Movable<? extends Serializable>> list = new ArrayList<Movable<? extends Serializable>> ();
Factory factory = Factory.newInstance();
// Doesn't compile, but Idea doesn't complain
Mover<? extends Serializable> mover = factory.getNew<error descr="'getNew(java.util.List<? extends Movable<java.io.Serializable>>)' in 'Factory' cannot be applied to '(java.util.List<Movable<? extends java.io.Serializable>>)'">(list)</error>;
Mover<? extends Serializable> mover = factory.getNew<error descr="'getNew(java.util.List<? extends Movable<T>>)' in 'Factory' cannot be applied to '(java.util.List<Movable<? extends java.io.Serializable>>)'">(list)</error>;
}
}
@@ -1,6 +1,6 @@
class D<T> {
void foo(D<?> x){
bar<error descr="'bar(D<?>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
bar<error descr="'bar(D<? extends T>, D<? super T>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
}
<T> void bar(D<? extends T> x, D<? super T> y){}
}
@@ -87,7 +87,7 @@ class CaptureTest {
}
void foo (Class<? extends Emum<CaptureTest>> clazz) {
<error descr="Inferred type 'capture<? extends CaptureTest.Emum<CaptureTest>>' for type parameter 'T' is not within its bound; should extend 'CaptureTest.Emum<capture<? extends CaptureTest.Emum<CaptureTest>>>'">Emum.valueOf(clazz, "CCC")</error>;
Emum.valueOf<error descr="'valueOf(java.lang.Class<T>, java.lang.String)' in 'CaptureTest.Emum' cannot be applied to '(java.lang.Class<capture<? extends CaptureTest.Emum<CaptureTest>>>, java.lang.String)'">(clazz, "CCC")</error>;
}
}
@@ -182,7 +182,7 @@ class TypeBug {
multiList.add(intHolder);
multiList.add(doubleHolder);
swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<java.lang.Object>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<T>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
// this line causes a ClassCastException when checked.
Integer value = intHolder.value;
@@ -10,6 +10,6 @@ class Node<NodeTypeT extends NodeType> {
class Main {
public static void main(NodeProperty<NumberExpression, Integer> nval, Node<? extends NodeType> expr) {
int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,java.lang.Object>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,ValueT>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
}
}
@@ -29,7 +29,7 @@ public class ConcurrentCollectors {
static <T, K, D, M1 extends Map<K, D>> C<T, M1> groupingBy(F<M1> f,
C<T, D> c,
BiConsumer<M1, T> consumer) {
return new CImpl<><error descr="'CImpl(ConcurrentCollectors.F<M1>, ConcurrentCollectors.BiConsumer<M1,T>, ConcurrentCollectors.BiOp<M1>)' in 'ConcurrentCollectors.CImpl' cannot be applied to '(ConcurrentCollectors.F<M1>, ConcurrentCollectors.BiConsumer<M1,T>, ConcurrentCollectors.BiOp<ConcurrentCollectors.ConcurrentMap<java.lang.Object,D>>)'">(f, consumer, arg(c.getOp()))</error>;
return new CImpl<><error descr="'CImpl(ConcurrentCollectors.F<R>, ConcurrentCollectors.BiConsumer<R,T>, ConcurrentCollectors.BiOp<R>)' in 'ConcurrentCollectors.CImpl' cannot be applied to '(ConcurrentCollectors.F<M1>, ConcurrentCollectors.BiConsumer<M1,T>, ConcurrentCollectors.BiOp<ConcurrentCollectors.ConcurrentMap<java.lang.Object,D>>)'">(f, consumer, arg(c.getOp()))</error>;
}
static <K, V, M2 extends ConcurrentMap<K, V>> BiOp<M2> arg(BiOp<V> op) {
@@ -13,7 +13,7 @@ class Foo<R> {
public void foo() {
reduce(Moo::new);
<error descr="Inferred type 'Foo<R>.AMoo' for type parameter 'S' is not within its bound; should implement 'Foo.ASink<java.lang.Object,Foo<R>.AMoo>'">reduce(AMoo::new)</error>;
reduce(<error descr="Cyclic inference">AMoo::new</error>);
reduce(AAMoo::new);
reduce(AAAMoo::new);
}
@@ -34,7 +34,7 @@ class Test1111 {
}
public void test(I<?> i) {
bar<error descr="'bar(Test1111.I<? super java.lang.Object>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
bar<error descr="'bar(Test1111.I<? super A>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
}
public static <A> void bar(I<? super A> i) {}
@@ -77,7 +77,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
public void testInferenceWithUpperBoundPromotion() {
doTest();
}
public void testVariance() {
public void _testVariance() { //todo waiting for capture bound
doTest();
}
public void testForeachTypes() {
@@ -88,7 +88,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testCapturedReturnTypes() throws Exception {
public void _testCapturedReturnTypes() throws Exception {//todo waiting for capture incorporation
doTest();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

@@ -108,8 +108,8 @@ public class LayoutProjectCodeDialog extends DialogWrapper implements ReformatFi
super.doOKAction();
if (mySuggestOptimizeImports) {
PropertiesComponent.getInstance().setValue(LayoutCodeConstants.OPTIMIZE_IMPORTS_KEY, Boolean.toString(isOptimizeImports()));
LayoutCodeSettingsStorage.saveRearrangeEntriesOptionFor(myProject, isRearrangeEntries());
}
LayoutCodeSettingsStorage.saveRearrangeEntriesOptionFor(myProject, isRearrangeEntries());
}
public boolean isOptimizeImports() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class RunDialog extends DialogWrapper implements RunConfigurable.RunDialo
private final Project myProject;
private final RunConfigurable myConfigurable;
private JComponent myCenterPanel;
@NonNls public static String HELP_ID = "reference.dialogs.rundebug";
@NonNls public static final String HELP_ID = "reference.dialogs.rundebug";
private final Executor myExecutor;
public RunDialog(final Project project, final Executor executor) {
@@ -205,7 +205,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
private static FindUsagesOptions getDefaultOptions(@NotNull FindUsagesHandler handler) {
FindUsagesOptions options = handler.getFindUsagesOptions(DataManager.getInstance().getDataContext());
// by default, scope in FindUsagesOptions is copied from the FindSettings, but we need a default one
//options.searchScope = FindUsagesManager.getMaximalScope(handler);
options.searchScope = GlobalSearchScope.projectScope(handler.getProject());
return options;
}
@@ -200,14 +200,6 @@ public class FindUsagesManager implements JDOMExternalizable {
}
public void findUsages(@NotNull PsiElement psiElement, final PsiFile scopeFile, final FileEditor editor, boolean showDialog) {
doShowDialogAndStartFind(psiElement, scopeFile, editor, showDialog, false);
}
private void doShowDialogAndStartFind(@NotNull PsiElement psiElement,
PsiFile scopeFile,
FileEditor editor,
boolean showDialog,
boolean useMaximalScope) {
FindUsagesHandler handler = getNewFindUsagesHandler(psiElement, false);
if (handler == null) return;
@@ -224,8 +216,8 @@ public class FindUsagesManager implements JDOMExternalizable {
setOpenInNewTab(dialog.isShowInSeparateWindow());
FindUsagesOptions findUsagesOptions = dialog.calcFindUsagesOptions();
if (!showDialog && useMaximalScope) {
findUsagesOptions.searchScope = getMaximalScope(handler);
if (!showDialog) {
findUsagesOptions.searchScope = GlobalSearchScope.projectScope(myProject);
}
clearFindingNextUsageInFile();
@@ -282,34 +274,6 @@ public class FindUsagesManager implements JDOMExternalizable {
}
}
public boolean isUsed(@NotNull PsiElement element, @NotNull FindUsagesOptions findUsagesOptions) {
FindUsagesHandler handler = getFindUsagesHandler(element, true);
if (handler == null) return false;
UsageSearcher usageSearcher = createUsageSearcher(new PsiElement[]{element}, PsiElement.EMPTY_ARRAY, handler, findUsagesOptions, null);
final AtomicBoolean used = new AtomicBoolean();
usageSearcher.generate(new Processor<Usage>() {
@Override
public boolean process(final Usage usage) {
if (isInComment(usage)) return true;
used.set(true);
return false;
}
});
return used.get();
}
private static boolean isInComment(@NotNull Usage usage) {
if (!(usage instanceof UsageInfo2UsageAdapter)) return false;
UsageInfo usageInfo = ((UsageInfo2UsageAdapter)usage).getUsageInfo();
if (!usageInfo.isNonCodeUsage()) return false;
SmartPsiFileRange psiRangePointer = usageInfo.getPsiFileRange();
if (psiRangePointer == null) return false;
Segment range = psiRangePointer.getRange();
PsiFile file = psiRangePointer.getContainingFile();
if (file == null || range == null) return false;
PsiElement element = file.findElementAt(range.getStartOffset());
return element instanceof PsiComment;
}
@NotNull
public static ProgressIndicator startProcessUsages(@NotNull FindUsagesHandler handler,
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.module.Module;
@@ -31,6 +32,7 @@ import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packageDependencies.ChangeListsScopesProvider;
import com.intellij.packageDependencies.DependencyValidationManager;
@@ -110,7 +112,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
addActionListener(createScopeChooserListener());
final JComboBox combo = getComboBox();
combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer(combo.getRenderer()));
combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer());
rebuildModel();
@@ -174,7 +176,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
model.addElement(new ScopeSeparator("VCS Scopes"));
final List<NamedScope> changeLists = ChangeListsScopesProvider.getInstance(myProject).getCustomScopes();
for (NamedScope changeListScope : changeLists) {
final GlobalSearchScope scope = GlobalSearchScopes.filterScope(myProject, changeListScope);
final GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(myProject, changeListScope);
model.addElement(new ScopeDescriptor(scope));
}
@@ -183,7 +185,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
for (NamedScopesHolder holder : holders) {
final NamedScope[] scopes = holder.getEditableScopes(); // predefined scopes already included
for (NamedScope scope : scopes) {
final GlobalSearchScope searchScope = GlobalSearchScopes.filterScope(myProject, scope);
final GlobalSearchScope searchScope = GlobalSearchScopesCore.filterScope(myProject, scope);
customScopes.add(new ScopeDescriptor(searchScope));
}
}
@@ -240,8 +242,8 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
}
if (!PlatformUtils.isCidr() && ModuleUtil.isSupportedRootType(project, JavaSourceRootType.TEST_SOURCE)) { // TODO: fix these scopes in AppCode
result.add(GlobalSearchScopes.projectProductionScope(project));
result.add(GlobalSearchScopes.projectTestScope(project));
result.add(GlobalSearchScopesCore.projectProductionScope(project));
result.add(GlobalSearchScopesCore.projectTestScope(project));
}
result.add(GlobalSearchScopes.openFilesScope(project));
@@ -273,17 +275,21 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
if (selectedTextEditor != null) {
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(selectedTextEditor.getDocument());
if (psiFile != null) {
if (selectedTextEditor.getSelectionModel().hasSelection()) {
final PsiElement startElement = psiFile.findElementAt(selectedTextEditor.getSelectionModel().getSelectionStart());
SelectionModel selectionModel = selectedTextEditor.getSelectionModel();
if (selectionModel.hasSelection()) {
int start = selectionModel.getSelectionStart();
final PsiElement startElement = psiFile.findElementAt(start);
if (startElement != null) {
final PsiElement endElement = psiFile.findElementAt(selectedTextEditor.getSelectionModel().getSelectionEnd());
int end = selectionModel.getSelectionEnd();
final PsiElement endElement = psiFile.findElementAt(end);
if (endElement != null) {
final PsiElement parent = PsiTreeUtil.findCommonParent(startElement, endElement);
if (parent != null) {
final List<PsiElement> elements = new ArrayList<PsiElement>();
final PsiElement[] children = parent.getChildren();
TextRange selection = new TextRange(start, end);
for (PsiElement child : children) {
if (!(child instanceof PsiWhiteSpace) && child.getContainingFile() != null) {
if (!(child instanceof PsiWhiteSpace) && child.getContainingFile() != null && selection.contains(child.getTextOffset())) {
elements.add(child);
}
}
@@ -445,10 +451,6 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
}
private static class ScopeDescriptionWithDelimiterRenderer extends ListCellRendererWrapper<ScopeDescriptor> {
public ScopeDescriptionWithDelimiterRenderer(final ListCellRenderer original) {
super();
}
@Override
public void customize(JList list, ScopeDescriptor value, int index, boolean selected, boolean hasFocus) {
setText(value.getDisplay());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@ public abstract class ActionPlaces {
public static final String PHING_EXPLORER_POPUP = "PhingExplorerPopup";
public static final String PHING_EXPLORER_TOOLBAR = "PhingExplorerToolbar";
public static final String DOCK_MENU = "DockMenu";
public static String PHING_MESSAGES_TOOLBAR = "PhingMessagesToolbar";
public static final String PHING_MESSAGES_TOOLBAR = "PhingMessagesToolbar";
public static final String CHANGES_LOCAL_DIFF_SETTINGS = "CHANGES_LOCAL_DIFF_SETTINGS";
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.intellij.ui.components.labels.LinkListener;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.PlatformColors;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@@ -32,8 +32,7 @@ import java.beans.PropertyChangeListener;
import java.util.Map;
import java.util.Set;
public class Banner extends NonOpaquePanel implements PropertyChangeListener{
class Banner extends NonOpaquePanel implements PropertyChangeListener{
private int myBannerMinHeight;
private final JComponent myText = new MyText();
@@ -53,6 +52,7 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{
public void addAction(final Action action) {
action.addPropertyChangeListener(this);
final LinkLabel label = new LinkLabel(null, null, new LinkListener() {
@Override
public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
action.actionPerformed(new ActionEvent(Banner.this, ActionEvent.ACTION_PERFORMED, Action.ACTION_COMMAND_KEY));
}
@@ -75,10 +75,11 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{
label.setToolTipText((String)action.getValue(Action.SHORT_DESCRIPTION));
}
@Override
public void propertyChange(final PropertyChangeEvent evt) {
final Object source = evt.getSource();
if (source instanceof Action) {
updateAction(((Action)source));
updateAction((Action)source);
}
}
@@ -91,12 +92,14 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{
myActionsPanel.removeAll();
}
@Override
public Dimension getMinimumSize() {
final Dimension size = super.getMinimumSize();
size.height = Math.max(myBannerMinHeight, size.height);
return size;
}
@Override
public Dimension getPreferredSize() {
final Dimension size = super.getPreferredSize();
size.height = getMinimumSize().height;
@@ -109,19 +112,17 @@ public class Banner extends NonOpaquePanel implements PropertyChangeListener{
repaint();
}
public void setText(@Nullable final String... text) {
public void setText(@NotNull final String... text) {
myText.removeAll();
if (text == null) return;
for (int i = 0; i < text.length; i++) {
final JLabel eachLabel = new JLabel(text[i], JLabel.CENTER);
final JLabel eachLabel = new JLabel(text[i], SwingConstants.CENTER);
final int gap = eachLabel.getIconTextGap();
eachLabel.setBorder(new EmptyBorder(0, 0, 0, gap));
eachLabel.setVerticalTextPosition(JLabel.TOP);
eachLabel.setVerticalTextPosition(SwingConstants.TOP);
eachLabel.setFont(eachLabel.getFont().deriveFont(Font.BOLD, eachLabel.getFont().getSize()));
myText.add(eachLabel);
if (i < text.length - 1) {
final JLabel eachIcon = new JLabel(AllIcons.General.ComboArrowRight, JLabel.CENTER);
final JLabel eachIcon = new JLabel(AllIcons.General.ComboArrowRight, SwingConstants.CENTER);
eachIcon.setBorder(new EmptyBorder(0, 0, 0, gap));
myText.add(eachIcon);
}
@@ -54,14 +54,13 @@ public class DetailsComponent {
public DetailsComponent() {
myComponent = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(final Graphics g) {
if (NullableComponent.Check.isNull(myContent) || !myDetailsEnabled) return;
GraphicsConfig c = new GraphicsConfig(g);
c.setAntialiasing(true);
int arc = 8;
Insets insets = getInsets();
if (insets == null) {
insets = new Insets(0, 0, 0, 0);
@@ -78,6 +77,7 @@ public class DetailsComponent {
final int rightY = banner.y + banner.height;
header.moveTo(leftX, rightY);
int arc = 8;
header.lineTo(leftX, leftY + arc);
header.quadTo(leftX, leftY, leftX + arc, leftY);
header.lineTo(rightX - arc, leftY);
@@ -111,7 +111,7 @@ public class DetailsComponent {
myBanner.add(myBannerLabel, BorderLayout.CENTER);
myEmptyContentLabel = new JLabel("", JLabel.CENTER);
myEmptyContentLabel = new JLabel("", SwingConstants.CENTER);
revalidateDetailsMode();
}
@@ -200,12 +200,7 @@ public class DetailsComponent {
}
private void updateBanner() {
if (NullableComponent.Check.isNull(myContent)) {
myBannerLabel.setText(null);
}
else {
myBannerLabel.setText(myBannerText);
}
myBannerLabel.setText(NullableComponent.Check.isNull(myContent) || myBannerText == null ? ArrayUtil.EMPTY_STRING_ARRAY : myBannerText);
myBannerLabel.revalidate();
myBannerLabel.repaint();
@@ -250,17 +245,16 @@ public class DetailsComponent {
}
public static interface Facade {
public interface Facade {
DetailsComponent getDetailsComponent();
}
private class MyWrapper extends Wrapper implements NullableComponent {
public MyWrapper(final JComponent c) {
super(c == null || NullableComponent.Check.isNull(c) ? DetailsComponent.this.myEmptyContentLabel : c);
super(c == null || NullableComponent.Check.isNull(c) ? myEmptyContentLabel : c);
}
@Override
public boolean isNull() {
return getTargetComponent() == myEmptyContentLabel;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import java.net.URL;
public class IdeSettingsStatisticsService extends SettingsConnectionService {
private static final Logger LOG = Logger.getInstance("#com.intellij.internal.statistic.ideSettings.IdeSettingsUsagesCollector");
private static String FILE_NAME = "ide-settings-statistics.xml";
private static final String FILE_NAME = "ide-settings-statistics.xml";
private static final IdeSettingsStatisticsService myInstance = new IdeSettingsStatisticsService();
private IdeSettingsDescriptor[] myDescriptors;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,14 +18,13 @@ package com.intellij.openapi.ui.playback.commands;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.playback.PlaybackCommand;
import com.intellij.openapi.ui.playback.PlaybackContext;
import com.intellij.openapi.ui.playback.PlaybackRunner;
import com.intellij.openapi.util.ActionCallback;
import java.io.File;
public abstract class AbstractCommand implements PlaybackCommand {
public static String CMD_PREFIX = "%";
public static final String CMD_PREFIX = "%";
private final String myText;
private final int myLine;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@ package com.intellij.openapi.ui.playback.commands;
import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.ui.playback.PlaybackContext;
import com.intellij.openapi.ui.playback.PlaybackRunner;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.wm.IdeFocusManager;
@@ -26,7 +25,7 @@ import java.util.*;
public class AssertFocused extends AbstractCommand {
public static String PREFIX = CMD_PREFIX + "assert focused";
public static final String PREFIX = CMD_PREFIX + "assert focused";
public AssertFocused(String text, int line) {
super(text, line);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import com.intellij.openapi.ui.playback.PlaybackContext;
import com.intellij.openapi.util.ActionCallback;
public class DelayCommand extends AbstractCommand {
public static String PREFIX = CMD_PREFIX + "delay";
public static final String PREFIX = CMD_PREFIX + "delay";
public DelayCommand(String text, int line) {
super(text, line);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@ import com.intellij.openapi.util.ActionCallback;
public class KeyShortcutCommand extends TypeCommand {
public static String PREFIX = CMD_PREFIX + "[";
public static String POSTFIX = "]";
public static final String PREFIX = CMD_PREFIX + "[";
public static final String POSTFIX = "]";
public KeyShortcutCommand(String text, int line) {
super(text, line);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import com.intellij.openapi.util.registry.Registry;
public class RegistryValueCommand extends AbstractCommand {
public static String PREFIX = CMD_PREFIX + "set";
public static final String PREFIX = CMD_PREFIX + "set";
public RegistryValueCommand(String text, int line) {
super(text, line);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.ActionCallback;
public class StopCommand extends AbstractCommand {
public static String PREFIX = CMD_PREFIX + "stop";
public static final String PREFIX = CMD_PREFIX + "stop";
public StopCommand(String text, int line) {
super(text, line);
@@ -1647,11 +1647,12 @@ public class AbstractPopup implements JBPopup {
@Override
public void setMinimumSize(Dimension size) {
if (size == null) {
myMinSize = myHeaderPanel.getPreferredSize();
final Dimension sz = myHeaderPanel.getPreferredSize();
if (size == null || sz == null) {
myMinSize = sz == null ? new Dimension(0, 0) : sz;
} else {
final int width = Math.max(size.width, myHeaderPanel.getPreferredSize().width);
final int height = Math.max(size.height, myHeaderPanel.getPreferredSize().height);
final int width = Math.max(size.width, sz.width);
final int height = Math.max(size.height, sz.height);
myMinSize = new Dimension(width, height);
}
@@ -71,6 +71,7 @@
<extensionPoint name="xml.implicitIdRefProvider" interface="com.intellij.psi.impl.source.resolve.reference.impl.providers.ImplicitIdRefProvider"/>
<extensionPoint qualifiedName="org.jetbrains.javaScriptDebuggerStarter" interface="com.intellij.ide.browsers.JavaScriptDebuggerStarter"/>
<extensionPoint qualifiedName="org.jetbrains.openInBrowserAction" interface="com.intellij.ide.browsers.actions.OpenInBrowserActionProducer"/>
<extensionPoint name="html.scriptContentProvider"
beanClass="com.intellij.lang.LanguageExtensionPoint">
@@ -188,7 +188,7 @@ library.configure.title=Configure Library
library.configure.module.title=Configure Module Library
library.configure.project.title=Configure Project Libraries
library.configure.global.title=Configure Global Libraries
library.detach.action=Detach
library.remove.action=Remove
library.root.node=Root
library.sources.node=Sources
project.order.entry.project=<Project>
@@ -211,10 +211,11 @@ public class UsageViewManagerImpl extends UsageViewManager {
@NotNull
public static String getProgressTitle(@NotNull UsageViewPresentation presentation) {
final String scopeText = presentation.getScopeText();
if (scopeText == null) {
return UsageViewBundle.message("progress.searching.for", StringUtil.capitalize(presentation.getUsagesString()));
}
return UsageViewBundle.message("progress.searching.for.in", StringUtil.capitalize(presentation.getUsagesString()), scopeText);
String usagesString = StringUtil.capitalize(presentation.getUsagesString());
String result = scopeText == null
? UsageViewBundle.message("progress.searching.for", usagesString)
: UsageViewBundle.message("progress.searching.for.in", usagesString, scopeText);
return StringUtil.escapeXml(result);
}
private void showToolWindow(boolean activateWindow) {
@@ -341,7 +342,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
findUsagesStartedBalloon.addRequest(new Runnable() {
@Override
public void run() {
String balloon = "Searching for " + myPresentation.getUsagesString()+"...";
String balloon = UsageViewBundle.message("progress.searching.for", StringUtil.escapeXml(myPresentation.getUsagesString()));
notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation, UsageViewManagerImpl.this.myProject,
balloon);
findStartedBalloonShown.set(true);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import java.util.StringTokenizer;
*/
public class CommandLineTokenizer extends StringTokenizer {
private static String DEFAULT_DELIMITERS = " \t\n\r\f";
private static final String DEFAULT_DELIMITERS = " \t\n\r\f";
// keep source level 1.4
private List myTokens = new ArrayList();
private int myCurrentToken = 0;
@@ -685,6 +685,7 @@ public class AllIcons {
public static class Modules {
public static final Icon AddContentEntry = IconLoader.getIcon("/modules/addContentEntry.png"); // 16x16
public static final Icon AddExcludedRoot = IconLoader.getIcon("/modules/addExcludedRoot.png"); // 16x16
public static final Icon Annotation = IconLoader.getIcon("/modules/annotation.png"); // 16x16
public static final Icon DeleteContentFolder = IconLoader.getIcon("/modules/deleteContentFolder.png"); // 9x9
public static final Icon DeleteContentFolderRollover = IconLoader.getIcon("/modules/deleteContentFolderRollover.png"); // 9x9
@@ -434,8 +434,10 @@ public class StringUtil extends StringUtilRt {
}
}
@NonNls private static final String[] ourPrepositions = {"at", "the", "and", "not", "if", "a", "or", "to", "in", "on", "into", "by"};
@NonNls private static final String[] ourPrepositions = {
"a", "an", "and", "as", "at", "but", "by", "down", "for", "from", "if", "in", "into", "not", "of", "on", "onto", "or", "out", "over",
"per", "nor", "the", "to", "up", "upon", "via", "with"
};
public static boolean isPreposition(@NotNull String s, int firstChar, int lastChar) {
return isPreposition(s, firstChar, lastChar, ourPrepositions);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -370,7 +370,7 @@ public class ArrayUtil extends ArrayUtilRt {
}
@NotNull
public static <T> T[] remove(@NotNull final T[] src, int idx, ArrayFactory<T> factory) {
public static <T> T[] remove(@NotNull final T[] src, int idx, @NotNull ArrayFactory<T> factory) {
int length = src.length;
if (idx < 0 || idx >= length) {
throw new IllegalArgumentException("invalid index: " + idx);
@@ -390,7 +390,7 @@ public class ArrayUtil extends ArrayUtilRt {
}
@NotNull
public static <T> T[] remove(@NotNull final T[] src, T element, ArrayFactory<T> factory) {
public static <T> T[] remove(@NotNull final T[] src, T element, @NotNull ArrayFactory<T> factory) {
final int idx = find(src, element);
if (idx == -1) return src;
@@ -441,14 +441,10 @@ public class ArrayUtil extends ArrayUtilRt {
return indexOf(src, obj);
}
public static boolean startsWith(byte[] array, byte[] prefix) {
public static boolean startsWith(@NotNull byte[] array, @NotNull byte[] prefix) {
if (array == prefix) {
return true;
}
if (array == null || prefix == null) {
return false;
}
int length = prefix.length;
if (array.length < length) {
return false;
@@ -463,14 +459,10 @@ public class ArrayUtil extends ArrayUtilRt {
return true;
}
public static <E> boolean startsWith(E[] array, E[] subArray) {
public static <E> boolean startsWith(@NotNull E[] array, @NotNull E[] subArray) {
if (array == subArray) {
return true;
}
if (array == null || subArray == null) {
return false;
}
int length = subArray.length;
if (array.length < length) {
return false;
@@ -500,13 +492,10 @@ public class ArrayUtil extends ArrayUtilRt {
return true;
}
public static <T> boolean equals(T[] a1, T[] a2, @NotNull Equality<? super T> comparator) {
public static <T> boolean equals(@NotNull T[] a1, @NotNull T[] a2, @NotNull Equality<? super T> comparator) {
if (a1 == a2) {
return true;
}
if (a1 == null || a2 == null) {
return false;
}
int length = a2.length;
if (a1.length != length) {
@@ -521,14 +510,10 @@ public class ArrayUtil extends ArrayUtilRt {
return true;
}
public static <T> boolean equals(T[] a1, T[] a2, @NotNull Comparator<? super T> comparator) {
public static <T> boolean equals(@NotNull T[] a1, @NotNull T[] a2, @NotNull Comparator<? super T> comparator) {
if (a1 == a2) {
return true;
}
if (a1 == null || a2 == null) {
return false;
}
int length = a2.length;
if (a1.length != length) {
return false;
@@ -681,11 +666,11 @@ public class ArrayUtil extends ArrayUtilRt {
return -1;
}
public static boolean contains(@Nullable final Object o, final Object... objects) {
public static boolean contains(@Nullable final Object o, @NotNull Object... objects) {
return indexOf(objects, o) >= 0;
}
public static boolean contains(@Nullable final String s, final String... strings) {
public static boolean contains(@Nullable final String s, @NotNull String... strings) {
if (s == null) {
for (String str : strings) {
if (str == null) return true;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -589,7 +589,7 @@ public class VcsUtil {
return (! s1Trimmed.equals(s2Trimmed)) && s1Trimmed.equalsIgnoreCase(s2Trimmed);
}
private static String ANNO_ASPECT = "show.vcs.annotation.aspect.";
private static final String ANNO_ASPECT = "show.vcs.annotation.aspect.";
//public static boolean isAspectAvailableByDefault(LineAnnotationAspect aspect) {
// if (aspect.getId() == null) return aspect.isShowByDefault();
// return PropertiesComponent.getInstance().getBoolean(ANNO_ASPECT + aspect.getId(), aspect.isShowByDefault());
@@ -45,7 +45,7 @@ import java.util.List;
class LanguageResolvingUtil {
private static String ANY_LANGUAGE_DEFAULT_ID = Language.ANY.getID();
private static final String ANY_LANGUAGE_DEFAULT_ID = Language.ANY.getID();
static Collection<LanguageDefinition> getAllLanguageDefinitions(ConvertContext context) {
List<LanguageDefinition> languageDefinitions = collectLanguageDefinitions(context);
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.maven.dom.refactorings.introduce;
import com.intellij.find.FindManager;
@@ -43,8 +58,8 @@ import org.jetbrains.idea.maven.dom.model.MavenDomProperties;
import java.util.*;
public class IntroducePropertyAction extends BaseRefactoringAction {
private static String PREFIX = "${";
private static String SUFFIX = "}";
private static final String PREFIX = "${";
private static final String SUFFIX = "}";
public IntroducePropertyAction() {
setInjectedContext(true);
@@ -16,6 +16,7 @@
package org.jetbrains.idea.maven.execution;
import com.intellij.execution.JUnitPatcher;
import com.intellij.execution.configurations.CommandLineTokenizer;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.text.StringUtil;
@@ -85,7 +86,7 @@ public class MavenJUnitPatcher extends JUnitPatcher {
if (argLine != null) {
String value = argLine.getTextTrim();
if (StringUtil.isNotEmpty(value)) {
javaParameters.getVMParametersList().add(value);
javaParameters.getVMParametersList().addParametersString(value);
}
}
}
@@ -0,0 +1,57 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idea.maven.execution;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import static java.util.Arrays.asList;
public class MavenJUnitPatcherTest extends MavenImportingTestCase {
public void testArgList() throws Exception {
VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" +
"<artifactId>m1</artifactId>" +
"<version>1</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>m2</artifactId>" +
" <version>1</version>" +
" </dependency>" +
"</dependencies>" +
"<build><plugins>" +
" <plugin>" +
" <groupId>org.apache.maven.plugins</groupId>" +
" <artifactId>maven-surefire-plugin</artifactId>" +
" <version>2.16</version>" +
" <configuration>" +
" <argLine>-Xmx2048M -XX:MaxPermSize=512M \"-Dargs=can have spaces\"</argLine>" +
" </configuration>" +
" </plugin>" +
"</plugins></build>");
importProjects(m1);
Module module = getModule("m1");
MavenJUnitPatcher mavenJUnitPatcher = new MavenJUnitPatcher();
JavaParameters javaParameters = new JavaParameters();
mavenJUnitPatcher.patchJavaParameters(module, javaParameters);
assertEquals(asList("-Xmx2048M", "-XX:MaxPermSize=512M", "-Dargs=can have spaces"),
javaParameters.getVMParametersList().getList());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ public class DependsOnGroupsInspection extends BaseJavaLocalInspectionTool {
private static final Pattern PATTERN = Pattern.compile("\"([a-zA-Z0-9_\\-\\(\\)]*)\"");
public JDOMExternalizableStringList groups = new JDOMExternalizableStringList();
@NonNls public static String SHORT_NAME = "groupsTestNG";
@NonNls public static final String SHORT_NAME = "groupsTestNG";
@NotNull
@Override
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python.refactoring.classes.membersManager;
import com.google.common.base.Function;
@@ -102,7 +117,8 @@ public abstract class MembersManager<T extends PyElement> implements Function<T,
@NotNull final PyClass... to) {
manager.checkElementTypes(elementsToMove);
for (final PyElement element : manager.getElementsToStoreReferences((Collection)elementsToMove)) {
Collection<? extends PyElement> references = manager.getElementsToStoreReferences((Collection)elementsToMove);
for (final PyElement element : references) {
PyClassRefactoringUtil.rememberNamedReferences(element, PyNames.CANONICAL_SELF); //"self" is not reference we need to move
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import static com.intellij.testFramework.PlatformTestUtil.assertTreeEqual;
* @author vlan
*/
public class PyStructureViewTest extends PyTestCase {
private static String TEST_DIRECTORY = "structureView/";
private static final String TEST_DIRECTORY = "structureView/";
public void testBaseClassNames() {
myFixture.configureByFiles(TEST_DIRECTORY + "baseClassNames.py",
@@ -362,6 +362,7 @@ plugin
plugins
pointcut
pointcuts
portlet
polyadic
popup
popups
@@ -0,0 +1,46 @@
package com.intellij.ide.browsers;
import com.intellij.openapi.util.Computable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.UUID;
final class CustomWebBrowser extends WebBrowserBase {
private final Computable<String> pathComputable;
private final Icon icon;
private final String browserNotFoundMessage;
CustomWebBrowser(@NotNull UUID id,
@NotNull BrowserFamily family,
@NotNull String name,
@NotNull Icon icon,
@NotNull Computable<String> pathComputable,
@Nullable String browserNotFoundMessage) {
super(id, family, name);
this.pathComputable = pathComputable;
this.icon = icon;
this.browserNotFoundMessage = browserNotFoundMessage;
}
@Override
@NotNull
public Icon getIcon() {
return icon;
}
@Override
@Nullable
public String getPath() {
return pathComputable.compute();
}
@Override
@NotNull
public String getBrowserNotFoundMessage() {
String message = browserNotFoundMessage;
return message == null ? super.getBrowserNotFoundMessage() : message;
}
}
@@ -16,9 +16,11 @@
package com.intellij.ide.browsers;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.util.NullableComputable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.UUID;
public abstract class WebBrowserBase extends WebBrowser {
@@ -62,6 +64,16 @@ public abstract class WebBrowserBase extends WebBrowser {
return null;
}
@NotNull
public static WebBrowser createCustomBrowser(@NotNull BrowserFamily family,
@NotNull String name,
@NotNull UUID id,
@NotNull Icon icon,
@NotNull NullableComputable<String> pathComputable,
@Nullable String browserNotFoundMessage) {
return new CustomWebBrowser(id, family, name, icon, pathComputable, browserNotFoundMessage);
}
@Override
public String toString() {
return getName() + " (" + getPath() + ")";
@@ -277,15 +277,6 @@ public class WebBrowserManager implements PersistentStateComponent<Element>, Mod
((ConfigurableWebBrowser)browser).setActive(isActive);
}
public void addBrowser(final @NotNull UUID id,
final @NotNull BrowserFamily family,
final @NotNull String name,
final @Nullable String path,
final boolean active,
final BrowserSpecificSettings specificSettings) {
browsers.add(new ConfigurableWebBrowser(id, family, name, path, active, specificSettings));
}
@Nullable
private static UUID parseUuid(@NotNull String id) {
if (id.indexOf('-') == -1) {
@@ -309,9 +300,7 @@ public class WebBrowserManager implements PersistentStateComponent<Element>, Mod
UUID id = parseUuid(idOrName);
if (id == null) {
for (ConfigurableWebBrowser browser : browsers) {
if (browser.getName().equals(idOrName) ||
browser.getFamily().name().equalsIgnoreCase(idOrName) ||
browser.getFamily().getName().equalsIgnoreCase(idOrName)) {
if (browser.getFamily().name().equalsIgnoreCase(idOrName) || browser.getFamily().getName().equalsIgnoreCase(idOrName)) {
return browser;
}
}
@@ -0,0 +1,12 @@
package com.intellij.ide.browsers.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.extensions.ExtensionPointName;
import java.util.List;
public abstract class OpenInBrowserActionProducer {
static final ExtensionPointName<OpenInBrowserActionProducer> EP_NAME = ExtensionPointName.create("org.jetbrains.openInBrowserAction");
public abstract List<AnAction> getActions();
}
@@ -22,6 +22,8 @@ import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.ComputableActionGroup;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -41,10 +43,15 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup
@Nullable
@Override
public Result<AnAction[]> compute() {
List<AnAction> actionsByEP = new SmartList<AnAction>();
for (OpenInBrowserActionProducer actionProducer : OpenInBrowserActionProducer.EP_NAME.getExtensions()) {
actionsByEP.addAll(actionProducer.getActions());
}
List<WebBrowser> browsers = WebBrowserManager.getInstance().getBrowsers();
boolean addDefaultBrowser = isPopup();
int offset = addDefaultBrowser ? 1 : 0;
AnAction[] actions = new AnAction[browsers.size() + offset];
AnAction[] actions = new AnAction[browsers.size() + offset + actionsByEP.size()];
if (addDefaultBrowser) {
if (myDefaultBrowserAction == null) {
@@ -59,6 +66,8 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup
actions[i + offset] = new BaseWebBrowserAction(browsers.get(i));
}
ArrayUtil.copy(actionsByEP, actions, offset + browsers.size());
return Result.create(actions, WebBrowserManager.getInstance());
}
};