mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Generated
+3
-2
@@ -13,8 +13,9 @@
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-client-4.4.1-src.zip!/httpcomponents-client-4.4.1/fluent-hc/src/main/java" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-client-4.4.1-src.zip!/httpcomponents-client-4.4.1/httpclient/src/main/java" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-client-4.4.1-src.zip!/httpcomponents-client-4.4.1/httpclient/src/main/java-deprecated" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-core-4.3.3-src.zip!/httpcomponents-core-4.3.3/httpcore/src/main/java" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-core-4.3.3-src.zip!/httpcomponents-core-4.3.3/httpcore/src/main/java-deprecated" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-core-4.4.1
|
||||
-src.zip!/httpcomponents-core-4.3.3/httpcore/src/main/java" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/httpcomponents-core-4.4.1-src.zip!/httpcomponents-core-4.3.3/httpcore/src/main/java-deprecated" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,6 +1,6 @@
|
||||
; Installer images
|
||||
!define IMAGES_LOCATION "${BASE_DIR}\build\images\idea"
|
||||
!define LICENSE_FILE "${BASE_DIR}\license\IDEA_license"
|
||||
;!define LICENSE_FILE "${BASE_DIR}\license\IDEA_license"
|
||||
!define PRODUCT_PROPERTIES_FILE "${BASE_DIR}\out\release\dist.all\bin\idea.properties"
|
||||
!define PRODUCT_VM_OPTIONS_NAME idea*.exe.vmoptions
|
||||
!define PRODUCT_VM_OPTIONS_FILE "${BASE_DIR}\out\release\dist.win\bin\${PRODUCT_VM_OPTIONS_NAME}"
|
||||
@@ -144,8 +144,11 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps =
|
||||
include(name: "*.*")
|
||||
}
|
||||
}
|
||||
|
||||
dir("license") {
|
||||
fileset(dir: "${home}/license")
|
||||
fileset(dir: "${home}/license") {
|
||||
exclude(name: "placeholder.txt")
|
||||
}
|
||||
}
|
||||
fileset(file: "${home}/LICENSE.txt")
|
||||
fileset(file: "${home}/NOTICE.txt")
|
||||
|
||||
@@ -68,6 +68,7 @@ public class JavaParametersUtil {
|
||||
parameters.getVMParametersList().addParametersString(vmParameters);
|
||||
}
|
||||
|
||||
@MagicConstant(valuesFromClass = JavaParameters.class)
|
||||
public static int getClasspathType(final RunConfigurationModule configurationModule, final String mainClassName,
|
||||
final boolean classMustHaveSource) throws CantRunException {
|
||||
final Module module = configurationModule.getModule();
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
@@ -110,7 +109,7 @@ public class FileHeaderChecker {
|
||||
}
|
||||
|
||||
if (!newText.isEmpty()) {
|
||||
PsiDocComment newComment = JavaPsiFacade.getElementFactory(project).createDocCommentFromText(newText);
|
||||
PsiComment newComment = JavaPsiFacade.getElementFactory(project).createCommentFromText(newText, null);
|
||||
element.replace(newComment);
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-4
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -74,10 +75,7 @@ public class StaticPseudoFunctionalStyleMethodInspection extends BaseJavaBatchLo
|
||||
if (qName == null) {
|
||||
return;
|
||||
}
|
||||
final int dotIndex = qName.lastIndexOf('.');
|
||||
if (dotIndex >= 0) {
|
||||
qName = qName.substring(dotIndex + 1);
|
||||
}
|
||||
qName = StringUtil.getShortName(qName);
|
||||
final Collection<StaticPseudoFunctionalStyleMethodOptions.PipelineElement> handlerInfos = myOptions.findElementsByMethodName(qName);
|
||||
if (handlerInfos.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class JavaFormattingModelBuilder implements FormattingModelBuilder {
|
||||
LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
|
||||
CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
|
||||
JavaCodeStyleSettings customJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
|
||||
Block block = AbstractJavaBlock.createJavaBlock(fileElement, commonSettings, customJavaSettings);
|
||||
Block block = AbstractJavaBlock.newJavaBlock(fileElement, commonSettings, customJavaSettings);
|
||||
FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
|
||||
return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,18 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
this(node, wrap, indent, settings, javaSettings, JavaWrapManager.INSTANCE, alignmentStrategy);
|
||||
}
|
||||
|
||||
private AbstractJavaBlock(@NotNull ASTNode ignored,
|
||||
@NotNull CommonCodeStyleSettings commonSettings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings) {
|
||||
super(ignored, null, null);
|
||||
mySettings = commonSettings;
|
||||
myJavaSettings = javaSettings;
|
||||
myIndentSettings = commonSettings.getIndentOptions();
|
||||
myIndent = null;
|
||||
myWrapManager = JavaWrapManager.INSTANCE;
|
||||
myAlignmentStrategy = AlignmentStrategy.getNullStrategy();
|
||||
}
|
||||
|
||||
protected AbstractJavaBlock(@NotNull final ASTNode node,
|
||||
final Wrap wrap,
|
||||
final Indent indent,
|
||||
@@ -116,33 +128,33 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Block createJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
@Nullable Indent indent,
|
||||
@Nullable Wrap wrap,
|
||||
Alignment alignment) {
|
||||
public Block createJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
@Nullable Indent indent,
|
||||
@Nullable Wrap wrap,
|
||||
Alignment alignment) {
|
||||
return createJavaBlock(child, settings, javaSettings,indent, wrap, AlignmentStrategy.wrap(alignment));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Block createJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
final Indent indent,
|
||||
@Nullable Wrap wrap,
|
||||
@NotNull AlignmentStrategy alignmentStrategy) {
|
||||
public Block createJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
final Indent indent,
|
||||
@Nullable Wrap wrap,
|
||||
@NotNull AlignmentStrategy alignmentStrategy) {
|
||||
return createJavaBlock(child, settings, javaSettings, indent, wrap, alignmentStrategy, -1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Block createJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
@Nullable Indent indent,
|
||||
Wrap wrap,
|
||||
@NotNull AlignmentStrategy alignmentStrategy,
|
||||
int startOffset) {
|
||||
private Block createJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
@Nullable Indent indent,
|
||||
Wrap wrap,
|
||||
@NotNull AlignmentStrategy alignmentStrategy,
|
||||
int startOffset) {
|
||||
Indent actualIndent = indent == null ? getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)) : indent;
|
||||
final IElementType elementType = child.getElementType();
|
||||
Alignment alignment = alignmentStrategy.getAlignment(elementType);
|
||||
@@ -164,7 +176,8 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
if (isStatement(child, child.getTreeParent())) {
|
||||
return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
|
||||
}
|
||||
if (child instanceof PsiComment &&
|
||||
if (isBuildInjectedBlocks() &&
|
||||
child instanceof PsiComment &&
|
||||
child instanceof PsiLanguageInjectionHost &&
|
||||
InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) {
|
||||
return new CommentWithInjectionBlock(child, wrap, alignment, indent, settings, javaSettings);
|
||||
@@ -194,12 +207,26 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Block createJavaBlock(@NotNull ASTNode child,
|
||||
public static Block newJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings) {
|
||||
return createJavaBlock(
|
||||
child, settings, javaSettings, getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)), null, AlignmentStrategy.getNullStrategy()
|
||||
);
|
||||
final Indent indent = getDefaultSubtreeIndent(child, getJavaIndentOptions(settings));
|
||||
return newJavaBlock(child, settings, javaSettings, indent, null, AlignmentStrategy.getNullStrategy());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Block newJavaBlock(@NotNull ASTNode child,
|
||||
@NotNull CommonCodeStyleSettings settings,
|
||||
@NotNull JavaCodeStyleSettings javaSettings,
|
||||
@Nullable Indent indent,
|
||||
@Nullable Wrap wrap,
|
||||
@NotNull AlignmentStrategy strategy) {
|
||||
return new AbstractJavaBlock(child, settings, javaSettings) {
|
||||
@Override
|
||||
protected List<Block> buildChildren() {
|
||||
return null;
|
||||
}
|
||||
}.createJavaBlock(child, settings, javaSettings, indent, wrap, strategy);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SyntheticBlockBuilder {
|
||||
final ASTNode firstNode = subNodes.get(0);
|
||||
if (firstNode.getElementType() == JavaTokenType.DOT) {
|
||||
AlignmentStrategy strategy = AlignmentStrategy.getNullStrategy();
|
||||
Block block = createJavaBlock(firstNode, mySettings, myJavaSettings, Indent.getNoneIndent(), null, strategy);
|
||||
Block block = newJavaBlock(firstNode, mySettings, myJavaSettings, Indent.getNoneIndent(), null, strategy);
|
||||
subBlocks.add(block);
|
||||
subNodes.remove(0);
|
||||
if (!subNodes.isEmpty()) {
|
||||
@@ -67,7 +67,7 @@ public class SyntheticBlockBuilder {
|
||||
final ArrayList<Block> result = new ArrayList<Block>();
|
||||
for (ASTNode node : subNodes) {
|
||||
Indent indent = Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS);
|
||||
result.add(createJavaBlock(node, mySettings, myJavaSettings, indent, null, AlignmentStrategy.getNullStrategy()));
|
||||
result.add(newJavaBlock(node, mySettings, myJavaSettings, indent, null, AlignmentStrategy.getNullStrategy()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+3
@@ -31,6 +31,7 @@ import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -268,6 +269,8 @@ public class JavaChildWrapArranger {
|
||||
|
||||
private static boolean isTypeAnnotationOrFalseIfDumb(@NotNull ASTNode child) {
|
||||
PsiElement node = child.getPsi();
|
||||
PsiElement next = PsiTreeUtil.skipSiblingsForward(node, PsiWhiteSpace.class, PsiAnnotation.class);
|
||||
if (next instanceof PsiKeyword) return false;
|
||||
return !DumbService.isDumb(node.getProject()) && isTypeAnnotation(node);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class ReplaceConstructorWithBuilderAction extends BaseRefactoringAction{
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
final PsiElement elementAt = file.findElementAt(offset);
|
||||
final PsiClass psiClass = ReplaceConstructorWithBuilderHandler.getParentNamedClass(elementAt);
|
||||
return psiClass != null && psiClass.getConstructors().length > 0;
|
||||
return psiClass != null && psiClass.getConstructors().length > 0 && !psiClass.isEnum();
|
||||
}
|
||||
|
||||
protected boolean isEnabledOnElements(@NotNull final PsiElement[] elements) {
|
||||
|
||||
+20
-3
@@ -17,8 +17,10 @@ package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.replaceConstructorWithFactory.ReplaceConstructorWithFactoryHandler;
|
||||
@@ -32,10 +34,25 @@ public class ReplaceConstructorWithFactoryAction extends BaseRefactoringAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
|
||||
return elements.length == 1 &&
|
||||
(elements[0] instanceof PsiMethod && ((PsiMethod)elements[0]).isConstructor() || elements[0] instanceof PsiClass)
|
||||
&& elements[0].getLanguage().isKindOf(JavaLanguage.INSTANCE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element,
|
||||
@NotNull Editor editor,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull DataContext context) {
|
||||
return (element instanceof PsiMethod &&
|
||||
((PsiMethod)element).isConstructor() &&
|
||||
acceptClass(((PsiMethod)element).getContainingClass()) ||
|
||||
acceptClass(element))
|
||||
&& element.getLanguage().isKindOf(JavaLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
private static boolean acceptClass(PsiElement element) {
|
||||
return element instanceof PsiClass && !((PsiClass)element).isEnum();
|
||||
}
|
||||
|
||||
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ public class JavaChangeSignatureHandler implements ChangeSignatureHandler {
|
||||
return elementParent;
|
||||
}
|
||||
if (elementParent instanceof PsiClass && ((PsiClass)elementParent).getNameIdentifier()==element) {
|
||||
if (((PsiClass)elementParent).isAnnotationType()) {
|
||||
if (((PsiClass)elementParent).isAnnotationType() || ((PsiClass)elementParent).isEnum()) {
|
||||
return null;
|
||||
}
|
||||
return elementParent;
|
||||
|
||||
+11
-6
@@ -22,17 +22,17 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class EncapsulateFieldsHandler implements RefactoringActionHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.encapsulateFields.EncapsulateFieldsHandler");
|
||||
@@ -108,8 +108,13 @@ public class EncapsulateFieldsHandler implements RefactoringActionHandler {
|
||||
}
|
||||
|
||||
LOG.assertTrue(aClass != null);
|
||||
final PsiField[] fields = aClass.getFields();
|
||||
if (fields.length == 0) {
|
||||
final List<PsiField> fields = ContainerUtil.filter(aClass.getFields(), new Condition<PsiField>() {
|
||||
@Override
|
||||
public boolean value(PsiField field) {
|
||||
return !(field instanceof PsiEnumConstant);
|
||||
}
|
||||
});
|
||||
if (fields.isEmpty()) {
|
||||
CommonRefactoringUtil.showErrorHint(project, CommonDataKeys.EDITOR.getData(dataContext), "Class has no fields to encapsulate",
|
||||
REFACTORING_NAME, HelpID.ENCAPSULATE_FIELDS);
|
||||
return;
|
||||
|
||||
+11
-1
@@ -17,6 +17,7 @@ package com.intellij.refactoring.encapsulateFields;
|
||||
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -25,10 +26,13 @@ import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
@@ -307,7 +311,13 @@ public class JavaEncapsulateFieldHelper extends EncapsulateFieldHelper {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiField[] getApplicableFields(@NotNull PsiClass aClass) {
|
||||
return aClass.getFields();
|
||||
final List<PsiField> fields = ContainerUtil.filter(aClass.getFields(), new Condition<PsiField>() {
|
||||
@Override
|
||||
public boolean value(PsiField field) {
|
||||
return !(field instanceof PsiEnumConstant);
|
||||
}
|
||||
});
|
||||
return fields.toArray(new PsiField[fields.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ class ExtractInterfaceDialog extends JavaExtractSuperBaseDialog {
|
||||
return element.hasModifierProperty(PsiModifier.PUBLIC)
|
||||
&& !element.hasModifierProperty(PsiModifier.STATIC);
|
||||
}
|
||||
else if (element instanceof PsiField) {
|
||||
else if (element instanceof PsiField && !(element instanceof PsiEnumConstant)) {
|
||||
return element.hasModifierProperty(PsiModifier.FINAL)
|
||||
&& element.hasModifierProperty(PsiModifier.STATIC)
|
||||
&& element.hasModifierProperty(PsiModifier.PUBLIC);
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ public class MethodDuplicatesHandler implements RefactoringActionHandler {
|
||||
}
|
||||
} else if (member instanceof PsiField) {
|
||||
final PsiField field = (PsiField)member;
|
||||
if (!field.hasInitializer()) {
|
||||
if (field.getInitializer() == null) {
|
||||
return "Field " + member.getName() + " doesn't have initializer";
|
||||
}
|
||||
final PsiClass containingClass = field.getContainingClass();
|
||||
|
||||
@@ -812,26 +812,13 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
}
|
||||
}
|
||||
|
||||
if (glb != null) {
|
||||
if (!((PsiWildcardType)substituted).isSuper()) {
|
||||
substituted = glb instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)glb).getWildcard()
|
||||
: PsiWildcardType.createExtends(manager, glb);
|
||||
}
|
||||
else {
|
||||
if (captureContext != null) {
|
||||
final PsiCapturedWildcardType capturedWildcardType = oldSubstituted instanceof PsiCapturedWildcardType
|
||||
? (PsiCapturedWildcardType)oldSubstituted
|
||||
: (PsiCapturedWildcardType)captureSubstitutor.substitute(typeParameter);
|
||||
LOG.assertTrue(capturedWildcardType != null);
|
||||
capturedWildcardType.setUpperBound(glb);
|
||||
return capturedWildcardType;
|
||||
}
|
||||
}
|
||||
if (glb != null && !((PsiWildcardType)substituted).isSuper()) {
|
||||
substituted = glb instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)glb).getWildcard()
|
||||
: PsiWildcardType.createExtends(manager, glb);
|
||||
}
|
||||
}
|
||||
|
||||
if (captureContext != null) {
|
||||
LOG.assertTrue(substituted instanceof PsiWildcardType, substituted);
|
||||
substituted =
|
||||
oldSubstituted instanceof PsiCapturedWildcardType && substituted.equals(((PsiCapturedWildcardType)oldSubstituted).getWildcard())
|
||||
? oldSubstituted
|
||||
|
||||
@@ -164,10 +164,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
}
|
||||
if (newBound instanceof PsiCapturedWildcardType) {
|
||||
final PsiWildcardType wildcard = ((PsiCapturedWildcardType)newBound).getWildcard();
|
||||
if (wildcardType.isExtends() != wildcard.isExtends()) {
|
||||
return !wildcard.isBounded() ? newBound : rebound(wildcardType, newBound);
|
||||
}
|
||||
if (wildcard.isBounded()) {
|
||||
if (wildcard.isBounded() && wildcardType.isExtends() == wildcard.isExtends()) {
|
||||
return newBound;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ public class TypeEqualityConstraint implements ConstraintFormula {
|
||||
final PsiSubstitutor sSubstitutor = sResult.getSubstitutor();
|
||||
for (PsiTypeParameter typeParameter : tClass.getTypeParameters()) {
|
||||
final PsiType tSubstituted = tSubstitutor.substitute(typeParameter);
|
||||
final PsiType sSubstituted = sSubstitutor.substitute(typeParameter);
|
||||
final PsiType sSubstituted = sSubstitutor.substituteWithBoundsPromotion(typeParameter);
|
||||
if (tSubstituted != null && sSubstituted != null) {
|
||||
constraints.add(new TypeEqualityConstraint(tSubstituted, sSubstituted));
|
||||
}
|
||||
|
||||
+1
-1
@@ -519,6 +519,6 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon(int flags) {
|
||||
return AllIcons.Nodes.AnonymousClass;
|
||||
return AllIcons.Nodes.MethodReference;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.scope.conflictResolvers;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
@@ -71,12 +72,14 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
|
||||
@Override
|
||||
public final CandidateInfo resolveConflict(@NotNull final List<CandidateInfo> conflicts){
|
||||
/*
|
||||
//non-default policies
|
||||
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(myArgumentsList);
|
||||
if (properties != null) {
|
||||
final PsiMethod method = properties.getMethod();
|
||||
LOG.error("Recursive conflict resolution for:" + method + "; " + myArgumentsList.getText() + "; file="
|
||||
+ (method == null ? "<unknown>" : method.getContainingFile()));
|
||||
}
|
||||
}*/
|
||||
return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, true, new Computable<CandidateInfo>() {
|
||||
@Override
|
||||
public CandidateInfo compute() {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class A<T> {
|
||||
<S extends A<? extends T>> void foo(){}
|
||||
void bar(A<?> a){
|
||||
a.<<error descr="Type parameter 'A' is not within its bound; should extend 'A<capture<?>>'">A<?></error>>foo();
|
||||
a.<<error descr="Type parameter 'A' is not within its bound; should extend 'A<? extends capture<?>>'">A<?></error>>foo();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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<?>>)' in 'A' cannot be applied to '(A<A<? extends capture<?>>>)'">(x.foo())</error>;
|
||||
}
|
||||
|
||||
<S> void baz(A<A<? extends S>> x){}
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ abstract class X {
|
||||
abstract <T> void copy(List<T> dest, List<? extends T> src);
|
||||
|
||||
void foo(List<?> x, List<?> y){
|
||||
copy<error descr="'copy(java.util.List<capture<?>>, java.util.List<capture<?>>)' in 'X' cannot be applied to '(java.util.List<capture<?>>, java.util.List<capture<?>>)'">(x, y)</error>;
|
||||
copy<error descr="'copy(java.util.List<capture<?>>, java.util.List<? extends capture<?>>)' in 'X' cannot be applied to '(java.util.List<capture<?>>, java.util.List<capture<?>>)'">(x, y)</error>;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class C<T extends C<? extends C<? extends T>>>{
|
||||
void foo(C<?> x){
|
||||
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'C<capture<?>>'">bar(x)</error>;
|
||||
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'C<? extends capture<?>>'">bar(x)</error>;
|
||||
}
|
||||
<T extends C<? extends T>> void bar(C<T> x){}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ abstract class A<T> {
|
||||
<K> void baz7(B<K, K> a) {}
|
||||
abstract B<T, ? extends T> foo7();
|
||||
void bar7(A<?> a) {
|
||||
baz7<error descr="'baz7(B<capture<?>,capture<?>>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo7())</error>;
|
||||
baz7<error descr="'baz7(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo7())</error>;
|
||||
}
|
||||
|
||||
<K> void baz9(B<K, K> a) {}
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ class Test {
|
||||
|
||||
traverser.filter<error descr="'filter(Predicate<? super capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'">(filter)</error>;
|
||||
traverser.filter1<error descr="'filter1(Predicate<capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'">(filter)</error>;
|
||||
traverser.filter2<error descr="'filter2(Predicate<capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'">(filter)</error>; //"'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'"
|
||||
traverser.filter2<error descr="'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'">(filter)</error>; //"'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'"
|
||||
|
||||
traverser1.filter<error descr="'filter(Predicate<? super capture<? extends java.lang.String>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'">(filter)</error>;
|
||||
traverser1.filter1<error descr="'filter1(Predicate<capture<? extends java.lang.String>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<?>>)'">(filter)</error>;
|
||||
@@ -36,7 +36,7 @@ class Test {
|
||||
|
||||
traverser.filter<error descr="'filter(Predicate<? super capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'">(filter1)</error>;
|
||||
traverser.filter1<error descr="'filter1(Predicate<capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'">(filter1)</error>;
|
||||
traverser.filter2<error descr="'filter2(Predicate<capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'">(filter1)</error>;// "'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'"
|
||||
traverser.filter2<error descr="'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'">(filter1)</error>;// "'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'"
|
||||
|
||||
traverser1.filter<error descr="'filter(Predicate<? super capture<? extends java.lang.String>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'">(filter1)</error>;
|
||||
traverser1.filter1<error descr="'filter1(Predicate<capture<? extends java.lang.String>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? extends java.lang.String>>)'">(filter1)</error>;
|
||||
@@ -50,7 +50,7 @@ class Test {
|
||||
|
||||
traverser.filter<error descr="'filter(Predicate<? super capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'">(filter2)</error>;
|
||||
traverser.filter1<error descr="'filter1(Predicate<capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'">(filter2)</error>;
|
||||
traverser.filter2<error descr="'filter2(Predicate<capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'">(filter2)</error>;// "'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'"
|
||||
traverser.filter2<error descr="'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'">(filter2)</error>;// "'filter2(Predicate<? extends capture<?>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'"
|
||||
|
||||
traverser1.filter(filter2);
|
||||
traverser1.filter1<error descr="'filter1(Predicate<capture<? extends java.lang.String>>)' in 'NodeTraverser' cannot be applied to '(Predicate<capture<? super java.lang.String>>)'">(filter2)</error>;
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ class Use99n extends Use99<GenericTest99D<?>,Double> {
|
||||
|
||||
class IDEA79360 {
|
||||
public static void main(Map<?, ?> map, Map<Object, Object> test) {
|
||||
map.putAll<error descr="'putAll(java.util.Map<capture<?>,capture<?>>)' in 'java.util.Map' cannot be applied to '(java.util.Map<java.lang.Object,java.lang.Object>)'">(test)</error>;
|
||||
map.putAll<error descr="'putAll(java.util.Map<? extends capture<?>,? extends capture<?>>)' in 'java.util.Map' cannot be applied to '(java.util.Map<java.lang.Object,java.lang.Object>)'">(test)</error>;
|
||||
map.put<error descr="'put(capture<?>, capture<?>)' in 'java.util.Map' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>;
|
||||
map.put<error descr="'put(capture<?>, capture<?>)' in 'java.util.Map' cannot be applied to '(java.lang.Object, java.lang.Object)'">(new Object(), new Object())</error>;
|
||||
map = new HashMap<Object, Object>(test);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class A<T> {
|
||||
<S extends A<? extends T>> void foo(){}
|
||||
void bar(A<?> a){
|
||||
a.<<error descr="Type parameter 'A' is not within its bound; should extend 'A<capture<?>>'">A<?></error>>foo();
|
||||
a.<<error descr="Type parameter 'A' is not within its bound; should extend 'A<? extends capture<?>>'">A<?></error>>foo();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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<?>>)' in 'A' cannot be applied to '(A<A<? extends capture<?>>>)'">(x.foo())</error>;
|
||||
}
|
||||
|
||||
<S> void baz(A<A<? extends S>> x){}
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ class B<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bar(B<?> b){ baz<error descr="'baz(A<? extends T,T>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(b.foo())</error>; }
|
||||
void bar(B<?> b){ baz<error descr="'baz(A<? extends T,T>)' in 'B' cannot be applied to '(A<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(b.foo())</error>; }
|
||||
<T> void baz(A<? extends T,T> a) {}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class C<T extends C<? extends C<? extends T>>>{
|
||||
void foo(C<?> x){
|
||||
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'C<capture<?>>'">bar(x)</error>;
|
||||
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'C<? extends capture<?>>'">bar(x)</error>;
|
||||
}
|
||||
<T extends C<? extends T>> void bar(C<T> x){}
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ abstract class A<T> {
|
||||
<K> void baz37(B<K, ? extends K> a) {}
|
||||
abstract B<T,? extends T> foo37();
|
||||
void bar37(A<?> a){
|
||||
baz37<error descr="'baz37(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo37())</error>;
|
||||
baz37<error descr="'baz37(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo37())</error>;
|
||||
}
|
||||
|
||||
<K> void baz39(B<K, ? extends K> a) {}
|
||||
@@ -16,7 +16,7 @@ abstract class A<T> {
|
||||
<K> void baz52(B<K, ? extends K> a) {}
|
||||
abstract B<? extends T,? extends T> foo52();
|
||||
void bar52(A<?> a){
|
||||
baz52<error descr="'baz52(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo52())</error>;
|
||||
baz52<error descr="'baz52(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo52())</error>;
|
||||
}
|
||||
|
||||
<K> void baz54(B<K, ? extends K> a) {}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ abstract class A<T> {
|
||||
<K> void baz256(B<? super K, ?> a) {}
|
||||
abstract B<? super T, ? extends T> foo256();
|
||||
void bar256(A<?> a) {
|
||||
baz256<error descr="'baz256(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo256())</error>;
|
||||
baz256<error descr="'baz256(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo256())</error>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ class Use99n extends Use99<GenericTest99D<?>,Double> {
|
||||
|
||||
class IDEA79360 {
|
||||
public static void main(Map<?, ?> map, Map<Object, Object> test) {
|
||||
map.putAll<error descr="'putAll(java.util.Map<capture<?>,capture<?>>)' in 'java.util.Map' cannot be applied to '(java.util.Map<java.lang.Object,java.lang.Object>)'">(test)</error>;
|
||||
map.putAll<error descr="'putAll(java.util.Map<? extends capture<?>,? extends capture<?>>)' in 'java.util.Map' cannot be applied to '(java.util.Map<java.lang.Object,java.lang.Object>)'">(test)</error>;
|
||||
map.put<error descr="'put(capture<?>, capture<?>)' in 'java.util.Map' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>;
|
||||
map.put<error descr="'put(capture<?>, capture<?>)' in 'java.util.Map' cannot be applied to '(java.lang.Object, java.lang.Object)'">(new Object(), new Object())</error>;
|
||||
map = new HashMap<Object, Object>(test);
|
||||
|
||||
+24
-24
@@ -47,7 +47,7 @@ abstract class A<T> {
|
||||
<K> void baz7(B<K, K> a) {}
|
||||
abstract B<T,? extends T> foo7();
|
||||
void bar7(A<?> a){
|
||||
baz7<error descr="'baz7(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo7())</error>;
|
||||
baz7<error descr="'baz7(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo7())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ abstract class A<T> {
|
||||
<K> void baz16(B<K, K> a) {}
|
||||
abstract B<? super T,? extends T> foo16();
|
||||
void bar16(A<?> a){
|
||||
baz16<error descr="'baz16(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo16())</error>;
|
||||
baz16<error descr="'baz16(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo16())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ abstract class A<T> {
|
||||
<K> void baz22(B<K, K> a) {}
|
||||
abstract B<? extends T,? extends T> foo22();
|
||||
void bar22(A<?> a){
|
||||
baz22<error descr="'baz22(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo22())</error>;
|
||||
baz22<error descr="'baz22(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo22())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ abstract class A<T> {
|
||||
<K> void baz25(B<K, K> a) {}
|
||||
abstract B<? extends T,?> foo25();
|
||||
void bar25(A<?> a){
|
||||
baz25<error descr="'baz25(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo25())</error>;
|
||||
baz25<error descr="'baz25(B<java.lang.Object,java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<?>>)'">(a.foo25())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ abstract class A<T> {
|
||||
<K> void baz37(B<K, ? extends K> a) {}
|
||||
abstract B<T,? extends T> foo37();
|
||||
void bar37(A<?> a){
|
||||
baz37<error descr="'baz37(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo37())</error>;
|
||||
baz37<error descr="'baz37(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo37())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ abstract class A<T> {
|
||||
<K> void baz46(B<K, ? extends K> a) {}
|
||||
abstract B<? super T,? extends T> foo46();
|
||||
void bar46(A<?> a){
|
||||
baz46<error descr="'baz46(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo46())</error>;
|
||||
baz46<error descr="'baz46(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo46())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ abstract class A<T> {
|
||||
<K> void baz52(B<K, ? extends K> a) {}
|
||||
abstract B<? extends T,? extends T> foo52();
|
||||
void bar52(A<?> a){
|
||||
baz52<error descr="'baz52(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo52())</error>;
|
||||
baz52<error descr="'baz52(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo52())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ abstract class A<T> {
|
||||
<K> void baz55(B<K, ? extends K> a) {}
|
||||
abstract B<? extends T,?> foo55();
|
||||
void bar55(A<?> a){
|
||||
baz55<error descr="'baz55(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo55())</error>;
|
||||
baz55<error descr="'baz55(B<K,? extends K>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<?>>)'">(a.foo55())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ abstract class A<T> {
|
||||
<K> void baz67(B<K, ? super K> a) {}
|
||||
abstract B<T,? extends T> foo67();
|
||||
void bar67(A<?> a){
|
||||
baz67<error descr="'baz67(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo67())</error>;
|
||||
baz67<error descr="'baz67(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo67())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ abstract class A<T> {
|
||||
<K> void baz76(B<K, ? super K> a) {}
|
||||
abstract B<? super T,? extends T> foo76();
|
||||
void bar76(A<?> a){
|
||||
baz76<error descr="'baz76(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo76())</error>;
|
||||
baz76<error descr="'baz76(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo76())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -572,7 +572,7 @@ abstract class A<T> {
|
||||
<K> void baz82(B<K, ? super K> a) {}
|
||||
abstract B<? extends T,? extends T> foo82();
|
||||
void bar82(A<?> a){
|
||||
baz82<error descr="'baz82(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo82())</error>;
|
||||
baz82<error descr="'baz82(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo82())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -593,7 +593,7 @@ abstract class A<T> {
|
||||
<K> void baz85(B<K, ? super K> a) {}
|
||||
abstract B<? extends T,?> foo85();
|
||||
void bar85(A<?> a){
|
||||
baz85<error descr="'baz85(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo85())</error>;
|
||||
baz85<error descr="'baz85(B<java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<?>>)'">(a.foo85())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1097,7 +1097,7 @@ abstract class A<T> {
|
||||
<K> void baz157(B<? extends K, ? super K> a) {}
|
||||
abstract B<T,? extends T> foo157();
|
||||
void bar157(A<?> a){
|
||||
baz157<error descr="'baz157(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo157())</error>;
|
||||
baz157<error descr="'baz157(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo157())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1160,7 +1160,7 @@ abstract class A<T> {
|
||||
<K> void baz166(B<? extends K, ? super K> a) {}
|
||||
abstract B<? super T,? extends T> foo166();
|
||||
void bar166(A<?> a){
|
||||
baz166<error descr="'baz166(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo166())</error>;
|
||||
baz166<error descr="'baz166(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo166())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1202,7 +1202,7 @@ abstract class A<T> {
|
||||
<K> void baz172(B<? extends K, ? super K> a) {}
|
||||
abstract B<? extends T,? extends T> foo172();
|
||||
void bar172(A<?> a){
|
||||
baz172<error descr="'baz172(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo172())</error>;
|
||||
baz172<error descr="'baz172(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo172())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1223,7 +1223,7 @@ abstract class A<T> {
|
||||
<K> void baz175(B<? extends K, ? super K> a) {}
|
||||
abstract B<? extends T,?> foo175();
|
||||
void bar175(A<?> a){
|
||||
baz175<error descr="'baz175(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo175())</error>;
|
||||
baz175<error descr="'baz175(B<?,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<?>>)'">(a.foo175())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1517,7 +1517,7 @@ abstract class A<T> {
|
||||
<K> void baz217(B<? super K, ? super K> a) {}
|
||||
abstract B<T,? extends T> foo217();
|
||||
void bar217(A<?> a){
|
||||
baz217<error descr="'baz217(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo217())</error>;
|
||||
baz217<error descr="'baz217(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo217())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1580,7 +1580,7 @@ abstract class A<T> {
|
||||
<K> void baz226(B<? super K, ? super K> a) {}
|
||||
abstract B<? super T,? extends T> foo226();
|
||||
void bar226(A<?> a){
|
||||
baz226<error descr="'baz226(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo226())</error>;
|
||||
baz226<error descr="'baz226(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo226())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1622,7 +1622,7 @@ abstract class A<T> {
|
||||
<K> void baz232(B<? super K, ? super K> a) {}
|
||||
abstract B<? extends T,? extends T> foo232();
|
||||
void bar232(A<?> a){
|
||||
baz232<error descr="'baz232(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo232())</error>;
|
||||
baz232<error descr="'baz232(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo232())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1643,7 +1643,7 @@ abstract class A<T> {
|
||||
<K> void baz235(B<? super K, ? super K> a) {}
|
||||
abstract B<? extends T,?> foo235();
|
||||
void bar235(A<?> a){
|
||||
baz235<error descr="'baz235(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo235())</error>;
|
||||
baz235<error descr="'baz235(B<? super java.lang.Object,? super java.lang.Object>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<?>>)'">(a.foo235())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1727,7 +1727,7 @@ abstract class A<T> {
|
||||
<K> void baz247(B<? super K, ?> a) {}
|
||||
abstract B<T,? extends T> foo247();
|
||||
void bar247(A<?> a){
|
||||
baz247<error descr="'baz247(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo247())</error>;
|
||||
baz247<error descr="'baz247(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<?>,capture<? extends capture<?>>>)'">(a.foo247())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1790,7 +1790,7 @@ abstract class A<T> {
|
||||
<K> void baz256(B<? super K, ?> a) {}
|
||||
abstract B<? super T,? extends T> foo256();
|
||||
void bar256(A<?> a){
|
||||
baz256<error descr="'baz256(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<?>>)'">(a.foo256())</error>;
|
||||
baz256<error descr="'baz256(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? super capture<?>>,capture<? extends capture<?>>>)'">(a.foo256())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1832,7 +1832,7 @@ abstract class A<T> {
|
||||
<K> void baz262(B<? super K, ?> a) {}
|
||||
abstract B<? extends T,? extends T> foo262();
|
||||
void bar262(A<?> a){
|
||||
baz262<error descr="'baz262(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo262())</error>;
|
||||
baz262<error descr="'baz262(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<? extends capture<?>>>)'">(a.foo262())</error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1853,7 +1853,7 @@ abstract class A<T> {
|
||||
<K> void baz265(B<? super K, ?> a) {}
|
||||
abstract B<? extends T,?> foo265();
|
||||
void bar265(A<?> a){
|
||||
baz265<error descr="'baz265(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo265())</error>;
|
||||
baz265<error descr="'baz265(B<? super java.lang.Object,?>)' in 'A' cannot be applied to '(B<capture<? extends capture<?>>,capture<?>>)'">(a.foo265())</error>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2146
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
enum <caret>E {
|
||||
;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
enum A {
|
||||
B;
|
||||
private int i;
|
||||
|
||||
public int getI() {
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setI(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
enum A {
|
||||
B;
|
||||
private int i;
|
||||
}
|
||||
+4
@@ -37,6 +37,10 @@ public class GenericsHighlightingGenerated8Test extends LightDaemonAnalyzerTestC
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void _testUnrelatedClassesExtendsTypeParams() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable);
|
||||
|
||||
-4
@@ -34,8 +34,4 @@ public class DefaultFileTemplateUsageInspectionTest extends LightCodeInsightFixt
|
||||
myFixture.enableInspections(new DefaultFileTemplateUsageInspection());
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testWtf() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
package com.intellij.psi.autodetect;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.fileTypes.PlainTextLanguage;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.autodetect.LineIndentInfo;
|
||||
import com.intellij.psi.codeStyle.autodetect.LineIndentInfoBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JavaAutoDetectIndentTest extends AbstractIndentAutoDetectionTest {
|
||||
|
||||
@@ -49,4 +56,105 @@ public class JavaAutoDetectIndentTest extends AbstractIndentAutoDetectionTest {
|
||||
doTestIndentSize(4);
|
||||
}
|
||||
|
||||
public void testBigFileWithIndent2() {
|
||||
doTestIndentSize(2);
|
||||
}
|
||||
|
||||
public void testBigFileWithIndent8() {
|
||||
doTestIndentSize(8);
|
||||
}
|
||||
|
||||
public void testBigFileWithIndent4() {
|
||||
doTestIndentSize(4);
|
||||
}
|
||||
|
||||
public void testFileWithTabs() {
|
||||
doTestTabsUsed();
|
||||
}
|
||||
|
||||
public void testSimpleIndent() {
|
||||
doTestMaxUsedIndent(2, 6);
|
||||
}
|
||||
|
||||
public void testManyComments() {
|
||||
doTestMaxUsedIndent(2, 6);
|
||||
}
|
||||
|
||||
public void testManyZeroRelativeIndent() {
|
||||
doTestMaxUsedIndent(2);
|
||||
}
|
||||
|
||||
public void testSmallFileWithIndent8() {
|
||||
doTestMaxUsedIndent(8);
|
||||
}
|
||||
|
||||
public void testSmallFileWithTabs() {
|
||||
doTestTabsUsed();
|
||||
}
|
||||
|
||||
public void testNoIndentsUseLanguageSpecificSettings() {
|
||||
CommonCodeStyleSettings.IndentOptions options = new CommonCodeStyleSettings.IndentOptions();
|
||||
options.USE_TAB_CHARACTER = true;
|
||||
|
||||
doTestTabsUsed(options);
|
||||
}
|
||||
|
||||
public void testSpacesToNumbers() throws Exception {
|
||||
String text = " i\n" +
|
||||
" a\n" +
|
||||
" t\n";
|
||||
doTestLineToIndentMapping(text, 5, 4, 10);
|
||||
}
|
||||
|
||||
public void testEmptyLines() throws Exception {
|
||||
doTestLineToIndentMapping(" \n\n\n", -1, -1, -1);
|
||||
}
|
||||
|
||||
public void testSpacesInSimpleClass() {
|
||||
doTestLineToIndentMapping(
|
||||
"public class A {\n" +
|
||||
"\n" +
|
||||
" public void test() {\n" +
|
||||
" int a = 2;\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" public void a() {\n" +
|
||||
" }\n" +
|
||||
"}",
|
||||
0, -1, 4, 6, 4, -1, 4, 4, 0
|
||||
);
|
||||
}
|
||||
|
||||
public void testComplexIndents() {
|
||||
doTestLineToIndentMapping(
|
||||
"class Test\n" +
|
||||
"{\n" +
|
||||
" int a;\n" +
|
||||
" int b;\n" +
|
||||
" \n" +
|
||||
" public void test() {\n" +
|
||||
" int c;\n" +
|
||||
" }\n" +
|
||||
" \n" +
|
||||
" public void run() {\n" +
|
||||
" Runnable runnable = new Runnable() {\n" +
|
||||
" @Override\n" +
|
||||
" public void run() {\n" +
|
||||
" System.out.println(\"Hello!\");\n" +
|
||||
" }\n" +
|
||||
" };\n" +
|
||||
" }\n" +
|
||||
"}",
|
||||
0, 0, 2, 2, -1, 2, 4, 2, -1, 2, 4, 6, 6, 8, 6, 4, 2, 0
|
||||
);
|
||||
}
|
||||
|
||||
private static void doTestLineToIndentMapping(@NotNull CharSequence text, int... spacesForLine) {
|
||||
List<LineIndentInfo> list = new LineIndentInfoBuilder(text, PlainTextLanguage.INSTANCE).build();
|
||||
Assert.assertEquals(list.size(), spacesForLine.length);
|
||||
for (int i = 0; i < spacesForLine.length; i++) {
|
||||
int indentSize = list.get(i).getIndentSize();
|
||||
Assert.assertEquals("Mismatch on line " + i, spacesForLine[i], indentSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,11 @@ public class ChangeSignatureTargetTest extends LightCodeInsightTestCase {
|
||||
doTest("A1");
|
||||
}
|
||||
|
||||
public void testDisabledForEnum() throws Exception {
|
||||
configureByFile("/refactoring/changeSignatureTarget/" + getTestName(true) + ".java");
|
||||
assertNull(new JavaChangeSignatureHandler().findTargetMember(getFile(), getEditor()));
|
||||
}
|
||||
|
||||
private void doTest(String expectedMemberName) throws Exception {
|
||||
String basePath = "/refactoring/changeSignatureTarget/" + getTestName(true);
|
||||
@NonNls final String filePath = basePath + ".java";
|
||||
|
||||
@@ -25,16 +25,11 @@ import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.refactoring.encapsulateFields.EncapsulateFieldsDescriptor;
|
||||
import com.intellij.refactoring.encapsulateFields.EncapsulateFieldsProcessor;
|
||||
import com.intellij.refactoring.encapsulateFields.FieldDescriptor;
|
||||
import com.intellij.refactoring.encapsulateFields.FieldDescriptorImpl;
|
||||
import com.intellij.refactoring.encapsulateFields.*;
|
||||
import com.intellij.refactoring.util.DocCommentPolicy;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -82,7 +77,15 @@ public class EncapsulateFieldsTest extends MultiFileTestCase{
|
||||
assertNotNull("Tested class not found", aClass);
|
||||
final PsiField field = aClass.findFieldByName("i", false);
|
||||
assertNotNull(field);
|
||||
doTest(aClass, field, null, true, true);
|
||||
doTest(aClass, null, true, true, field);
|
||||
});
|
||||
}
|
||||
|
||||
public void testFilterEnumConstants() throws Exception {
|
||||
doTest((rootDir, rootAfter) -> {
|
||||
final PsiClass aClass = myJavaFacade.findClass("A", GlobalSearchScope.projectScope(myProject));
|
||||
assertNotNull("Tested class not found", aClass);
|
||||
doTest(aClass, null, true, true, new JavaEncapsulateFieldHelper().getApplicableFields(aClass));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,28 +112,32 @@ public class EncapsulateFieldsTest extends MultiFileTestCase{
|
||||
assertNotNull("Tested class not found", aClass);
|
||||
|
||||
|
||||
doTest(aClass, aClass.findFieldByName(fieldName, false), conflicts, true, true);
|
||||
doTest(aClass, conflicts, true, true, aClass.findFieldByName(fieldName, false));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void doTest(final PsiClass aClass,
|
||||
final PsiField field,
|
||||
final String conflicts,
|
||||
final boolean generateGetters,
|
||||
final boolean generateSetters) {
|
||||
final boolean generateSetters,
|
||||
final PsiField... fields) {
|
||||
try {
|
||||
final Project project = aClass.getProject();
|
||||
EncapsulateFieldsProcessor processor = new EncapsulateFieldsProcessor(project, new EncapsulateFieldsDescriptor() {
|
||||
@Override
|
||||
public FieldDescriptor[] getSelectedFields() {
|
||||
return new FieldDescriptor[]{new FieldDescriptorImpl(
|
||||
field,
|
||||
GenerateMembersUtil.suggestGetterName(field),
|
||||
GenerateMembersUtil.suggestSetterName(field),
|
||||
isToEncapsulateGet() ? GenerateMembersUtil.generateGetterPrototype(field) : null,
|
||||
isToEncapsulateSet() ? GenerateMembersUtil.generateSetterPrototype(field) : null
|
||||
)};
|
||||
final FieldDescriptor[] descriptors = new FieldDescriptor[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
descriptors[i] = new FieldDescriptorImpl(
|
||||
fields[i],
|
||||
GenerateMembersUtil.suggestGetterName(fields[i]),
|
||||
GenerateMembersUtil.suggestSetterName(fields[i]),
|
||||
isToEncapsulateGet() ? GenerateMembersUtil.generateGetterPrototype(fields[i]) : null,
|
||||
isToEncapsulateSet() ? GenerateMembersUtil.generateSetterPrototype(fields[i]) : null
|
||||
);
|
||||
}
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
<orderEntry type="module" module-name="java-psi-api" />
|
||||
<orderEntry type="module" module-name="java-impl" />
|
||||
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
|
||||
<orderEntry type="module" module-name="spellchecker" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -1,4 +1,3 @@
|
||||
manifest.unexpected.token=Unexpected token
|
||||
manifest.colon.expected=':' expected
|
||||
manifest.whitespace.expected=Whitespace expected
|
||||
manifest.header.expected=Header expected
|
||||
@@ -11,4 +10,6 @@ inspection.group=Manifest
|
||||
inspection.newline.message=Manifest file doesn't end with a final newline
|
||||
inspection.newline.fix=Add newline
|
||||
inspection.header.message=Header name is unknown or spelled incorrectly
|
||||
inspection.header.fix=Change to ''{0}''
|
||||
inspection.header.ui.label=Custom headers:
|
||||
inspection.header.rename.fix=Change to ''{0}''
|
||||
inspection.header.remember.fix=Add ''{0}'' to custom headers
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2009, Osmorc Development Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
* * Neither the name of 'Osmorc Development Team' nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jetbrains.lang.manifest.header;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A match describes how good a header known to a particular header provider matches a given header.
|
||||
* The name of the given header may contain typos and so there may be no perfect match. A perfect match will
|
||||
* have a Levenshtein distance of 0. Worse matches will have greater Levenshtein distances.
|
||||
*
|
||||
* @author Robert F. Beeger (robert@beeger.net)
|
||||
*/
|
||||
public class HeaderNameMatch implements Comparable<HeaderNameMatch> {
|
||||
private final int myDistance;
|
||||
private final String myHeaderName;
|
||||
|
||||
public HeaderNameMatch(int distance, @NotNull String headerName) {
|
||||
myDistance = distance;
|
||||
myHeaderName = headerName;
|
||||
}
|
||||
|
||||
public int getDistance() {
|
||||
return myDistance;
|
||||
}
|
||||
|
||||
public String getHeaderName() {
|
||||
return myHeaderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches are compared based on their distance.
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(@NotNull HeaderNameMatch o) {
|
||||
return getDistance() - o.getDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HeaderNameMatch that = (HeaderNameMatch)o;
|
||||
|
||||
return myDistance == that.myDistance && myHeaderName.equals(that.myHeaderName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myDistance;
|
||||
result = 31 * result + myHeaderName.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -27,19 +27,17 @@ package org.jetbrains.lang.manifest.header;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.text.LevenshteinDistance;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.lang.manifest.psi.Header;
|
||||
import org.jetbrains.lang.manifest.psi.HeaderValuePart;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* @author Robert F. Beeger (robert@beeger.net)
|
||||
@@ -53,7 +51,7 @@ public class HeaderParserRepository {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<String, HeaderParser> compute() {
|
||||
Map<String, HeaderParser> map = ContainerUtil.newHashMap();
|
||||
Map<String, HeaderParser> map = new THashMap<String, HeaderParser>(CaseInsensitiveStringHashingStrategy.INSTANCE);
|
||||
for (HeaderParserProvider provider : Extensions.getExtensions(HeaderParserProvider.EP_NAME)) {
|
||||
map.putAll(provider.getHeaderParsers());
|
||||
}
|
||||
@@ -66,23 +64,6 @@ public class HeaderParserRepository {
|
||||
return myParsers.getValue().get(headerName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<HeaderNameMatch> getMatches(@NotNull String headerName) {
|
||||
HeaderParser parser = myParsers.getValue().get(headerName);
|
||||
if (parser != null) {
|
||||
return ContainerUtil.emptyList();
|
||||
}
|
||||
|
||||
LevenshteinDistance distance = new LevenshteinDistance();
|
||||
Set<HeaderNameMatch> result = new TreeSet<HeaderNameMatch>();
|
||||
for (Map.Entry<String, HeaderParser> entry : myParsers.getValue().entrySet()) {
|
||||
String otherName = entry.getKey();
|
||||
int dist = distance.calculateMetrics(headerName, otherName);
|
||||
result.add(new HeaderNameMatch(dist, otherName));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getAllHeaderNames() {
|
||||
return myParsers.getValue().keySet();
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.lang.manifest.highlighting;
|
||||
|
||||
import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.lang.manifest.ManifestBundle;
|
||||
|
||||
public abstract class AbstractManifestQuickFix extends LocalQuickFixOnPsiElement {
|
||||
protected AbstractManifestQuickFix(@NotNull PsiElement element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final String getFamilyName() {
|
||||
return ManifestBundle.message("inspection.group");
|
||||
}
|
||||
}
|
||||
+1
-7
@@ -61,7 +61,7 @@ public class MissingFinalNewlineInspection extends LocalInspectionTool {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class AddNewlineQuickFix extends LocalQuickFixOnPsiElement {
|
||||
private static class AddNewlineQuickFix extends AbstractManifestQuickFix {
|
||||
private AddNewlineQuickFix(Section section) {
|
||||
super(section);
|
||||
}
|
||||
@@ -72,12 +72,6 @@ public class MissingFinalNewlineInspection extends LocalInspectionTool {
|
||||
return ManifestBundle.message("inspection.newline.fix");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return ManifestBundle.message("inspection.group");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
|
||||
PsiElement lastChild = startElement.getLastChild();
|
||||
|
||||
+113
-28
@@ -26,25 +26,42 @@ package org.jetbrains.lang.manifest.highlighting;
|
||||
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.spellchecker.engine.Suggestion;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
|
||||
import com.intellij.util.text.EditDistance;
|
||||
import com.intellij.util.xmlb.annotations.AbstractCollection;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.lang.manifest.ManifestBundle;
|
||||
import org.jetbrains.lang.manifest.header.HeaderNameMatch;
|
||||
import org.jetbrains.lang.manifest.header.HeaderParserRepository;
|
||||
import org.jetbrains.lang.manifest.psi.Header;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Robert F. Beeger (robert@beeger.net)
|
||||
*/
|
||||
public class MisspelledHeaderInspection extends LocalInspectionTool {
|
||||
private static final int MAX_SUGGESTIONS = 10;
|
||||
private static final int MAX_SUGGESTIONS = 5;
|
||||
private static final int MAX_DISTANCE = 4;
|
||||
private static final int TYPO_DISTANCE = 2;
|
||||
|
||||
private HeaderParserRepository myRepository;
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "header")
|
||||
public final Set<String> CUSTOM_HEADERS = new THashSet<String>(CaseInsensitiveStringHashingStrategy.INSTANCE);
|
||||
|
||||
private final HeaderParserRepository myRepository;
|
||||
|
||||
public MisspelledHeaderInspection() {
|
||||
myRepository = HeaderParserRepository.getInstance();
|
||||
@@ -58,49 +75,117 @@ public class MisspelledHeaderInspection extends LocalInspectionTool {
|
||||
public void visitElement(PsiElement element) {
|
||||
if (element instanceof Header) {
|
||||
Header header = (Header)element;
|
||||
Collection<HeaderNameMatch> matches = myRepository.getMatches(header.getName());
|
||||
if (!matches.isEmpty()) {
|
||||
List<HeaderNameSpellingQuickFix> fixes = ContainerUtil.newArrayListWithCapacity(MAX_SUGGESTIONS);
|
||||
for (HeaderNameMatch match : matches) {
|
||||
fixes.add(new HeaderNameSpellingQuickFix(header, match));
|
||||
if (fixes.size() == MAX_SUGGESTIONS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
holder.registerProblem(
|
||||
header.getNameElement(), ManifestBundle.message("inspection.header.message"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes.toArray(new HeaderNameSpellingQuickFix[fixes.size()])
|
||||
);
|
||||
String headerName = header.getName();
|
||||
|
||||
SortedSet<Suggestion> matches = new TreeSet<Suggestion>();
|
||||
addMatches(headerName, CUSTOM_HEADERS, matches);
|
||||
addMatches(headerName, myRepository.getAllHeaderNames(), matches);
|
||||
|
||||
Suggestion bestMatch = ContainerUtil.getFirstItem(matches);
|
||||
if (bestMatch != null && headerName.equals(bestMatch.getWord())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>();
|
||||
for (Suggestion match : matches) {
|
||||
fixes.add(new HeaderRenameQuickFix(header, match.getWord()));
|
||||
if (fixes.size() == MAX_SUGGESTIONS) break;
|
||||
}
|
||||
if (bestMatch == null || bestMatch.getMetrics() > TYPO_DISTANCE) {
|
||||
fixes.add(new CustomHeaderQuickFix(header, CUSTOM_HEADERS));
|
||||
}
|
||||
holder.registerProblem(
|
||||
header.getNameElement(), ManifestBundle.message("inspection.header.message"),
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fixes.toArray(new LocalQuickFix[fixes.size()])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void addMatches(String headerName, Collection<String> headers, SortedSet<Suggestion> matches) {
|
||||
for (String candidate : headers) {
|
||||
int distance = EditDistance.optimalAlignment(headerName, candidate, false);
|
||||
if (distance <= MAX_DISTANCE) {
|
||||
matches.add(new Suggestion(candidate, distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class HeaderNameSpellingQuickFix implements LocalQuickFix {
|
||||
private final Header myHeader;
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
return new OptionsPanel(CUSTOM_HEADERS);
|
||||
}
|
||||
|
||||
private static class OptionsPanel extends JPanel {
|
||||
public OptionsPanel(final Set<String> headers) {
|
||||
super(new BorderLayout(5, 5));
|
||||
|
||||
add(new JLabel(ManifestBundle.message("inspection.header.ui.label")), BorderLayout.NORTH);
|
||||
|
||||
final JTextArea area = new JTextArea("");
|
||||
add(area, BorderLayout.CENTER);
|
||||
if (!headers.isEmpty()) {
|
||||
area.setText(StringUtil.join(new TreeSet<String>(headers), "\n"));
|
||||
}
|
||||
|
||||
area.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
headers.clear();
|
||||
for (String line : StringUtil.split(area.getText(), "\n")) {
|
||||
String header = line.trim();
|
||||
if (!header.isEmpty()) {
|
||||
headers.add(header);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static class HeaderRenameQuickFix extends AbstractManifestQuickFix {
|
||||
private final String myNewName;
|
||||
|
||||
private HeaderNameSpellingQuickFix(Header header, HeaderNameMatch match) {
|
||||
myHeader = header;
|
||||
myNewName = match.getHeaderName();
|
||||
private HeaderRenameQuickFix(Header header, String newName) {
|
||||
super(header);
|
||||
myNewName = newName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return ManifestBundle.message("inspection.header.fix", myNewName);
|
||||
public String getText() {
|
||||
return ManifestBundle.message("inspection.header.rename.fix", myNewName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
|
||||
((Header)startElement).setName(myNewName);
|
||||
}
|
||||
}
|
||||
|
||||
private static class CustomHeaderQuickFix extends AbstractManifestQuickFix {
|
||||
private final String myHeaderName;
|
||||
private final Collection<String> myHeaders;
|
||||
|
||||
private CustomHeaderQuickFix(Header header, Collection<String> headers) {
|
||||
super(header);
|
||||
myHeaderName = header.getName();
|
||||
myHeaders = headers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return ManifestBundle.message("inspection.group");
|
||||
public String getText() {
|
||||
return ManifestBundle.message("inspection.header.remember.fix", myHeaderName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
myHeader.setName(myNewName);
|
||||
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
|
||||
myHeaders.add(myHeaderName);
|
||||
|
||||
InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
|
||||
InspectionProfileManager.getInstance().fireProfileChanged(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,7 +18,6 @@ package org.jetbrains.lang.manifest;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.lang.manifest.psi.Header;
|
||||
import org.jetbrains.lang.manifest.psi.HeaderValue;
|
||||
@@ -27,16 +26,16 @@ import org.jetbrains.lang.manifest.psi.ManifestFile;
|
||||
public class ManifestPsiTest extends LightIdeaTestCase {
|
||||
public void testFile() {
|
||||
ManifestFile file = createFile("");
|
||||
Assert.assertEquals(0, file.getSections().size());
|
||||
Assert.assertNull(file.getMainSection());
|
||||
Assert.assertEquals(0, file.getHeaders().size());
|
||||
assertEquals(0, file.getSections().size());
|
||||
assertNull(file.getMainSection());
|
||||
assertEquals(0, file.getHeaders().size());
|
||||
|
||||
file = createFile("Header: value\n\nAnother-Header: another value\n");
|
||||
Assert.assertEquals(2, file.getSections().size());
|
||||
Assert.assertNotNull(file.getMainSection());
|
||||
Assert.assertEquals(1, file.getHeaders().size());
|
||||
Assert.assertNotNull(file.getHeader("Header"));
|
||||
Assert.assertNull(file.getHeader("Another-Header"));
|
||||
assertEquals(2, file.getSections().size());
|
||||
assertNotNull(file.getMainSection());
|
||||
assertEquals(1, file.getHeaders().size());
|
||||
assertNotNull(file.getHeader("Header"));
|
||||
assertNull(file.getHeader("Another-Header"));
|
||||
}
|
||||
|
||||
public void testHeader() {
|
||||
@@ -54,15 +53,15 @@ public class ManifestPsiTest extends LightIdeaTestCase {
|
||||
|
||||
private static void assertHeaderValue(ManifestFile file, String name, @Nullable String expected) {
|
||||
Header header = file.getHeader(name);
|
||||
Assert.assertNotNull(header);
|
||||
assertNotNull(header);
|
||||
|
||||
HeaderValue value = header.getHeaderValue();
|
||||
if (expected == null) {
|
||||
Assert.assertNull(value);
|
||||
assertNull(value);
|
||||
}
|
||||
else {
|
||||
Assert.assertNotNull(value);
|
||||
Assert.assertEquals(expected, value.getUnwrappedText());
|
||||
assertNotNull(value);
|
||||
assertEquals(expected, value.getUnwrappedText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,61 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.lang.manifest.highlighting.MisspelledHeaderInspection;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MisspelledHeaderInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.enableInspections(new MisspelledHeaderInspection());
|
||||
public void testNoProblem() {
|
||||
doTest("Manifest-Version: 1.0", 0);
|
||||
}
|
||||
|
||||
public void testNoProblem() {
|
||||
myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "Manifest-Version: 1.0\n");
|
||||
assertEquals(0, myFixture.getAvailableIntentions().size());
|
||||
public void testMixedCase() {
|
||||
doTest("<weak_warning descr=\"Header name is unknown or spelled incorrectly\">manifest-version</weak_warning>: 1.0", 1);
|
||||
}
|
||||
|
||||
public void testMissedDash() {
|
||||
doTest("<weak_warning descr=\"Header name is unknown or spelled incorrectly\">ManifestVersion</weak_warning>: 1.0", 1);
|
||||
}
|
||||
|
||||
public void testMisspelled() {
|
||||
doTest("<weak_warning descr=\"Header name is unknown or spelled incorrectly\">MainFestVersion</weak_warning>: 1.0", 1);
|
||||
}
|
||||
|
||||
public void testTotallyIncorrect() {
|
||||
doTest("<weak_warning descr=\"Header name is unknown or spelled incorrectly\">some_totally_impossible_header</weak_warning>: -", 0);
|
||||
}
|
||||
|
||||
public void testFix() {
|
||||
myFixture.enableInspections(new MisspelledHeaderInspection());
|
||||
myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "ManifestVersion: 1.0\n");
|
||||
List<IntentionAction> intentions = myFixture.filterAvailableIntentions("Change to");
|
||||
assertTrue(intentions.size() > 0);
|
||||
assertEquals(1, intentions.size());
|
||||
myFixture.launchAction(intentions.get(0));
|
||||
myFixture.checkResult("Manifest-Version: 1.0\n");
|
||||
}
|
||||
|
||||
public void testCustomHeader() {
|
||||
MisspelledHeaderInspection inspection = new MisspelledHeaderInspection();
|
||||
inspection.CUSTOM_HEADERS.add("Custom-Header");
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "Custom-Header: -\n");
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
public void testCustomHeaderFix() {
|
||||
MisspelledHeaderInspection inspection = new MisspelledHeaderInspection();
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, "Custom-Header: -\n");
|
||||
List<IntentionAction> intentions = myFixture.filterAvailableIntentions("Add ");
|
||||
assertEquals(1, intentions.size());
|
||||
myFixture.launchAction(intentions.get(0));
|
||||
assertEquals(Collections.singleton("Custom-Header"), inspection.CUSTOM_HEADERS);
|
||||
}
|
||||
|
||||
private void doTest(String text, int expected) {
|
||||
myFixture.enableInspections(new MisspelledHeaderInspection());
|
||||
myFixture.configureByText(ManifestFileTypeFactory.MANIFEST, text + "\n");
|
||||
myFixture.checkHighlighting();
|
||||
assertEquals(expected, myFixture.filterAvailableIntentions("Change to").size());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -269,7 +269,7 @@ public class JavaReplaceHandler extends StructuralReplaceHandler {
|
||||
if (firstChild instanceof PsiModifierList) {
|
||||
final PsiModifierList modifierList = (PsiModifierList)firstChild;
|
||||
for (PsiElement child : modifierList.getChildren()) {
|
||||
elementParent.add(child);
|
||||
elementParent.addBefore(child, elementToReplace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-5
@@ -81,7 +81,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
private final ExternalInfo myExternalInfo = new ExternalInfo();
|
||||
protected InspectionProfileImpl mySource;
|
||||
private Map<String, ToolsImpl> myTools = new THashMap<String, ToolsImpl>();
|
||||
private Map<String, Boolean> myDisplayLevelMap;
|
||||
private volatile Map<String, Boolean> myDisplayLevelMap;
|
||||
@Attribute("is_locked")
|
||||
private boolean myLockedProfile;
|
||||
private final InspectionProfileImpl myBaseProfile;
|
||||
@@ -933,10 +933,17 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
|
||||
private Map<String, Boolean> getDisplayLevelMap() {
|
||||
if (myBaseProfile == null) return null;
|
||||
if (myDisplayLevelMap == null) {
|
||||
initInspectionTools(null);
|
||||
myDisplayLevelMap = new TreeMap<String, Boolean>();
|
||||
for (String toolId : myTools.keySet()) {
|
||||
myDisplayLevelMap.put(toolId, toolSettingsAreEqual(toolId, myBaseProfile, this));
|
||||
// Synchronizing on myExternalInfo as initInspectionTools() synchronizes on it internally.
|
||||
synchronized (myExternalInfo) {
|
||||
if (myDisplayLevelMap == null) {
|
||||
initInspectionTools(null);
|
||||
TreeMap<String,Boolean> map = new TreeMap<String, Boolean>();
|
||||
for (String toolId : myTools.keySet()) {
|
||||
map.put(toolId, toolSettingsAreEqual(toolId, myBaseProfile, this));
|
||||
}
|
||||
myDisplayLevelMap = map;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
return myDisplayLevelMap;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.builtInWebServer;
|
||||
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -106,7 +107,7 @@ public final class BuiltInWebServer extends HttpRequestHandler {
|
||||
host = host.substring(1, host.length() - 1);
|
||||
}
|
||||
|
||||
if (isIpv6 || Character.digit(host.charAt(0), 10) != -1 || host.charAt(0) == ':' || isOwnHostName(host)) {
|
||||
if (isIpv6 || InetAddresses.isInetAddress(host) || isOwnHostName(host) || host.endsWith(".ngrok.io")) {
|
||||
if (urlDecoder.path().length() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,14 @@ public abstract class ArchiveHandler {
|
||||
public final long length;
|
||||
public final long timestamp;
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* Please use the {@link EntryInfo#EntryInfo(ArchiveHandler.EntryInfo, CharSequence, boolean, long, long)} instead
|
||||
*/
|
||||
public EntryInfo(EntryInfo parent, @NotNull String shortName, boolean isDirectory, long length, long timestamp) {
|
||||
this(parent, (CharSequence) shortName, isDirectory, length, timestamp);
|
||||
}
|
||||
|
||||
public EntryInfo(EntryInfo parent, @NotNull CharSequence shortName, boolean isDirectory, long length, long timestamp) {
|
||||
this.parent = parent;
|
||||
this.shortName = shortName;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -82,6 +82,7 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
private boolean myEventsHandling = false;
|
||||
private final boolean myAssertThreading;
|
||||
private volatile boolean myDoingBulkUpdate = false;
|
||||
private boolean myUpdatingBulkModeStatus;
|
||||
private volatile boolean myAcceptSlashR = false;
|
||||
private boolean myChangeInProgress;
|
||||
private volatile int myBufferSize;
|
||||
@@ -971,12 +972,21 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
// do not fire listeners or otherwise updateStarted() will be called more times than updateFinished()
|
||||
return;
|
||||
}
|
||||
myDoingBulkUpdate = value;
|
||||
if (value) {
|
||||
getPublisher().updateStarted(this);
|
||||
if (myUpdatingBulkModeStatus) {
|
||||
throw new IllegalStateException("Detected bulk mode status update from DocumentBulkUpdateListener");
|
||||
}
|
||||
else {
|
||||
getPublisher().updateFinished(this);
|
||||
myUpdatingBulkModeStatus = true;
|
||||
try {
|
||||
myDoingBulkUpdate = value;
|
||||
if (value) {
|
||||
getPublisher().updateStarted(this);
|
||||
}
|
||||
else {
|
||||
getPublisher().updateFinished(this);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myUpdatingBulkModeStatus = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ public final class LoadTextUtil {
|
||||
return text;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " + file.getPresentableUrl());
|
||||
throw new IllegalArgumentException("Attempt to load text for binary file which doesn't have a decompiler plugged in: " + file.getPresentableUrl() + ". File type: " + fileType.getName());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
+5
@@ -23,6 +23,7 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.ui.mac.foundation.MacUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.DoubleArrayList;
|
||||
import com.intellij.util.containers.Stack;
|
||||
@@ -43,6 +44,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
private volatile boolean myFinished;
|
||||
|
||||
private volatile boolean myIndeterminate;
|
||||
private volatile Object myMacActivity;
|
||||
|
||||
private Stack<String> myTextStack;
|
||||
private DoubleArrayList myFractionStack;
|
||||
@@ -68,6 +70,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
myText = "";
|
||||
myFraction = 0;
|
||||
myText2 = "";
|
||||
myMacActivity = MacUtil.wakeUpNeo(toString());
|
||||
myRunning = true;
|
||||
}
|
||||
|
||||
@@ -82,6 +85,8 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements
|
||||
LOG.assertTrue(myRunning, "stop() should be called only if start() called before");
|
||||
myRunning = false;
|
||||
myFinished = true;
|
||||
MacUtil.matrixHasYou(myMacActivity);
|
||||
myMacActivity = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,7 @@ import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class PsiDocumentManagerBase extends PsiDocumentManager implements DocumentListener, DocumentBulkUpdateListener {
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiDocumentManagerImpl");
|
||||
static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.PsiDocumentManagerImpl");
|
||||
private static final Key<Document> HARD_REF_TO_DOCUMENT = Key.create("HARD_REFERENCE_TO_DOCUMENT");
|
||||
private static final Key<PsiFile> HARD_REF_TO_PSI = Key.create("HARD_REFERENCE_TO_PSI");
|
||||
private static final Key<List<Runnable>> ACTION_AFTER_COMMIT = Key.create("ACTION_AFTER_COMMIT");
|
||||
@@ -73,11 +73,11 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final SmartPointerManagerImpl mySmartPointerManager;
|
||||
|
||||
public PsiDocumentManagerBase(@NotNull final Project project,
|
||||
@NotNull PsiManager psiManager,
|
||||
@NotNull SmartPointerManager smartPointerManager,
|
||||
@NotNull MessageBus bus,
|
||||
@NonNls @NotNull final DocumentCommitProcessor documentCommitProcessor) {
|
||||
protected PsiDocumentManagerBase(@NotNull final Project project,
|
||||
@NotNull PsiManager psiManager,
|
||||
@NotNull SmartPointerManager smartPointerManager,
|
||||
@NotNull MessageBus bus,
|
||||
@NonNls @NotNull final DocumentCommitProcessor documentCommitProcessor) {
|
||||
myProject = project;
|
||||
myPsiManager = psiManager;
|
||||
myDocumentCommitProcessor = documentCommitProcessor;
|
||||
@@ -132,7 +132,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FileViewProvider getCachedViewProvider(@NotNull Document document) {
|
||||
FileViewProvider getCachedViewProvider(@NotNull Document document) {
|
||||
final VirtualFile virtualFile = getVirtualFile(document);
|
||||
if (virtualFile == null) return null;
|
||||
return getCachedViewProvider(virtualFile);
|
||||
@@ -149,7 +149,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected PsiFile getCachedPsiFile(@NotNull VirtualFile virtualFile) {
|
||||
PsiFile getCachedPsiFile(@NotNull VirtualFile virtualFile) {
|
||||
return ((PsiManagerEx)myPsiManager).getFileManager().getCachedPsiFile(virtualFile);
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
public void doPostponedOperationsAndUnblockDocument(@NotNull Document doc) {
|
||||
}
|
||||
|
||||
protected void fireDocumentCreated(@NotNull Document document, PsiFile file) {
|
||||
void fireDocumentCreated(@NotNull Document document, PsiFile file) {
|
||||
for (Listener listener : myListeners) {
|
||||
listener.documentCreated(document, file);
|
||||
}
|
||||
@@ -611,7 +611,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
boolean isBulk = document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate();
|
||||
|
||||
boolean isRelevant = virtualFile != null && isRelevant(virtualFile);
|
||||
if (!isBulk && isRelevant) {
|
||||
if (!isBulk && isRelevant && shouldNotifySmartPointers(virtualFile)) {
|
||||
mySmartPointerManager.fastenBelts(virtualFile, event.getOffset(), null);
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
boolean isBulk = document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate();
|
||||
|
||||
boolean isRelevant = virtualFile != null && isRelevant(virtualFile);
|
||||
if (!isBulk && isRelevant) {
|
||||
if (!isBulk && isRelevant && shouldNotifySmartPointers(virtualFile)) {
|
||||
mySmartPointerManager.unfastenBelts(virtualFile, event.getOffset());
|
||||
}
|
||||
|
||||
@@ -711,19 +711,20 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
@Override
|
||||
public void updateStarted(@NotNull Document document) {
|
||||
final VirtualFile virtualFile = getVirtualFile(document);
|
||||
if (virtualFile == null || !isRelevant(virtualFile)) return;
|
||||
|
||||
mySmartPointerManager.fastenBelts(virtualFile, 0, null);
|
||||
if (virtualFile != null && isRelevant(virtualFile) && shouldNotifySmartPointers(virtualFile)) {
|
||||
mySmartPointerManager.fastenBelts(virtualFile, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFinished(@NotNull Document document) {
|
||||
final VirtualFile virtualFile = getVirtualFile(document);
|
||||
if (virtualFile == null || !isRelevant(virtualFile)) return;
|
||||
mySmartPointerManager.unfastenBelts(virtualFile, 0);
|
||||
if (virtualFile != null && isRelevant(virtualFile) && shouldNotifySmartPointers(virtualFile)) {
|
||||
mySmartPointerManager.unfastenBelts(virtualFile, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCommitWithoutPsi(@NotNull Document document) {
|
||||
void handleCommitWithoutPsi(@NotNull Document document) {
|
||||
final Pair<CharSequence, Long> prevPair = myLastCommittedTexts.remove(document);
|
||||
if (prevPair == null) {
|
||||
return;
|
||||
@@ -770,6 +771,10 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
return !virtualFile.getFileType().isBinary() && !myProject.isDisposed();
|
||||
}
|
||||
|
||||
boolean shouldNotifySmartPointers(@NotNull VirtualFile virtualFile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean checkConsistency(@NotNull PsiFile psiFile, @NotNull Document document) {
|
||||
//todo hack
|
||||
if (psiFile.getVirtualFile() == null) return true;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRange(@NotNull Segment range) {
|
||||
void setRange(@NotNull Segment range) {
|
||||
mySyncStartOffset = range.getStartOffset();
|
||||
mySyncEndOffset = range.getEndOffset();
|
||||
}
|
||||
@@ -267,11 +267,13 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
}
|
||||
|
||||
int getSyncEndOffset() {
|
||||
return mySyncEndOffset;
|
||||
RangeMarker marker = myRangeMarker;
|
||||
return marker == null || !marker.isValid() ? mySyncEndOffset : marker.getEndOffset();
|
||||
}
|
||||
|
||||
int getSyncStartOffset() {
|
||||
return mySyncStartOffset;
|
||||
RangeMarker marker = myRangeMarker;
|
||||
return marker == null || !marker.isValid() ? mySyncStartOffset : marker.getStartOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,8 +290,8 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
&& myType == otherInfo.myType
|
||||
&& mySyncMarkerIsValid
|
||||
&& otherInfo.mySyncMarkerIsValid
|
||||
&& mySyncStartOffset == otherInfo.mySyncStartOffset
|
||||
&& mySyncEndOffset == otherInfo.mySyncEndOffset
|
||||
&& getSyncStartOffset() == otherInfo.getSyncStartOffset()
|
||||
&& getSyncEndOffset() == otherInfo.getSyncEndOffset()
|
||||
;
|
||||
}
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
|
||||
+13
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -78,9 +78,7 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
|
||||
public final synchronized boolean checkContentIsEqualTo(CharSequence sequence) {
|
||||
final Document document = getDocument();
|
||||
return document instanceof DocumentEx &&
|
||||
Comparing.equal(document.getImmutableCharSequence(), sequence) &&
|
||||
!((DocumentEx)document).isInBulkUpdate();
|
||||
return document != null && isInSyncWithDocument() && Comparing.equal(document.getImmutableCharSequence(), sequence);
|
||||
}
|
||||
|
||||
public EditorColorsScheme getScheme() {
|
||||
@@ -107,13 +105,12 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
@Override
|
||||
public HighlighterIterator createIterator(int startOffset) {
|
||||
synchronized (this) {
|
||||
final Document document = getDocument();
|
||||
if(document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) {
|
||||
((DocumentEx)document).setInBulkUpdate(false); // bulk mode failed
|
||||
}
|
||||
|
||||
if (mySegments.getSegmentCount() == 0 && document != null && document.getTextLength() > 0) {
|
||||
// bulk mode was reset
|
||||
if (!isInSyncWithDocument()) {
|
||||
final Document document = getDocument();
|
||||
assert document != null;
|
||||
if(document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) {
|
||||
((DocumentEx)document).setInBulkUpdate(false); // bulk mode failed
|
||||
}
|
||||
doSetText(document.getCharsSequence());
|
||||
}
|
||||
|
||||
@@ -131,6 +128,11 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
Project project = myEditor.getProject();
|
||||
return project != null && !project.isDisposed();
|
||||
}
|
||||
|
||||
private boolean isInSyncWithDocument() {
|
||||
Document document = getDocument();
|
||||
return document == null || document.getTextLength() == 0 || mySegments.getSegmentCount() > 0;
|
||||
}
|
||||
|
||||
private static boolean isInitialState(int data) {
|
||||
return data >= 0;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 447 B |
Binary file not shown.
|
After Width: | Height: | Size: 1023 B |
@@ -29,11 +29,14 @@ import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -50,6 +53,7 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
|
||||
private final WindowManager myWindowManager;
|
||||
private final EditorFactory myEditorFactory;
|
||||
private final SmartPointerManagerImpl mySmartPointerManager;
|
||||
|
||||
private final Map<Window, List<Editor>> myWindowToEditorsMap = new HashMap<Window, List<Editor>>();
|
||||
private final Map<Window, WindowFocusListener> myWindowToWindowFocusListenerMap = new HashMap<Window, WindowFocusListener>();
|
||||
@@ -63,10 +67,12 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
|
||||
public EditorTracker(Project project,
|
||||
final WindowManager windowManager,
|
||||
final EditorFactory editorFactory) {
|
||||
final EditorFactory editorFactory,
|
||||
SmartPointerManager manager) {
|
||||
super(project);
|
||||
myWindowManager = windowManager;
|
||||
myEditorFactory = editorFactory;
|
||||
mySmartPointerManager = (SmartPointerManagerImpl)manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +91,7 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myEditorFactoryListener.dispose(null);
|
||||
myEditorFactoryListener.executeOnRelease(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -225,7 +231,7 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
myDispatcher.getMulticaster().activeEditorsChanged(editors);
|
||||
}
|
||||
|
||||
public void addEditorTrackerListener(@NotNull EditorTrackerListener listener, @NotNull Disposable parentDisposable) {
|
||||
void addEditorTrackerListener(@NotNull EditorTrackerListener listener, @NotNull Disposable parentDisposable) {
|
||||
myDispatcher.addListener(listener,parentDisposable);
|
||||
}
|
||||
|
||||
@@ -236,7 +242,7 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
public void editorCreated(@NotNull EditorFactoryEvent event) {
|
||||
final Editor editor = event.getEditor();
|
||||
if (editor.getProject() != null && editor.getProject() != myProject) return;
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
|
||||
if (psiFile == null) return;
|
||||
|
||||
final JComponent component = editor.getComponent();
|
||||
@@ -244,7 +250,7 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
|
||||
final HierarchyListener hierarchyListener = new HierarchyListener() {
|
||||
@Override
|
||||
public void hierarchyChanged(HierarchyEvent e) {
|
||||
public void hierarchyChanged(@NotNull HierarchyEvent e) {
|
||||
registerEditor(editor);
|
||||
}
|
||||
};
|
||||
@@ -252,23 +258,32 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
|
||||
final FocusListener focusListener = new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
public void focusGained(@NotNull FocusEvent e) {
|
||||
editorFocused(editor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
public void focusLost(@NotNull FocusEvent e) {
|
||||
}
|
||||
};
|
||||
contentComponent.addFocusListener(focusListener);
|
||||
|
||||
final VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
myExecuteOnEditorRelease.put(event.getEditor(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
component.removeHierarchyListener(hierarchyListener);
|
||||
contentComponent.removeFocusListener(focusListener);
|
||||
// allow range markers in smart pointers to be collected
|
||||
if (virtualFile != null) {
|
||||
mySmartPointerManager.unfastenBelts(virtualFile, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// materialize all range markers and do not let them to be collected to improve responsiveness
|
||||
if (virtualFile != null) {
|
||||
mySmartPointerManager.fastenBelts(virtualFile, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -276,10 +291,10 @@ public class EditorTracker extends AbstractProjectComponent {
|
||||
final Editor editor = event.getEditor();
|
||||
if (editor.getProject() != null && editor.getProject() != myProject) return;
|
||||
unregisterEditor(editor);
|
||||
dispose(editor);
|
||||
executeOnRelease(editor);
|
||||
}
|
||||
|
||||
private void dispose(Editor editor) {
|
||||
private void executeOnRelease(Editor editor) {
|
||||
if (editor == null) {
|
||||
for (Runnable r : myExecuteOnEditorRelease.values()) {
|
||||
r.run();
|
||||
|
||||
+4
-2
@@ -34,6 +34,7 @@ import com.intellij.util.Alarm;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -102,7 +103,8 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
}
|
||||
|
||||
if (myCanceled) return false;
|
||||
if (myPopup.isDisposed()) return false;
|
||||
final JComponent content = myPopup.getContent();
|
||||
if (content == null || myPopup.isDisposed()) return false;
|
||||
|
||||
synchronized (lock) {
|
||||
if (myData.contains(element)) return true;
|
||||
@@ -126,7 +128,7 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
|
||||
myPopup.setCaption(getCaption(getCurrentSize()));
|
||||
myPopup.pack(true, true);
|
||||
}
|
||||
}, 200, ModalityState.stateForComponent(myPopup.getContent()));
|
||||
}, 200, ModalityState.stateForComponent(content));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
|
||||
|
||||
myBrowser = new Browser(this);
|
||||
|
||||
mySplitter = new Splitter(false, AnalysisUIOptions.getInstance(myProject).SPLITTER_PROPORTION);
|
||||
mySplitter = new OnePixelSplitter(false, AnalysisUIOptions.getInstance(myProject).SPLITTER_PROPORTION);
|
||||
|
||||
mySplitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT | SideBorder.RIGHT));
|
||||
mySplitter.setSecondComponent(myBrowser);
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
@@ -39,7 +38,6 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Element;
|
||||
@@ -66,7 +64,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
private final Map<String, RunnerAndConfigurationSettings> myConfigurations =
|
||||
new LinkedHashMap<String, RunnerAndConfigurationSettings>(); // template configurations are not included here
|
||||
private final Map<String, Boolean> mySharedConfigurations = new THashMap<String, Boolean>();
|
||||
private final Map<RunConfiguration, List<BeforeRunTask>> myConfigurationToBeforeTasksMap = new WeakHashMap<RunConfiguration, List<BeforeRunTask>>();
|
||||
private final Map<RunConfiguration, List<BeforeRunTask>> myConfigurationToBeforeTasksMap = ContainerUtil.createConcurrentWeakMap();
|
||||
|
||||
// When readExternal not all configuration may be loaded, so we need to remember the selected configuration
|
||||
// so that when it is eventually loaded, we can mark is as a selected.
|
||||
@@ -155,7 +153,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
@NotNull
|
||||
public RunnerAndConfigurationSettings createConfiguration(@NotNull final RunConfiguration runConfiguration,
|
||||
@NotNull final ConfigurationFactory factory) {
|
||||
assertDispatchThread();
|
||||
RunnerAndConfigurationSettings template = getConfigurationTemplate(factory);
|
||||
RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(this, runConfiguration, false);
|
||||
settings.importRunnerAndConfigurationSettings((RunnerAndConfigurationSettingsImpl)template);
|
||||
@@ -165,12 +162,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
return settings;
|
||||
}
|
||||
|
||||
private void assertDispatchThread() {
|
||||
if (myProject.isInitialized()) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myTemplateConfigurationsMap.clear();
|
||||
@@ -344,7 +335,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
public void addConfiguration(RunnerAndConfigurationSettings settings,
|
||||
boolean shared,
|
||||
List<BeforeRunTask> tasks, boolean addEnabledTemplateTasksIfAbsent) {
|
||||
assertDispatchThread();
|
||||
String existingId = findExistingConfigurationId(settings);
|
||||
String newId = settings.getUniqueID();
|
||||
RunnerAndConfigurationSettings existingSettings = null;
|
||||
@@ -425,7 +415,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
|
||||
@Override
|
||||
public void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings) {
|
||||
assertDispatchThread();
|
||||
if (settings == null) return;
|
||||
|
||||
for (Iterator<RunnerAndConfigurationSettings> it = getSortedConfigurations().iterator(); it.hasNext(); ) {
|
||||
@@ -818,7 +807,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
}
|
||||
|
||||
private void clear(boolean allConfigurations) {
|
||||
assertDispatchThread();
|
||||
List<RunnerAndConfigurationSettings> configurations;
|
||||
if (allConfigurations) {
|
||||
myConfigurations.clear();
|
||||
@@ -1147,7 +1135,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID) {
|
||||
assertDispatchThread();
|
||||
if (settings instanceof WrappingRunConfiguration) {
|
||||
return getBeforeRunTasks(((WrappingRunConfiguration)settings).getPeer(), taskProviderID);
|
||||
}
|
||||
@@ -1169,7 +1156,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
@Override
|
||||
@NotNull
|
||||
public List<BeforeRunTask> getBeforeRunTasks(final RunConfiguration settings) {
|
||||
assertDispatchThread();
|
||||
if (settings instanceof WrappingRunConfiguration) {
|
||||
return getBeforeRunTasks(((WrappingRunConfiguration)settings).getPeer());
|
||||
}
|
||||
@@ -1225,7 +1211,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
|
||||
@Override
|
||||
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, @NotNull List<BeforeRunTask> tasks, boolean addEnabledTemplateTasksIfAbsent) {
|
||||
assertDispatchThread();
|
||||
List<BeforeRunTask> result = new SmartList<BeforeRunTask>(tasks);
|
||||
if (addEnabledTemplateTasksIfAbsent) {
|
||||
List<BeforeRunTask> templates = getTemplateBeforeRunTasks(runConfiguration);
|
||||
@@ -1246,7 +1231,6 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
}
|
||||
|
||||
public final void resetBeforeRunTasks(final RunConfiguration runConfiguration) {
|
||||
assertDispatchThread();
|
||||
myConfigurationToBeforeTasksMap.remove(runConfiguration);
|
||||
fireBeforeRunTasksUpdated();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class FormatProcessor {
|
||||
public class FormatProcessor {
|
||||
|
||||
private static final Map<Alignment.Anchor, BlockAlignmentProcessor> ALIGNMENT_PROCESSORS =
|
||||
new EnumMap<Alignment.Anchor, BlockAlignmentProcessor>(Alignment.Anchor.class);
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.formatting;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
class IndentImpl extends Indent {
|
||||
public class IndentImpl extends Indent {
|
||||
private final boolean myIsAbsolute;
|
||||
private final boolean myRelativeToDirectParent;
|
||||
|
||||
@@ -38,7 +38,7 @@ class IndentImpl extends Indent {
|
||||
myEnforceIndentToChildren = enforceIndentToChildren;
|
||||
}
|
||||
|
||||
Type getType() {
|
||||
public Type getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.intellij.psi.codeStyle.autodetect;
|
||||
|
||||
import com.intellij.formatting.*;
|
||||
import com.intellij.lang.LanguageFormatting;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.formatter.common.NewLineBlocksIterator;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FormatterBasedLineIndentInfoBuilder {
|
||||
private static final int MAX_NEW_LINE_BLOCKS_TO_PROCESS = 500;
|
||||
|
||||
private final PsiFile myFile;
|
||||
private final Document myDocument;
|
||||
private final CharSequence myText;
|
||||
private final CodeStyleSettings mySettings;
|
||||
private final FormattingModelBuilder myFormattingModelBuilder;
|
||||
|
||||
public FormatterBasedLineIndentInfoBuilder(@NotNull PsiFile file) {
|
||||
Project project = file.getProject();
|
||||
|
||||
myFile = file;
|
||||
myDocument = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
myText = myDocument != null ? myDocument.getCharsSequence() : null;
|
||||
mySettings = CodeStyleSettingsManager.getSettings(project);
|
||||
myFormattingModelBuilder = LanguageFormatting.INSTANCE.forContext(myFile);
|
||||
}
|
||||
|
||||
public List<LineIndentInfo> build() {
|
||||
if (myText == null || myFormattingModelBuilder == null) return null;
|
||||
|
||||
List<Block> normallyIndentedBlocks = ContainerUtil.filter(getBlocksStartingNewLine(), new Condition<Block>() {
|
||||
@Override
|
||||
public boolean value(Block block) {
|
||||
Indent.Type type = block.getIndent() instanceof IndentImpl ? ((IndentImpl)block.getIndent()).getType() : null;
|
||||
return type == Indent.Type.NONE || type == Indent.Type.NORMAL;
|
||||
}
|
||||
});
|
||||
|
||||
return ContainerUtil.map(normallyIndentedBlocks, new Function<Block, LineIndentInfo>() {
|
||||
@Override
|
||||
public LineIndentInfo fun(Block newLineBlock) {
|
||||
int blockStartOffset = newLineBlock.getTextRange().getStartOffset();
|
||||
int lineStartOffset = myDocument.getLineStartOffset(myDocument.getLineNumber(blockStartOffset));
|
||||
return createLineIndentInfo(lineStartOffset, blockStartOffset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Block> getBlocksStartingNewLine() {
|
||||
FormattingModel model = myFormattingModelBuilder.createModel(myFile, mySettings);
|
||||
Block root = model.getRootBlock();
|
||||
NewLineBlocksIterator newLineBlocksIterator = new NewLineBlocksIterator(root, myDocument);
|
||||
|
||||
List<Block> newLineBlocks = new ArrayList<Block>();
|
||||
int currentLine = 0;
|
||||
while (newLineBlocksIterator.hasNext() && currentLine < MAX_NEW_LINE_BLOCKS_TO_PROCESS) {
|
||||
Block next = newLineBlocksIterator.next();
|
||||
if (next instanceof ASTBlock && ((ASTBlock)next).getNode() instanceof PsiComment) {
|
||||
continue;
|
||||
}
|
||||
newLineBlocks.add(next);
|
||||
currentLine++;
|
||||
}
|
||||
|
||||
return newLineBlocks;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private LineIndentInfo createLineIndentInfo(int lineStartOffset, int textStartOffset) {
|
||||
if (CharArrayUtil.indexOf(myText, "\t", lineStartOffset, textStartOffset) > 0) {
|
||||
return LineIndentInfo.LINE_WITH_TABS;
|
||||
}
|
||||
return LineIndentInfo.newWhiteSpaceIndent(textStartOffset - lineStartOffset);
|
||||
}
|
||||
|
||||
}
|
||||
+18
-3
@@ -19,6 +19,7 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
@@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.psi.codeStyle.CommonCodeStyleSettings.*;
|
||||
import static com.intellij.psi.codeStyle.CommonCodeStyleSettings.IndentOptions;
|
||||
|
||||
public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
|
||||
private static Logger LOG = Logger.getInstance("#com.intellij.psi.codeStyle.CommonCodeStyleSettings.IndentOptionsDetector");
|
||||
@@ -38,12 +39,14 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
|
||||
private final Project myProject;
|
||||
private final Document myDocument;
|
||||
private final Language myLanguage;
|
||||
private final boolean myUseFormatterBasedLineIndentBuilder;
|
||||
|
||||
public IndentOptionsDetectorImpl(@NotNull PsiFile file) {
|
||||
myFile = file;
|
||||
myLanguage = file.getLanguage();
|
||||
myProject = file.getProject();
|
||||
myDocument = PsiDocumentManager.getInstance(myProject).getDocument(myFile);
|
||||
myUseFormatterBasedLineIndentBuilder = Registry.is("editor.detect.indent.by.formatter");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,8 +54,12 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
|
||||
public IndentOptions getIndentOptions() {
|
||||
IndentOptions indentOptions = (IndentOptions)CodeStyleSettingsManager.getSettings(myProject).getIndentOptions(myFile.getFileType()).clone();
|
||||
|
||||
if (myDocument != null) {
|
||||
List<LineIndentInfo> linesInfo = new LineIndentInfoBuilder(myDocument.getCharsSequence(), myLanguage).build();
|
||||
long start = System.currentTimeMillis();
|
||||
List<LineIndentInfo> linesInfo = calcLineIndentInfo();
|
||||
long end = System.currentTimeMillis();
|
||||
LOG.info("Formatter-based: " + myUseFormatterBasedLineIndentBuilder + ". Line info building time: " + (end - start));
|
||||
|
||||
if (linesInfo != null) {
|
||||
IndentUsageStatistics stats = new IndentUsageStatisticsImpl(linesInfo);
|
||||
adjustIndentOptions(indentOptions, stats);
|
||||
}
|
||||
@@ -60,6 +67,14 @@ public class IndentOptionsDetectorImpl implements IndentOptionsDetector {
|
||||
return indentOptions;
|
||||
}
|
||||
|
||||
private List<LineIndentInfo> calcLineIndentInfo() {
|
||||
if (myDocument == null) return null;
|
||||
if (myUseFormatterBasedLineIndentBuilder) {
|
||||
return new FormatterBasedLineIndentInfoBuilder(myFile).build();
|
||||
}
|
||||
return new LineIndentInfoBuilder(myDocument.getCharsSequence(), myLanguage).build();
|
||||
}
|
||||
|
||||
private void adjustIndentOptions(@NotNull IndentOptions indentOptions, @NotNull IndentUsageStatistics stats) {
|
||||
int linesWithTabs = stats.getTotalLinesWithLeadingTabs();
|
||||
int linesWithWhiteSpaceIndent = stats.getTotalLinesWithLeadingSpaces();
|
||||
|
||||
@@ -37,8 +37,10 @@ public abstract class AbstractBlock implements ASTBlock {
|
||||
@NotNull protected final ASTNode myNode;
|
||||
@Nullable protected final Wrap myWrap;
|
||||
@Nullable protected final Alignment myAlignment;
|
||||
private List<Block> mySubBlocks;
|
||||
private Boolean myIncomplete;
|
||||
|
||||
private List<Block> mySubBlocks;
|
||||
private Boolean myIncomplete;
|
||||
private boolean myBuildInjectedBlocks = true;
|
||||
|
||||
protected AbstractBlock(@NotNull ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment) {
|
||||
myNode = node;
|
||||
@@ -66,8 +68,23 @@ public abstract class AbstractBlock implements ASTBlock {
|
||||
return mySubBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents from building injected blocks, which allows to build blocks faster
|
||||
* Initially was made for formatting-based indent detector
|
||||
*/
|
||||
protected void setBuildInjectedBlocks(boolean value) {
|
||||
myBuildInjectedBlocks = value;
|
||||
}
|
||||
|
||||
protected boolean isBuildInjectedBlocks() {
|
||||
return myBuildInjectedBlocks;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Block> buildInjectedBlocks() {
|
||||
if (!myBuildInjectedBlocks) {
|
||||
return EMPTY;
|
||||
}
|
||||
if (!(this instanceof SettingsAwareBlock)) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.intellij.psi.formatter.common;
|
||||
|
||||
import com.intellij.formatting.Block;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewLineBlocksIterator implements Iterator<Block> {
|
||||
private final Document myDocument;
|
||||
private final int myTotalLines;
|
||||
|
||||
private int myCurrentLineStartOffset;
|
||||
private int myCurrentDocumentLine;
|
||||
private Stack<Block> myStack = new Stack<Block>();
|
||||
|
||||
public NewLineBlocksIterator(Block root, Document document) {
|
||||
myStack.add(root);
|
||||
myDocument = document;
|
||||
myTotalLines = myDocument.getLineCount();
|
||||
|
||||
myCurrentDocumentLine = 0;
|
||||
myCurrentLineStartOffset = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (myCurrentDocumentLine < myTotalLines) {
|
||||
popUntilTopBlockStartOffsetGreaterOrEqual(myCurrentLineStartOffset);
|
||||
return !myStack.isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block next() {
|
||||
popUntilTopBlockStartOffsetGreaterOrEqual(myCurrentLineStartOffset);
|
||||
|
||||
Block current = myStack.peek();
|
||||
TextRange currentBlockRange = current.getTextRange();
|
||||
|
||||
myCurrentDocumentLine = myDocument.getLineNumber(currentBlockRange.getStartOffset());
|
||||
myCurrentDocumentLine++;
|
||||
if (myCurrentDocumentLine < myTotalLines) {
|
||||
myCurrentLineStartOffset = myDocument.getLineStartOffset(myCurrentDocumentLine);
|
||||
if (currentBlockRange.getEndOffset() < myCurrentLineStartOffset) {
|
||||
myStack.pop();
|
||||
}
|
||||
else {
|
||||
pushAll(current);
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
private void popUntilTopBlockStartOffsetGreaterOrEqual(final int lineStartOffset) {
|
||||
if (myStack.isEmpty()) return;
|
||||
|
||||
Block current = myStack.peek();
|
||||
TextRange range = current.getTextRange();
|
||||
int currentStartOffset = range.getStartOffset();
|
||||
int currentEndOffset = range.getEndOffset();
|
||||
|
||||
if (currentStartOffset < lineStartOffset) {
|
||||
myStack.pop();
|
||||
if (currentEndOffset > lineStartOffset) {
|
||||
pushAll(current);
|
||||
}
|
||||
popUntilTopBlockStartOffsetGreaterOrEqual(lineStartOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private void pushAll(Block current) {
|
||||
if (current instanceof AbstractBlock) {
|
||||
//building blocks as fast as possible
|
||||
((AbstractBlock)current).setBuildInjectedBlocks(false);
|
||||
}
|
||||
|
||||
List<Block> blocks = current.getSubBlocks();
|
||||
Collections.reverse(blocks);
|
||||
for (Block block : blocks) {
|
||||
myStack.push(block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.ex.DocumentBulkUpdateListener;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectLocator;
|
||||
@@ -123,6 +124,12 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean shouldNotifySmartPointers(@NotNull VirtualFile virtualFile) {
|
||||
// for an open file do not do fasten/unfasten, they should always stay fastened to improve responsiveness
|
||||
return !myProject.isDefault() && !FileEditorManager.getInstance(myProject).isFileOpen(virtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeDocumentChangeOnUnlockedDocument(@NotNull final FileViewProvider viewProvider) {
|
||||
PostprocessReformattingAspect.getInstance(myProject).beforeDocumentChanged(viewProvider);
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
public class AbstractFileTreeTable<T> extends TreeTable {
|
||||
private final MyModel<T> myModel;
|
||||
private final Project myProject;
|
||||
|
||||
@@ -57,9 +57,19 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
@NotNull String valueTitle,
|
||||
@NotNull VirtualFileFilter filter,
|
||||
boolean showProjectNode) {
|
||||
super(new MyModel<T>(project, valueClass, valueTitle, filter));
|
||||
this(project, valueClass, valueTitle, filter, showProjectNode, true);
|
||||
}
|
||||
|
||||
public AbstractFileTreeTable(@NotNull Project project,
|
||||
@NotNull Class<T> valueClass,
|
||||
@NotNull String valueTitle,
|
||||
@NotNull VirtualFileFilter filter,
|
||||
boolean showProjectNode,
|
||||
boolean filterNonContentFiles) {
|
||||
super(new MyModel<T>(project, valueClass, valueTitle, filterNonContentFiles ? new NonContentFileFilter(project, filter) : filter));
|
||||
myProject = project;
|
||||
|
||||
//noinspection unchecked
|
||||
myModel = (MyModel)getTableModel();
|
||||
myModel.setTreeTable(this);
|
||||
|
||||
@@ -84,6 +94,7 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
getTree().setShowsRootHandles(true);
|
||||
getTree().setLineStyleAngled();
|
||||
getTree().setRootVisible(showProjectNode);
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
getTree().setCellRenderer(new DefaultTreeCellRenderer() {
|
||||
@Override
|
||||
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded,
|
||||
@@ -96,21 +107,18 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
}
|
||||
FileNode fileNode = (FileNode)value;
|
||||
VirtualFile file = fileNode.getObject();
|
||||
if (fileNode.getParent() instanceof FileNode) {
|
||||
setText(file.getName());
|
||||
setText(fileNode.getParent() instanceof FileNode ? file.getName() : file.getPresentableUrl());
|
||||
if (file.isDirectory()) {
|
||||
setIcon(fileIndex.isExcluded(file) ? AllIcons.Modules.ExcludeRoot : PlatformIcons.DIRECTORY_CLOSED_ICON);
|
||||
}
|
||||
else {
|
||||
setText(file.getPresentableUrl());
|
||||
setIcon(IconUtil.getIcon(file, 0, null));
|
||||
}
|
||||
|
||||
Icon icon = file.isDirectory() ? PlatformIcons.DIRECTORY_CLOSED_ICON : IconUtil.getIcon(file, 0, null);
|
||||
setIcon(icon);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
getTableHeader().setReorderingAllowed(false);
|
||||
|
||||
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
setPreferredScrollableViewportSize(new Dimension(300, getRowHeight() * 10));
|
||||
|
||||
@@ -140,8 +148,7 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
|
||||
public static void press(final Container comboComponent) {
|
||||
if (comboComponent instanceof JButton) {
|
||||
final JButton button = (JButton)comboComponent;
|
||||
button.doClick();
|
||||
((JButton)comboComponent).doClick();
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < comboComponent.getComponentCount(); i++) {
|
||||
@@ -191,8 +198,7 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
|
||||
public void reset(@NotNull Map<VirtualFile, T> mappings) {
|
||||
myModel.reset(mappings);
|
||||
final TreeNode root = (TreeNode)myModel.getRoot();
|
||||
myModel.nodeChanged(root);
|
||||
myModel.nodeChanged((TreeNode)myModel.getRoot());
|
||||
getTree().setModel(null);
|
||||
getTree().setModel(myModel);
|
||||
TreeUtil.expandRootChildIfOnlyOne(getTree());
|
||||
@@ -223,7 +229,6 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class MyModel<T> extends DefaultTreeModel implements TreeTableModel {
|
||||
private final Map<VirtualFile, T> myCurrentMapping = new HashMap<VirtualFile, T>();
|
||||
private final Class<T> myValueClass;
|
||||
@@ -310,11 +315,14 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
|
||||
@Override
|
||||
public void setValueAt(final Object aValue, final Object node, final int column) {
|
||||
final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
|
||||
final Object userObject = treeNode.getUserObject();
|
||||
if (userObject instanceof Project) return;
|
||||
final Object userObject = ((DefaultMutableTreeNode)node).getUserObject();
|
||||
if (userObject instanceof Project) {
|
||||
return;
|
||||
}
|
||||
|
||||
final VirtualFile file = (VirtualFile)userObject;
|
||||
final T t = (T)aValue;
|
||||
@SuppressWarnings("unchecked")
|
||||
T t = (T)aValue;
|
||||
if (t == null || myTreeTable.isNullObject(t)) {
|
||||
myCurrentMapping.remove(file);
|
||||
}
|
||||
@@ -426,8 +434,8 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
public void clearCachedChildren() {
|
||||
if (children != null) {
|
||||
for (Object child : children) {
|
||||
ConvenientNode<T> node = (ConvenientNode<T>)child;
|
||||
node.clearCachedChildren();
|
||||
//noinspection unchecked
|
||||
((ConvenientNode<T>)child).clearCachedChildren();
|
||||
}
|
||||
}
|
||||
removeAllChildren();
|
||||
@@ -451,14 +459,11 @@ public abstract class AbstractFileTreeTable<T> extends TreeTable {
|
||||
|
||||
@Override
|
||||
protected void appendChildrenTo(@NotNull final Collection<ConvenientNode> children) {
|
||||
VirtualFile[] childrenf = getObject().getChildren();
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
for (VirtualFile child : childrenf) {
|
||||
if (myFilter.accept(child) && fileIndex.isInContent(child)) {
|
||||
for (VirtualFile child : getObject().getChildren()) {
|
||||
if (myFilter.accept(child)) {
|
||||
children.add(new FileNode(child, myProject, myFilter));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.intellij.util.ui.tree;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NonContentFileFilter implements VirtualFileFilter {
|
||||
private final Project project;
|
||||
private final VirtualFileFilter filter;
|
||||
|
||||
private ProjectFileIndex fileIndex;
|
||||
|
||||
public NonContentFileFilter(@NotNull Project project, @NotNull VirtualFileFilter filter) {
|
||||
this.project = project;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(@NotNull VirtualFile file) {
|
||||
if (!filter.accept(file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileIndex == null) {
|
||||
fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
}
|
||||
return fileIndex.isInContent(file);
|
||||
}
|
||||
}
|
||||
@@ -96,11 +96,14 @@ public class CommonShortcuts {
|
||||
return shortcutsById(IdeActions.ACTION_NEW_ELEMENT);
|
||||
}
|
||||
|
||||
public static ShortcutSet getDuplicate() {
|
||||
return shortcutsById(IdeActions.ACTION_EDITOR_DUPLICATE);
|
||||
}
|
||||
|
||||
public static ShortcutSet getMove() {
|
||||
return shortcutsById(IdeActions.ACTION_MOVE);
|
||||
}
|
||||
|
||||
|
||||
public static ShortcutSet getRename() {
|
||||
return shortcutsById(IdeActions.ACTION_RENAME);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import javax.swing.*;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.metal.DefaultMetalTheme;
|
||||
import java.awt.*;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -52,9 +53,27 @@ public class IntelliJLaf extends DarculaLaf {
|
||||
}
|
||||
|
||||
private static void installMacOSXFonts(UIDefaults defaults) {
|
||||
FontUIResource font = new FontUIResource("HelveticaNeue-CondensedBlack", Font.PLAIN, 13);
|
||||
defaults.put("Label.font", font);
|
||||
defaults.put("CheckBox.font", font);
|
||||
defaults.put("RadioButton.font", font);
|
||||
String face = "HelveticaNeue-CondensedBlack";
|
||||
LafManagerImpl.initFontDefaults(defaults, face, 13);
|
||||
for (Object key : new HashSet<Object>(defaults.keySet())) {
|
||||
Object value = defaults.get(key);
|
||||
if (value instanceof FontUIResource) {
|
||||
FontUIResource font = (FontUIResource)value;
|
||||
if (font.getFamily().equals("Lucida Grande") || font.getFamily().equals("Serif")) {
|
||||
if (!key.toString().contains("Menu")) {
|
||||
defaults.put(key, new FontUIResource(face, font.getStyle(), font.getSize()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Font menuFont = new Font("Lucida Grande", Font.PLAIN, 14);
|
||||
defaults.put("Menu.font", menuFont);
|
||||
defaults.put("MenuItem.font", menuFont);
|
||||
defaults.put("MenuItem.acceleratorFont", menuFont);
|
||||
}
|
||||
|
||||
public static boolean isGraphite() {
|
||||
Color c = UIManager.getColor("controlHighlight");
|
||||
return c != null && c.getBlue() < 150;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,4 +437,8 @@ public class DarculaLaf extends BasicLookAndFeel {
|
||||
public boolean getSupportsWindowDecorations() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Icon loadIcon(String path) {
|
||||
return IconLoader.findIcon(path, DarculaLaf.class, true);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -342,6 +342,9 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
final int R = JBUI.scale(5);
|
||||
if (hasFocus) {
|
||||
g.setClip(2, 2, comboBox.getWidth()- 4, comboBox.getHeight() - 4); //todo[kb] check HiDPI
|
||||
}
|
||||
if (editor != null && comboBox.isEditable()) {
|
||||
((JComponent)editor).setBorder(null);
|
||||
g.setColor(editor.getBackground());
|
||||
@@ -351,11 +354,11 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
g.setColor(editor.getBackground());
|
||||
g.fillRect(xxx, y + 1, 5, H);
|
||||
} else {
|
||||
g.setColor(comboBox.getBackground());
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
g.fillRoundRect(x + 1, y + 1, W, H, R, R);
|
||||
g.setColor(getArrowButtonFillColor(arrowButton.getBackground()));
|
||||
g.fillRoundRect(xxx, y + 1, width - xxx, H, R, R);
|
||||
g.setColor(comboBox.getBackground());
|
||||
g.setColor(UIUtil.getPanelBackground());
|
||||
g.fillRect(xxx, y + 1, 5, H);
|
||||
}
|
||||
final Color borderColor = getBorderColor();//ColorUtil.shift(UIUtil.getBorderColor(), 4);
|
||||
@@ -368,6 +371,7 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
paintCurrentValue(g, r, false);
|
||||
|
||||
if (hasFocus) {
|
||||
g.setClip(0, 0, comboBox.getWidth(), comboBox.getHeight());
|
||||
DarculaUIUtil.paintFocusRing(g, JBUI.scale(2), JBUI.scale(2), width - JBUI.scale(4), height - JBUI.scale(4));
|
||||
}
|
||||
else {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user