Merge remote-tracking branch 'origin/master'
@@ -16,6 +16,7 @@
|
||||
package org.intellij.images.fileTypes;
|
||||
|
||||
import com.intellij.lang.documentation.AbstractDocumentationProvider;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWithId;
|
||||
@@ -39,7 +40,7 @@ public class ImageDocumentationProvider extends AbstractDocumentationProvider {
|
||||
|
||||
if (element instanceof PsiFileSystemItem && !((PsiFileSystemItem)element).isDirectory()) {
|
||||
final VirtualFile file = ((PsiFileSystemItem)element).getVirtualFile();
|
||||
if (file instanceof VirtualFileWithId) {
|
||||
if (file instanceof VirtualFileWithId && !DumbService.isDumb(element.getProject())) {
|
||||
ImageInfoIndex.processValues(file, new FileBasedIndex.ValueProcessor<ImageInfoIndex.ImageInfo>() {
|
||||
public boolean process(VirtualFile file, ImageInfoIndex.ImageInfo value) {
|
||||
int imageWidth = value.width;
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
import com.intellij.ui.EditorTextFieldWithBrowseButton;
|
||||
import com.intellij.ui.PanelWithAnchor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -64,7 +65,7 @@ public class ApplicationConfigurable extends SettingsEditor<ApplicationConfigura
|
||||
ClassBrowser.createApplicationClassBrowser(project, myModuleSelector).setField(getMainClassField());
|
||||
myVersionDetector = new JreVersionDetector();
|
||||
|
||||
setAnchor(myModule.getAnchor());
|
||||
myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myCommonProgramParameters, myAlternativeJREPanel, myModule);
|
||||
}
|
||||
|
||||
public void applyEditorTo(final ApplicationConfiguration configuration) throws ConfigurationException {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AlternativeJREPanel extends JPanel implements PanelWithAnchor {
|
||||
private final ComponentWithBrowseButton<TextFieldWithHistory> myPathField;
|
||||
private final JBCheckBox myCbEnabled;
|
||||
final TextFieldWithHistory myFieldWithHistory;
|
||||
private JComponent myAnchor;
|
||||
|
||||
public AlternativeJREPanel() {
|
||||
super(new GridBagLayout());
|
||||
@@ -79,6 +80,9 @@ public class AlternativeJREPanel extends JPanel implements PanelWithAnchor {
|
||||
}
|
||||
});
|
||||
enabledChanged();
|
||||
|
||||
setAnchor(myCbEnabled);
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@@ -112,11 +116,12 @@ public class AlternativeJREPanel extends JPanel implements PanelWithAnchor {
|
||||
|
||||
@Override
|
||||
public JComponent getAnchor() {
|
||||
return myCbEnabled.getAnchor();
|
||||
return myAnchor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchor(JComponent anchor) {
|
||||
myAnchor = anchor;
|
||||
myCbEnabled.setAnchor(anchor);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,6 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
myEntryTable = new JBTable(myModel);
|
||||
myEntryTable.setShowGrid(false);
|
||||
myEntryTable.setDragEnabled(false);
|
||||
myEntryTable.setShowHorizontalLines(false);
|
||||
myEntryTable.setShowVerticalLines(false);
|
||||
myEntryTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
|
||||
myEntryTable.setDefaultRenderer(ClasspathTableItem.class, new TableItemRenderer(getStructureConfigurableContext()));
|
||||
@@ -152,7 +150,6 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setFixedColumnWidth(ClasspathTableModel.EXPORT_COLUMN, ClasspathTableModel.EXPORT_COLUMN_NAME);
|
||||
setFixedColumnWidth(ClasspathTableModel.SCOPE_COLUMN, DependencyScope.COMPILE.toString() + " "); // leave space for combobox border
|
||||
|
||||
@@ -246,13 +243,9 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
}
|
||||
|
||||
private void setFixedColumnWidth(final int columnIndex, final String textToMeasure) {
|
||||
final FontMetrics fontMetrics = myEntryTable.getFontMetrics(myEntryTable.getFont());
|
||||
final int width = fontMetrics.stringWidth(" " + textToMeasure + " ") + 4;
|
||||
final TableColumn checkboxColumn = myEntryTable.getTableHeader().getColumnModel().getColumn(columnIndex);
|
||||
checkboxColumn.setWidth(width);
|
||||
checkboxColumn.setPreferredWidth(width);
|
||||
checkboxColumn.setMaxWidth(width);
|
||||
checkboxColumn.setMinWidth(width);
|
||||
final TableColumn column = myEntryTable.getTableHeader().getColumnModel().getColumn(columnIndex);
|
||||
column.setResizable(false);
|
||||
column.setMaxWidth(column.getPreferredWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<border type="empty"/>
|
||||
<children>
|
||||
<grid id="452da" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
|
||||
@@ -72,30 +72,35 @@ public class RedundantLambdaParameterTypeInspection extends BaseJavaLocalInspect
|
||||
if (parameters.length == 0) return;
|
||||
final PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, false);
|
||||
if (functionalInterfaceType != null) {
|
||||
if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType)) {
|
||||
final PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiExpressionList) {
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (gParent instanceof PsiCallExpression && ((PsiCallExpression)gParent).getTypeArguments().length == 0) {
|
||||
final PsiMethod method = ((PsiCallExpression)gParent).resolveMethod();
|
||||
if (method == null) return;
|
||||
final int idx = LambdaUtil.getLambdaIdx((PsiExpressionList)parent, expression);
|
||||
if (idx < 0) return;
|
||||
final PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiExpressionList) {
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (gParent instanceof PsiCallExpression && ((PsiCallExpression)gParent).getTypeArguments().length == 0) {
|
||||
final PsiMethod method = ((PsiCallExpression)gParent).resolveMethod();
|
||||
if (method == null) return;
|
||||
final int idx = LambdaUtil.getLambdaIdx((PsiExpressionList)parent, expression);
|
||||
if (idx < 0) return;
|
||||
|
||||
final PsiTypeParameter[] typeParameters = method.getTypeParameters();
|
||||
final PsiExpression[] arguments = ((PsiExpressionList)parent).getExpressions();
|
||||
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(holder.getProject());
|
||||
arguments[idx] = javaPsiFacade.getElementFactory().createExpressionFromText("null", expression);
|
||||
final PsiSubstitutor substitutor = javaPsiFacade.getResolveHelper()
|
||||
.inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, PsiSubstitutor.EMPTY,
|
||||
gParent, DefaultParameterTypeInferencePolicy.INSTANCE);
|
||||
|
||||
for (PsiTypeParameter parameter : typeParameters) {
|
||||
final PsiType psiType = substitutor.substitute(parameter);
|
||||
if (psiType == null || LambdaUtil.dependsOnTypeParams(psiType, expression, parameter)) return;
|
||||
final PsiTypeParameter[] typeParameters = method.getTypeParameters();
|
||||
final PsiExpression[] arguments = ((PsiExpressionList)parent).getExpressions();
|
||||
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(holder.getProject());
|
||||
arguments[idx] = javaPsiFacade.getElementFactory().createExpressionFromText("(" + StringUtil.join(expression.getParameterList().getParameters(), new Function<PsiParameter, String>() {
|
||||
@Override
|
||||
public String fun(PsiParameter parameter) {
|
||||
return parameter.getName();
|
||||
}
|
||||
}, ", ") + ") -> {}", expression);
|
||||
final PsiSubstitutor substitutor = javaPsiFacade.getResolveHelper()
|
||||
.inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, PsiSubstitutor.EMPTY,
|
||||
gParent, DefaultParameterTypeInferencePolicy.INSTANCE);
|
||||
|
||||
for (PsiTypeParameter parameter : typeParameters) {
|
||||
final PsiType psiType = substitutor.substitute(parameter);
|
||||
if (psiType == null || LambdaUtil.dependsOnTypeParams(psiType, expression, parameter)) return;
|
||||
}
|
||||
}
|
||||
} else if (!LambdaUtil.isLambdaFullyInferred(expression, functionalInterfaceType)) {
|
||||
return;
|
||||
}
|
||||
holder.registerProblem(expression.getParameterList(), "Redundant parameter type declarations",
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL, new RemoveTypeDeclarationsFix());
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ParameterCanBeLocalInspection extends BaseJavaLocalInspectionTool {
|
||||
final List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>();
|
||||
for (PsiParameter parameter : getWriteBeforeRead(parameters, body)) {
|
||||
final PsiIdentifier identifier = parameter.getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
if (identifier != null && identifier.isPhysical()) {
|
||||
result.add(createProblem(manager, identifier, isOnTheFly));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,37 +17,31 @@ package com.intellij.find.findUsages;
|
||||
|
||||
import com.intellij.find.FindBundle;
|
||||
import com.intellij.find.FindSettings;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.util.MethodSignatureUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.StateRestoringCheckBox;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> extends AbstractFindUsagesDialog {
|
||||
protected final PsiElement myPsiElement;
|
||||
public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> extends CommonFindUsagesDialog {
|
||||
private StateRestoringCheckBox myCbIncludeOverloadedMethods;
|
||||
private boolean myIncludeOverloadedMethodsAvailable = false;
|
||||
|
||||
protected JavaFindUsagesDialog(PsiElement element, Project project, FindUsagesOptions findUsagesOptions, boolean toShowInNewTab, boolean mustOpenInNewTab,
|
||||
protected JavaFindUsagesDialog(@NotNull PsiElement element,
|
||||
@NotNull Project project,
|
||||
@NotNull FindUsagesOptions findUsagesOptions,
|
||||
boolean toShowInNewTab,
|
||||
boolean mustOpenInNewTab,
|
||||
boolean isSingleFile,
|
||||
FindUsagesHandler handler) {
|
||||
super(project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, isTextSearch(element, isSingleFile, handler), !isSingleFile && !element.getManager().isInProject(element));
|
||||
myPsiElement = element;
|
||||
super(element, project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, handler);
|
||||
myIncludeOverloadedMethodsAvailable = element instanceof PsiMethod && MethodSignatureUtil.hasOverloads((PsiMethod)element);
|
||||
init();
|
||||
}
|
||||
|
||||
private static boolean isTextSearch(PsiElement element, boolean isSingleFile, FindUsagesHandler handler) {
|
||||
return FindUsagesUtil.isSearchForTextOccurrencesAvailable(element, isSingleFile, handler);
|
||||
}
|
||||
|
||||
public void calcFindUsagesOptions(T options) {
|
||||
if (options instanceof JavaMethodFindUsagesOptions) {
|
||||
@@ -85,28 +79,10 @@ public abstract class JavaFindUsagesDialog<T extends JavaFindUsagesOptions> exte
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInFileOnly() {
|
||||
return super.isInFileOnly() ||
|
||||
myPsiElement != null && PsiSearchHelper.SERVICE.getInstance(myPsiElement.getProject()).getUseScope(myPsiElement)instanceof LocalSearchScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureLabelComponent(final SimpleColoredComponent coloredComponent) {
|
||||
coloredComponent.append(StringUtil.capitalize(UsageViewUtil.getType(myPsiElement)));
|
||||
coloredComponent.append(" ");
|
||||
coloredComponent.append(UsageViewUtil.getDescriptiveName(myPsiElement));
|
||||
}
|
||||
|
||||
protected final PsiElement getPsiElement() {
|
||||
return myPsiElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHelpAction() {
|
||||
HelpManager.getInstance().invokeHelp(FindUsagesManager.getHelpID(myPsiElement));
|
||||
}
|
||||
|
||||
protected T getFindUsagesOptions() {
|
||||
return (T)myFindUsagesOptions;
|
||||
}
|
||||
|
||||
@@ -66,18 +66,17 @@ import java.util.*;
|
||||
* @author peter
|
||||
*/
|
||||
public class JavaFindUsagesHandler extends FindUsagesHandler{
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.find.findUsages.DefaultFindUsagesHandler");
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.find.findUsages.JavaFindUsagesHandler");
|
||||
public static final String ACTION_STRING = FindBundle.message("find.super.method.warning.action.verb");
|
||||
|
||||
private final PsiElement[] myElementsToSearch;
|
||||
private final JavaFindUsagesHandlerFactory myFactory;
|
||||
|
||||
public JavaFindUsagesHandler(@NotNull PsiElement psiElement, JavaFindUsagesHandlerFactory factory) {
|
||||
public JavaFindUsagesHandler(@NotNull PsiElement psiElement, @NotNull JavaFindUsagesHandlerFactory factory) {
|
||||
this(psiElement, PsiElement.EMPTY_ARRAY, factory);
|
||||
}
|
||||
|
||||
|
||||
public JavaFindUsagesHandler(@NotNull PsiElement psiElement, @NotNull PsiElement[] elementsToSearch, JavaFindUsagesHandlerFactory factory) {
|
||||
public JavaFindUsagesHandler(@NotNull PsiElement psiElement, @NotNull PsiElement[] elementsToSearch, @NotNull JavaFindUsagesHandlerFactory factory) {
|
||||
super(psiElement);
|
||||
myElementsToSearch = elementsToSearch;
|
||||
myFactory = factory;
|
||||
@@ -714,14 +713,14 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isSearchForTextOccurencesAvailable(PsiElement psiElement, boolean isSingleFile) {
|
||||
protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) {
|
||||
if (isSingleFile) return false;
|
||||
return new JavaNonCodeSearchElementDescriptionProvider().getElementDescription(psiElement, NonCodeSearchDescriptionLocation.NON_JAVA) != null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PsiReference> findReferencesToHighlight(final PsiElement target, final SearchScope searchScope) {
|
||||
public Collection<PsiReference> findReferencesToHighlight(@NotNull final PsiElement target, final SearchScope searchScope) {
|
||||
if (target instanceof PsiMethod) {
|
||||
final PsiMethod[] superMethods = ((PsiMethod)target).findDeepestSuperMethods();
|
||||
if (superMethods.length == 0) {
|
||||
|
||||
@@ -133,7 +133,7 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
@NotNull JavaElementArrangementEntry target)
|
||||
{
|
||||
if (previous == null) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
@@ -152,7 +152,7 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
else {
|
||||
return commonSettings.BLANK_LINES_AROUND_METHOD;
|
||||
}
|
||||
default: return 0;
|
||||
default: return commonSettings.BLANK_LINES_AROUND_CLASS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
AlignmentInColumnsHelper alignmentInColumnsHelper) {
|
||||
super(node, wrap, createBlockAlignment(alignmentStrategy, node));
|
||||
mySettings = settings;
|
||||
myIndentSettings = settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA);
|
||||
myIndentSettings = settings.getIndentOptions();
|
||||
myIndent = indent;
|
||||
myWrapManager = wrapManager;
|
||||
myAlignmentStrategy = alignmentStrategy;
|
||||
|
||||
@@ -16,23 +16,23 @@
|
||||
package com.intellij.refactoring.util;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaNonCodeSearchElementDescriptionProvider implements ElementDescriptionProvider {
|
||||
@Override
|
||||
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
|
||||
if (!(location instanceof NonCodeSearchDescriptionLocation)) return null;
|
||||
NonCodeSearchDescriptionLocation ncdLocation = (NonCodeSearchDescriptionLocation) location;
|
||||
if (element instanceof PsiPackage) {
|
||||
return ncdLocation.isNonJava() ? ((PsiPackage)element).getQualifiedName() : ((PsiPackage)element).getName();
|
||||
}
|
||||
else if (element instanceof PsiClass) {
|
||||
if (element instanceof PsiClass) {
|
||||
return ncdLocation.isNonJava() ? ((PsiClass)element).getQualifiedName() : ((PsiClass)element).getName();
|
||||
}
|
||||
else if (element instanceof PsiMember) {
|
||||
if (element instanceof PsiMember) {
|
||||
PsiMember member = (PsiMember)element;
|
||||
String name = member.getName();
|
||||
if (name == null) return null;
|
||||
|
||||
@@ -76,6 +76,7 @@ public class LambdaUtil {
|
||||
|
||||
public static boolean isLambdaFullyInferred(PsiLambdaExpression expression, PsiType functionalInterfaceType) {
|
||||
if (expression.getParameterList().getParametersCount() > 0 || getFunctionalInterfaceReturnType(functionalInterfaceType) != PsiType.VOID) { //todo check that void lambdas without params check
|
||||
if (functionalInterfaceType instanceof PsiClassType && ((PsiClassType)functionalInterfaceType).isRaw()) return false;
|
||||
return !dependsOnTypeParams(functionalInterfaceType, expression);
|
||||
}
|
||||
return true;
|
||||
@@ -144,8 +145,8 @@ public class LambdaUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lambdaFormalType
|
||||
.isAssignableFrom(GenericsUtil.eliminateWildcards(resolveResult.getSubstitutor().substitute(methodSignature.getSubstitutor().substitute(methodParameterType))))) {
|
||||
if (!TypeConversionUtil.erasure(lambdaFormalType)
|
||||
.isAssignableFrom(TypeConversionUtil.erasure(GenericsUtil.eliminateWildcards(resolveResult.getSubstitutor().substitute(methodSignature.getSubstitutor().substitute(methodParameterType)))))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -216,12 +217,12 @@ public class LambdaUtil {
|
||||
private static List<MethodSignature> findFunctionCandidates(PsiClass psiClass) {
|
||||
if (psiClass.isInterface()) {
|
||||
final List<MethodSignature> methods = new ArrayList<MethodSignature>();
|
||||
final PsiMethod[] psiClassMethods = psiClass.getAllMethods();
|
||||
for (PsiMethod psiMethod : psiClassMethods) {
|
||||
final Collection<HierarchicalMethodSignature> visibleSignatures = psiClass.getVisibleSignatures();
|
||||
for (HierarchicalMethodSignature signature : visibleSignatures) {
|
||||
final PsiMethod psiMethod = signature.getMethod();
|
||||
if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue;
|
||||
final PsiClass methodContainingClass = psiMethod.getContainingClass();
|
||||
if (!overridesPublicObjectMethod(psiMethod)) {
|
||||
methods.add(getMethodSignature(psiMethod, psiClass, methodContainingClass));
|
||||
if (!overridesPublicObjectMethod(psiMethod) && !PsiUtil.isExtensionMethod(psiMethod)) {
|
||||
methods.add(signature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +290,7 @@ public class LambdaUtil {
|
||||
final PsiLambdaExpression lambdaExpression,
|
||||
final PsiExpression expression) {
|
||||
final PsiParameter[] lambdaParams = lambdaExpression.getParameterList().getParameters();
|
||||
LOG.assertTrue(lambdaParams.length == methodParameters.length, "lambda params: " + lambdaExpression.getParameterList().getText() + "; method params: " + Arrays.toString(methodParameters));
|
||||
if (lambdaParams.length != methodParameters.length) return false;
|
||||
final boolean [] independent = new boolean[]{true};
|
||||
expression.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
@@ -389,7 +390,7 @@ public class LambdaUtil {
|
||||
if (type == null) {
|
||||
type = getFunctionalInterfaceType(lambdaExpression, false);
|
||||
}
|
||||
final PsiClassType.ClassResolveResult resolveResult = type instanceof PsiClassType ? ((PsiClassType)type).resolveGenerics() : null;
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(type);
|
||||
if (resolveResult != null) {
|
||||
final PsiMethod method = getFunctionalInterfaceMethod(type);
|
||||
if (method != null) {
|
||||
@@ -433,6 +434,9 @@ public class LambdaUtil {
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (gParent instanceof PsiCallExpression) {
|
||||
myMethod = ((PsiCallExpression)gParent).resolveMethod();
|
||||
if (myMethod != null && PsiTreeUtil.isAncestor(myMethod, expression, false)) {
|
||||
myMethod = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,6 @@ public abstract class PsiType implements PsiAnnotationOwner {
|
||||
* @param visitor the visitor to accept the type.
|
||||
* @return the value returned by the visitor.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract <A> A accept(@NotNull PsiTypeVisitor<A> visitor);
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,6 +71,8 @@ public class PsiTypeVisitor<A> {
|
||||
@Nullable
|
||||
public A visitLambdaExpressionType(PsiLambdaExpressionType lambdaExpressionType) {
|
||||
final PsiLambdaExpression lambdaExpression = lambdaExpressionType.getExpression();
|
||||
return visitType(lambdaExpression.getFunctionalInterfaceType());
|
||||
final PsiType interfaceType = lambdaExpression.getFunctionalInterfaceType();
|
||||
if (interfaceType != null) return interfaceType.accept(this);
|
||||
return visitType(interfaceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.resolve;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -186,6 +185,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
PsiType upperBound = PsiType.NULL;
|
||||
if (paramTypes.length > 0) {
|
||||
sortLambdaExpressionsLast(paramTypes, argTypes);
|
||||
boolean rawType = false;
|
||||
boolean nullPassed = false;
|
||||
for (int j = 0; j < argTypes.length; j++) {
|
||||
PsiType argumentType = argTypes[j];
|
||||
if (argumentType == null) continue;
|
||||
@@ -193,6 +194,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
|
||||
PsiType parameterType = paramTypes[j];
|
||||
if (parameterType == null) break;
|
||||
rawType |= parameterType instanceof PsiClassType && ((PsiClassType)parameterType).isRaw();
|
||||
nullPassed |= argumentType == PsiType.NULL;
|
||||
|
||||
if (parameterType instanceof PsiEllipsisType) {
|
||||
parameterType = ((PsiEllipsisType)parameterType).getComponentType();
|
||||
@@ -203,6 +206,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
final Pair<PsiType,ConstraintType> currentSubstitution;
|
||||
if (argumentType instanceof PsiLambdaExpressionType) {
|
||||
currentSubstitution = inferSubstitutionFromLambda(typeParameter, (PsiLambdaExpressionType)argumentType, lowerBound);
|
||||
if (rawType && currentSubstitution == FAILED_INFERENCE || nullPassed && currentSubstitution == null) return new Pair<PsiType, ConstraintType>(null, ConstraintType.EQUALS);
|
||||
} else {
|
||||
currentSubstitution = getSubstitutionForTypeParameterConstraint(typeParameter, parameterType,
|
||||
argumentType, true, PsiUtil.getLanguageLevel(typeParameter));
|
||||
@@ -592,7 +596,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
if (constraintFromFormalParams != null) return constraintFromFormalParams;
|
||||
|
||||
final PsiParameter[] methodParameters = method.getParameterList().getParameters();
|
||||
final PsiSubstitutor subst = resolveResult.getSubstitutor();
|
||||
final PsiSubstitutor subst =
|
||||
TypeConversionUtil.getSuperClassSubstitutor(method.getContainingClass(), resolveResult.getElement(), resolveResult.getSubstitutor());
|
||||
final boolean methodParamsDependOnTypeParams = methodParamsDependOnTypeParams(lambdaExpression, methodParameters, subst, typeParam);
|
||||
final PsiType returnType = subst.substitute(method.getReturnType());
|
||||
if (returnType != null && returnType != PsiType.VOID) {
|
||||
@@ -891,8 +896,10 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
|
||||
return getFailedInferenceConstraint(typeParameter);
|
||||
}
|
||||
final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType);
|
||||
if (method == null || methodParamsDependOnTypeParams((PsiLambdaExpression)expression, method.getParameterList().getParameters(),
|
||||
PsiUtil.resolveGenericsClassInType(functionalInterfaceType).getSubstitutor(), typeParameter)) {
|
||||
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
if (method == null || methodParamsDependOnTypeParams((PsiLambdaExpression)expression, method.getParameterList().getParameters(),
|
||||
TypeConversionUtil.getSuperClassSubstitutor(method.getContainingClass(), resolveResult.getElement(), resolveResult.getSubstitutor()), typeParameter)) {
|
||||
return getFailedInferenceConstraint(typeParameter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class Test {
|
||||
public static final BinaryOperator<Integer> rPlus = (x, y) -> x + y;
|
||||
interface BinaryOperator<T> extends Combiner<T,T,T> {
|
||||
public T operate(T left, T right);
|
||||
|
||||
@Override
|
||||
T combine(T t1, T t2) default {
|
||||
return operate(t1, t2);
|
||||
}
|
||||
}
|
||||
|
||||
interface Combiner<T, U, V> {
|
||||
V combine(T t, U u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
class TestData<K> {}
|
||||
interface TerminalOp<L, M> extends IntermediateOp<L, M> {}
|
||||
interface IntermediateOp<L1, M1> { boolean _(L1 l, M1 m);}
|
||||
|
||||
class Test<T, U> {
|
||||
protected U exerciseOps(TestData<T> data, TerminalOp<T, U> terminal, IntermediateOp<T, U>... ops) {
|
||||
return exerciseOps(data, terminal, (u, v) -> u.equals(v));
|
||||
}
|
||||
}
|
||||
|
||||
class Test1 {
|
||||
protected <T, U> U exerciseOps(TestData<T> data, TerminalOp<T, U> terminal, IntermediateOp... ops) {
|
||||
return exerciseOps(data, terminal, (u, v) -> u.equals(v));
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
protected <T, U> U exerciseOps(TestData<T> data, TerminalOp<T, U> terminal, IntermediateOp<T, U>... ops) {
|
||||
return exerciseOps(data, terminal, (u, v) -> u.equals(v));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import java.util.*;
|
||||
class TestData<K> {}
|
||||
interface TerminalOp<L, M> extends IntermediateOp<L, M> {}
|
||||
interface IntermediateOp<L1, M1> { boolean _(L1 l, M1 m);}
|
||||
|
||||
|
||||
class Test1 {
|
||||
protected <T, U> U exerciseOps(TestData<T> data, TerminalOp<T, U> terminal, IntermediateOp<T, U>... ops) {
|
||||
return exerciseOps(data, (u, v) -> u.equals(v), terminal);
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
protected <T, U> U exerciseOps(TestData<T> data, TerminalOp<T, U> terminal, IntermediateOp... ops) {
|
||||
return exerciseOps(data, <error descr="Cyclic inference">(u, v) -> u.equals(v)</error>, terminal);
|
||||
}
|
||||
}
|
||||
|
||||
class Test3 {
|
||||
interface I<Y> {
|
||||
void m(Y y);
|
||||
}
|
||||
|
||||
static <T> void bar(I<T> i, List<T> l){
|
||||
bar(x -> {}, l);
|
||||
bar(<error descr="Cyclic inference">x -> {}</error>, null);
|
||||
bar((I<T>)x -> {}, null);
|
||||
bar((T x) -> {}, null);
|
||||
bar(x -> {}, new ArrayList<T>());
|
||||
bar(<error descr="Cyclic inference">x -> {}</error>, new ArrayList());
|
||||
}
|
||||
|
||||
static {
|
||||
bar(<error descr="Cyclic inference">x->{}</error>, new ArrayList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
|
||||
// "Remove redundant types" "false"
|
||||
class Test3 {
|
||||
interface I<Y> {
|
||||
void m(Y y);
|
||||
}
|
||||
|
||||
static <T> void bar(I<T> i, List<T> l){
|
||||
bar((<caret>T x) -> {}, null);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,17 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testDefaultMethod() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLambdaOnVarargPlace() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLambdaRawOrNot() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoInferenceResult() throws Exception {
|
||||
doTest();
|
||||
|
||||
@@ -25,6 +25,7 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.S
|
||||
public class JavaRearrangerBlankLinesTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testPreserveRelativeBlankLines() {
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 2
|
||||
commonSettings.BLANK_LINES_AROUND_FIELD = 1
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 2
|
||||
commonSettings.BLANK_LINES_AROUND_FIELD_IN_INTERFACE = 2
|
||||
@@ -33,11 +34,11 @@ public class JavaRearrangerBlankLinesTest extends AbstractJavaRearrangerTest {
|
||||
'''\
|
||||
class Test {
|
||||
private void method1() {}
|
||||
|
||||
|
||||
public void method2() {}
|
||||
|
||||
private int i;
|
||||
|
||||
|
||||
public int j;
|
||||
public static int k;
|
||||
}
|
||||
@@ -62,13 +63,19 @@ interface MyInterface {
|
||||
|
||||
void test2();
|
||||
}
|
||||
|
||||
|
||||
class Test {
|
||||
public static int k;
|
||||
|
||||
public int j;
|
||||
|
||||
private int i;
|
||||
|
||||
|
||||
|
||||
public void method2() {}
|
||||
|
||||
|
||||
private void method1() {}
|
||||
}''',
|
||||
[rule(INTERFACE),
|
||||
|
||||
@@ -24,6 +24,9 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementModifier.*
|
||||
class JavaRearrangerByTypeAndModifierTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
void testComplex() {
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 0
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 0
|
||||
|
||||
doTest(
|
||||
'''\
|
||||
class Test {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import org.junit.Before
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.*
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -22,6 +24,13 @@ import static com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryType.
|
||||
*/
|
||||
class JavaRearrangerByTypeTest extends AbstractJavaRearrangerTest {
|
||||
|
||||
@Before
|
||||
void setUp() {
|
||||
super.setUp()
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 0
|
||||
commonSettings.BLANK_LINES_AROUND_CLASS = 0
|
||||
}
|
||||
|
||||
void testFieldsBeforeMethods() {
|
||||
doTest(
|
||||
'''\
|
||||
|
||||
@@ -503,4 +503,17 @@ public class JavaFormatterIndentationTest extends AbstractJavaFormatterTest {
|
||||
"// This is a line comment"
|
||||
);
|
||||
}
|
||||
|
||||
public void testMultilineComment() {
|
||||
// IDEA-90860
|
||||
String text =
|
||||
"\n" +
|
||||
"/*\n" +
|
||||
" * comment\n" +
|
||||
" */\n" +
|
||||
"\n" +
|
||||
"class Test {\n" +
|
||||
"}";
|
||||
doTextTest(text, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,11 @@ abstract class JavaModuleFixtureBuilderImpl<T extends ModuleFixture> extends Mod
|
||||
@Override
|
||||
public JavaModuleFixtureBuilder addLibrary(String libraryName, String... classPath) {
|
||||
final HashMap<OrderRootType, String[]> map = new HashMap<OrderRootType, String[]>();
|
||||
for (String path : classPath) {
|
||||
if (!new File(path).exists()) {
|
||||
System.out.println(path + " not exists");
|
||||
}
|
||||
}
|
||||
map.put(OrderRootType.CLASSES, classPath);
|
||||
myLibraries.add(new Lib(libraryName, map));
|
||||
return this;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ModuleBuildTarget extends BuildTarget {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
if (o == null || !(o instanceof ModuleBuildTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.impl.JpsElementChildRoleBase;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.module.JpsModuleDependency;
|
||||
@@ -14,6 +15,8 @@ public class JpsModuleDependencyImpl extends JpsDependencyElementBase<JpsModuleD
|
||||
private static final JpsElementChildRole<JpsModuleReference>
|
||||
MODULE_REFERENCE_CHILD_ROLE = JpsElementChildRoleBase.create("module reference");
|
||||
|
||||
private volatile Ref<JpsModule> myCachedModule = null;
|
||||
|
||||
public JpsModuleDependencyImpl(final JpsModuleReference moduleReference) {
|
||||
super();
|
||||
myContainer.setChild(MODULE_REFERENCE_CHILD_ROLE, moduleReference);
|
||||
@@ -31,7 +34,12 @@ public class JpsModuleDependencyImpl extends JpsDependencyElementBase<JpsModuleD
|
||||
|
||||
@Override
|
||||
public JpsModule getModule() {
|
||||
return getModuleReference().resolve();
|
||||
Ref<JpsModule> moduleRef = myCachedModule;
|
||||
if (moduleRef == null) {
|
||||
moduleRef = new Ref<JpsModule>(getModuleReference().resolve());
|
||||
myCachedModule = moduleRef;
|
||||
}
|
||||
return moduleRef.get();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.jetbrains.jps.model.serialization;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.jps.model.JpsGlobal;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsSdkTableSerializer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -10,6 +10,10 @@ import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsArtifactPropertiesSerializer;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsPackagingElementSerializer;
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryPropertiesSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryRootTypeSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsSdkPropertiesSerializer;
|
||||
import org.jetbrains.jps.model.serialization.module.JpsModulePropertiesSerializer;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -12,6 +12,10 @@ import org.jetbrains.jps.model.library.sdk.JpsSdkType;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsArtifactSerializer;
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsSdkTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.module.JpsModulePropertiesSerializer;
|
||||
import org.jetbrains.jps.model.serialization.module.JpsModuleRootModelSerializer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
@@ -162,7 +166,8 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
final String typeId = moduleRoot.getAttributeValue("type");
|
||||
final JpsModulePropertiesSerializer<?> serializer = getModulePropertiesSerializer(typeId);
|
||||
final JpsModule module = createModule(name, moduleRoot, serializer);
|
||||
JpsModuleSerializer.loadRootModel(module, JDomSerializationUtil.findComponent(moduleRoot, "NewModuleRootManager"), projectSdkType);
|
||||
JpsModuleRootModelSerializer
|
||||
.loadRootModel(module, JDomSerializationUtil.findComponent(moduleRoot, "NewModuleRootManager"), projectSdkType);
|
||||
final String moduleDirPath = file.getParent();
|
||||
JpsFacetSerializer.loadFacets(module, JDomSerializationUtil.findComponent(moduleRoot, "FacetManager"),
|
||||
FileUtil.toSystemIndependentName(moduleDirPath));
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.jps.model.artifact.*;
|
||||
import org.jetbrains.jps.model.artifact.elements.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.model.serialization.JpsLibraryTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.model.serialization.JpsLibraryRootTypeSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryRootTypeSerializer;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer;
|
||||
import org.jetbrains.jps.model.serialization.artifact.JpsPackagingElementSerializer;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.library;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryType;
|
||||
import org.jetbrains.jps.model.serialization.JpsElementPropertiesSerializer;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.library;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.library;
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.jps.model.java.JpsJavaLibraryType;
|
||||
import org.jetbrains.jps.model.library.*;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.library;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
|
||||
import org.jetbrains.jps.model.serialization.JpsElementPropertiesSerializer;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.library;
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import org.jdom.Element;
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
|
||||
import org.jetbrains.jps.model.module.JpsSdkReferencesTable;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -1,10 +1,11 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.module;
|
||||
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.module.JpsModuleType;
|
||||
import org.jetbrains.jps.model.serialization.JpsElementPropertiesSerializer;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
package org.jetbrains.jps.model.serialization.module;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -15,6 +15,9 @@ import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsSdkTableSerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -25,7 +28,7 @@ import static com.intellij.openapi.util.JDOMUtil.getChildren;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsModuleSerializer {
|
||||
public class JpsModuleRootModelSerializer {
|
||||
public static final String URL_ATTRIBUTE = "url";
|
||||
public static final String CONTENT_TAG = "content";
|
||||
public static final String SOURCE_FOLDER_TAG = "sourceFolder";
|
||||
@@ -5,6 +5,7 @@ import com.intellij.testFramework.PlatformTestUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsSdkTableSerializer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.jetbrains.jps.model.java.JpsJavaSdkType;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdkReference;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
import org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer;
|
||||
import org.jetbrains.jps.model.serialization.module.JpsModuleRootModelSerializer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -91,7 +93,7 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase {
|
||||
private static void doTestSaveModule(JpsModule module, final String moduleFilePath) {
|
||||
try {
|
||||
Element actual = JDomSerializationUtil.createComponentElement("NewModuleRootManager");
|
||||
JpsModuleSerializer.saveRootModel(module, actual);
|
||||
JpsModuleRootModelSerializer.saveRootModel(module, actual);
|
||||
File imlFile = getFileInSampleProject(moduleFilePath);
|
||||
Element rootElement = loadModuleRootTag(imlFile);
|
||||
Element expected = JDomSerializationUtil.findComponent(rootElement, "NewModuleRootManager");
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.templateLanguages.OuterLanguageElement;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -938,6 +939,24 @@ public class PsiTreeUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean treeWalkUp(@NotNull final PsiElement entrance,
|
||||
@Nullable final PsiElement maxScope,
|
||||
PairProcessor<PsiElement, PsiElement> eachScopeAndLastParent) {
|
||||
PsiElement prevParent = null;
|
||||
PsiElement scope = entrance;
|
||||
|
||||
while (scope != null) {
|
||||
if (!eachScopeAndLastParent.process(scope, prevParent)) return false;
|
||||
|
||||
if (scope == maxScope) break;
|
||||
prevParent = scope;
|
||||
scope = prevParent.getContext();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiElement findPrevParent(@NotNull PsiElement ancestor, @NotNull PsiElement descendant) {
|
||||
PsiElement cur = descendant;
|
||||
|
||||
@@ -31,6 +31,10 @@ public class LanguageTokenSeparatorGenerators extends LanguageExtension<TokenSep
|
||||
@Override
|
||||
public ASTNode generateWhitespaceBetweenTokens(ASTNode left, ASTNode right) {
|
||||
Language l = PsiUtilCore.getNotAnyLanguage(left);
|
||||
Language rightLang = PsiUtilCore.getNotAnyLanguage(right);
|
||||
if (rightLang.isKindOf(l)) {
|
||||
l = rightLang; // get more precise lexer
|
||||
}
|
||||
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
|
||||
if (parserDefinition != null) {
|
||||
PsiManager manager = right.getTreeParent().getPsi().getManager();
|
||||
|
||||
|
After Width: | Height: | Size: 762 B |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 793 B |
|
After Width: | Height: | Size: 781 B |
|
After Width: | Height: | Size: 790 B |
|
After Width: | Height: | Size: 796 B |
|
After Width: | Height: | Size: 764 B |
|
After Width: | Height: | Size: 803 B |
|
After Width: | Height: | Size: 782 B |
|
After Width: | Height: | Size: 770 B |
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 461 B |
|
After Width: | Height: | Size: 349 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 319 B |
|
After Width: | Height: | Size: 341 B |
|
After Width: | Height: | Size: 351 B |
|
After Width: | Height: | Size: 333 B |
|
After Width: | Height: | Size: 314 B |
|
After Width: | Height: | Size: 331 B |
|
After Width: | Height: | Size: 346 B |
|
After Width: | Height: | Size: 349 B |
|
After Width: | Height: | Size: 325 B |
|
After Width: | Height: | Size: 324 B |
|
After Width: | Height: | Size: 341 B |
|
After Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 330 B |
|
After Width: | Height: | Size: 314 B |
|
After Width: | Height: | Size: 334 B |
|
After Width: | Height: | Size: 346 B |
|
After Width: | Height: | Size: 328 B |
|
After Width: | Height: | Size: 393 B |
|
After Width: | Height: | Size: 389 B |
|
After Width: | Height: | Size: 391 B |
|
After Width: | Height: | Size: 389 B |
|
After Width: | Height: | Size: 393 B |
|
After Width: | Height: | Size: 388 B |
|
After Width: | Height: | Size: 390 B |
|
After Width: | Height: | Size: 395 B |
|
After Width: | Height: | Size: 391 B |
|
After Width: | Height: | Size: 392 B |
|
After Width: | Height: | Size: 391 B |
|
After Width: | Height: | Size: 392 B |
@@ -56,7 +56,8 @@ public interface Rearranger<E extends ArrangementEntry> {
|
||||
* @param parent target entry's parent (if available)
|
||||
* @param previous previous entry (if available)
|
||||
* @param target target entry which blank lines number the caller is interested in
|
||||
* @return number of blank lines to insert before the target entry
|
||||
* @return number of blank lines to insert before the target entry;
|
||||
* negative as an indication that no blank lines adjustment is necessary
|
||||
*/
|
||||
int getBlankLines(@NotNull CodeStyleSettings settings, @Nullable E parent, @Nullable E previous, @NotNull E target);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ com.siyeh.ig.errorhandling.TooBroadThrowsInspection
|
||||
com.siyeh.ig.errorhandling.UnusedCatchParameterInspection
|
||||
com.siyeh.ig.finalization.FinalizeCallsSuperFinalizeInspection
|
||||
com.siyeh.ig.finalization.FinalizeInspection
|
||||
com.siyeh.ig.imports.StaticImportInspection
|
||||
com.siyeh.ig.inheritance.InterfaceNeverImplementedInspection
|
||||
com.siyeh.ig.inheritance.NonProtectedConstructorInAbstractClassInspection
|
||||
com.siyeh.ig.inheritance.RefusedBequestInspection
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CommonProgramParametersPanel extends JPanel implements PanelWithAnc
|
||||
private LabeledComponent<JPanel> myWorkingDirectoryComponent;
|
||||
private TextFieldWithBrowseButton myWorkingDirectoryField;
|
||||
private EnvironmentVariablesComponent myEnvVariablesComponent;
|
||||
protected JComponent anchor;
|
||||
protected JComponent myAnchor;
|
||||
|
||||
private Module myModuleContext = null;
|
||||
private boolean myHaveModuleContext = false;
|
||||
@@ -160,11 +160,11 @@ public class CommonProgramParametersPanel extends JPanel implements PanelWithAnc
|
||||
}
|
||||
|
||||
public JComponent getAnchor() {
|
||||
return anchor;
|
||||
return myAnchor;
|
||||
}
|
||||
|
||||
public void setAnchor(JComponent anchor) {
|
||||
this.anchor = anchor;
|
||||
this.myAnchor = anchor;
|
||||
myProgramParametersComponent.setAnchor(anchor);
|
||||
myWorkingDirectoryComponent.setAnchor(anchor);
|
||||
myEnvVariablesComponent.setAnchor(anchor);
|
||||
|
||||
@@ -280,7 +280,6 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
continueSearch = false;
|
||||
}
|
||||
pingEDT.ping();
|
||||
//rebuildPopup(usageView, usages, table, popup, presentation, popupPosition);
|
||||
return continueSearch;
|
||||
}
|
||||
}
|
||||
@@ -579,14 +578,14 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
}.registerCustomShortcutSet(new CustomShortcutSet(shortcut.getFirstKeyStroke()), table);
|
||||
}
|
||||
|
||||
InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, new Runnable() {
|
||||
InplaceButton settingsButton = createSettingsButton(handler, popupPosition, editor, maxUsages, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
popup[0].cancel();
|
||||
}
|
||||
});
|
||||
|
||||
ActiveComponent iconComp = new ActiveComponent() {
|
||||
ActiveComponent spinningProgress = new ActiveComponent() {
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
}
|
||||
@@ -596,7 +595,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
return processIcon;
|
||||
}
|
||||
};
|
||||
builder.setCommandButton(new CompositeActiveComponent(iconComp, button));
|
||||
builder.setCommandButton(new CompositeActiveComponent(spinningProgress, settingsButton));
|
||||
|
||||
DefaultActionGroup toolbar = new DefaultActionGroup();
|
||||
usageView.addFilteringActions(toolbar);
|
||||
@@ -631,7 +630,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
|
||||
|
||||
myWidth = (int)(toolBar.getPreferredSize().getWidth()
|
||||
+ new JLabel(getFullTitle(usages, title, hadMoreSeparator, visibleNodes.size() - 1)).getPreferredSize().getWidth()
|
||||
+ button.getPreferredSize().getWidth());
|
||||
+ settingsButton.getPreferredSize().getWidth());
|
||||
myWidth = -1;
|
||||
for (AnAction action : toolbar.getChildren(null)) {
|
||||
action.unregisterCustomShortcutSet(usageView.getComponent());
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class AbstractFindUsagesDialog extends DialogWrapper {
|
||||
return panel;
|
||||
}
|
||||
|
||||
public abstract void configureLabelComponent(final SimpleColoredComponent coloredComponent);
|
||||
public abstract void configureLabelComponent(@NotNull SimpleColoredComponent coloredComponent);
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -34,13 +35,15 @@ import javax.swing.*;
|
||||
public class CommonFindUsagesDialog extends AbstractFindUsagesDialog {
|
||||
protected final PsiElement myPsiElement;
|
||||
|
||||
public CommonFindUsagesDialog(PsiElement element,
|
||||
Project project,
|
||||
FindUsagesOptions findUsagesOptions,
|
||||
public CommonFindUsagesDialog(@NotNull PsiElement element,
|
||||
@NotNull Project project,
|
||||
@NotNull FindUsagesOptions findUsagesOptions,
|
||||
boolean toShowInNewTab,
|
||||
boolean mustOpenInNewTab,
|
||||
boolean isSingleFile, FindUsagesHandler handler) {
|
||||
super(project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, isTextSearch(element, isSingleFile, handler), !isSingleFile && !element.getManager().isInProject(element));
|
||||
boolean isSingleFile,
|
||||
FindUsagesHandler handler) {
|
||||
super(project, findUsagesOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, isTextSearch(element, isSingleFile, handler),
|
||||
!isSingleFile && !element.getManager().isInProject(element));
|
||||
myPsiElement = element;
|
||||
init();
|
||||
}
|
||||
@@ -52,7 +55,7 @@ public class CommonFindUsagesDialog extends AbstractFindUsagesDialog {
|
||||
@Override
|
||||
protected boolean isInFileOnly() {
|
||||
return super.isInFileOnly() ||
|
||||
myPsiElement != null && PsiSearchHelper.SERVICE.getInstance(myPsiElement.getProject()).getUseScope(myPsiElement)instanceof LocalSearchScope;
|
||||
PsiSearchHelper.SERVICE.getInstance(myPsiElement.getProject()).getUseScope(myPsiElement) instanceof LocalSearchScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +64,7 @@ public class CommonFindUsagesDialog extends AbstractFindUsagesDialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureLabelComponent(final SimpleColoredComponent coloredComponent) {
|
||||
public void configureLabelComponent(@NotNull SimpleColoredComponent coloredComponent) {
|
||||
coloredComponent.append(StringUtil.capitalize(UsageViewUtil.getType(myPsiElement)));
|
||||
coloredComponent.append(" ");
|
||||
coloredComponent.append(UsageViewUtil.getDescriptiveName(myPsiElement), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
|
||||
@@ -193,11 +193,11 @@ public abstract class FindUsagesHandler {
|
||||
return Collections.singleton(element.getText());
|
||||
}
|
||||
|
||||
protected boolean isSearchForTextOccurencesAvailable(PsiElement psiElement, boolean isSingleFile) {
|
||||
protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<PsiReference> findReferencesToHighlight(PsiElement target, SearchScope searchScope) {
|
||||
public Collection<PsiReference> findReferencesToHighlight(@NotNull PsiElement target, SearchScope searchScope) {
|
||||
return ReferencesSearch.search(target, searchScope, false).findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public class FindUsagesManager implements JDOMExternalizable {
|
||||
if (handler == null) return;
|
||||
|
||||
boolean singleFile = scopeFile != null;
|
||||
final AbstractFindUsagesDialog dialog = handler.getFindUsagesDialog(singleFile, shouldOpenInNewTab(), mustOpenInNewTab());
|
||||
AbstractFindUsagesDialog dialog = handler.getFindUsagesDialog(singleFile, shouldOpenInNewTab(), mustOpenInNewTab());
|
||||
if (showDialog) {
|
||||
dialog.show();
|
||||
if (!dialog.isOK()) return;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
@@ -26,6 +25,7 @@ import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
import com.intellij.psi.search.SearchRequestCollector;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -80,13 +80,13 @@ public class FindUsagesOptions extends UserDataHolderBase implements Cloneable {
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = (searchScope != null ? searchScope.hashCode() : 0);
|
||||
int result = searchScope == null ? 0 : searchScope.hashCode();
|
||||
result = 31 * result + (isSearchForTextOccurrences ? 1 : 0);
|
||||
result = 31 * result + (isUsages ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
@@ -18,12 +17,13 @@
|
||||
package com.intellij.find.findUsages;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FindUsagesUtil {
|
||||
private FindUsagesUtil() {
|
||||
}
|
||||
|
||||
public static boolean isSearchForTextOccurrencesAvailable(PsiElement element, boolean isSingleFile, FindUsagesHandler handler) {
|
||||
public static boolean isSearchForTextOccurrencesAvailable(@NotNull PsiElement element, boolean isSingleFile, FindUsagesHandler handler) {
|
||||
return !isSingleFile && handler != null && handler.isSearchForTextOccurencesAvailable(element, isSingleFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
|
||||
@Override
|
||||
public void addDirectory(String s) {
|
||||
if (s == null || s.length() == 0){
|
||||
if (s == null || s.isEmpty()){
|
||||
return;
|
||||
}
|
||||
addStringToList(s, RECENT_DIR_STRINGS, MAX_RECENT_SIZE);
|
||||
@@ -345,7 +345,7 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
@Override
|
||||
public void setFileMask(String _fileMask) {
|
||||
FILE_MASK = _fileMask;
|
||||
if (_fileMask != null && _fileMask.length() > 0) {
|
||||
if (_fileMask != null && !_fileMask.isEmpty()) {
|
||||
addStringToList(_fileMask, RECENT_FILE_MASKS, MAX_RECENT_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ public class ReplaceInProjectManager {
|
||||
manager.searchAndShowUsages(new UsageTarget[]{new FindInProjectUtil.StringUsageTarget(findModelCopy.getStringToFind())},
|
||||
usageSearcherFactory, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {
|
||||
@Override
|
||||
public void usageViewCreated(UsageView usageView) {
|
||||
public void usageViewCreated(@NotNull UsageView usageView) {
|
||||
context[0] = new ReplaceContext(usageView, findModelCopy);
|
||||
addReplaceActions(context[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findingUsagesFinished(final UsageView usageView) {
|
||||
public void findingUsagesFinished(@NotNull final UsageView usageView) {
|
||||
if (context[0] != null && findManager.getFindInProjectModel().isPromptOnReplace()) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
|
||||