Merge remote-tracking branch 'origin/master'

This commit is contained in:
irengrig
2015-06-15 20:50:02 +02:00
171 changed files with 4328 additions and 1431 deletions
+3 -2
View File
@@ -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>
@@ -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();
@@ -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 {
@@ -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;
}
@@ -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);
}
@@ -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;
}
}
@@ -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));
}
@@ -519,6 +519,6 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
@Nullable
@Override
public Icon getIcon(int flags) {
return AllIcons.Nodes.AnonymousClass;
return AllIcons.Nodes.MethodReference;
}
}
@@ -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,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();
}
}
@@ -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){}
@@ -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,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){}
}
@@ -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) {}
@@ -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>;
@@ -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,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();
}
}
@@ -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){}
@@ -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,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){}
}
@@ -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) {}
@@ -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>;
}
@@ -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);
@@ -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>;
}
@@ -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);
@@ -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);
}
}
}
+2 -2
View File
@@ -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();
@@ -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");
}
}
@@ -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();
@@ -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());
}
}
@@ -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);
}
}
}
@@ -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;
@@ -24,11 +24,14 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiRecursiveElementVisitor;
import com.intellij.util.Processor;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
@@ -85,35 +88,45 @@ public class BackwardDependenciesBuilder extends DependenciesBuilder {
psiManager.startBatchFilesProcessingMode();
try {
final int fileCount = getScope().getFileCount();
getScope().accept(new PsiRecursiveElementVisitor() {
@Override public void visitFile(final PsiFile file) {
final boolean includeTestSource = getScope().isIncludeTestSource();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(getProject()).getFileIndex();
getScope().accept(new Processor<VirtualFile>() {
@Override
public boolean process(final VirtualFile virtualFile) {
if (!includeTestSource && fileIndex.isInTestSourceContent(virtualFile)) {
return true;
}
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
if (indicator.isCanceled()) {
throw new ProcessCanceledException();
}
indicator.setText(AnalysisScopeBundle.message("package.dependencies.progress.text"));
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null) {
indicator.setText2(getRelativeToProjectPath(virtualFile));
}
indicator.setText2(getRelativeToProjectPath(virtualFile));
if (fileCount > 0) {
indicator.setFraction(((double)++myFileCount) / myTotalFileCount);
}
}
final Map<PsiFile, Set<PsiFile>> dependencies = builder.getDependencies();
for (final PsiFile psiFile : dependencies.keySet()) {
if (dependencies.get(psiFile).contains(file)) {
Set<PsiFile> fileDeps = getDependencies().get(file);
if (fileDeps == null) {
fileDeps = new HashSet<PsiFile>();
getDependencies().put(file, fileDeps);
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
final PsiFile file = psiManager.findFile(virtualFile);
if (file != null) {
final Map<PsiFile, Set<PsiFile>> dependencies = builder.getDependencies();
for (final PsiFile psiFile : dependencies.keySet()) {
if (dependencies.get(psiFile).contains(file)) {
Set<PsiFile> fileDeps = getDependencies().get(file);
if (fileDeps == null) {
fileDeps = new HashSet<PsiFile>();
getDependencies().put(file, fileDeps);
}
fileDeps.add(psiFile);
}
}
psiManager.dropResolveCaches();
}
fileDeps.add(psiFile);
}
}
psiManager.dropResolveCaches();
InjectedLanguageManager.getInstance(file.getProject()).dropFileCaches(file);
});
return true;
}
});
}
@@ -138,7 +138,8 @@ public class ForwardDependenciesBuilder extends DependenciesBuilder {
(fileIndex.isInContent(virtualFile) ||
fileIndex.isInLibraryClasses(virtualFile) ||
fileIndex.isInLibrarySource(virtualFile))) {
found.add(dependencyFile);
final PsiElement navigationElement = dependencyFile.getNavigationElement();
found.add(navigationElement instanceof PsiFile ? (PsiFile)navigationElement : dependencyFile);
}
}
}
@@ -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 {
@@ -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>() {
@@ -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();
@@ -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;
}
@@ -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;
}
@@ -99,6 +99,12 @@ public class FindDependencyUtil {
@Override
public void process(PsiElement place, PsiElement dependency) {
PsiFile dependencyFile = dependency.getContainingFile();
if (dependencyFile != null) {
final PsiElement navigationElement = dependencyFile.getNavigationElement();
if (navigationElement instanceof PsiFile) {
dependencyFile = (PsiFile)navigationElement;
}
}
if (searchFor.contains(dependencyFile)) {
usages.add(new UsageInfo(place));
}
@@ -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);
}
}
@@ -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);
}
}
@@ -135,8 +135,9 @@ public class EditorHyperlinkSupport {
@Override
public void run() {
if (hyperlinkInfo instanceof HyperlinkInfoBase) {
RelativePoint point = new RelativePoint(myEditor.getContentComponent(), myEditor.logicalPositionToXY(logical));
((HyperlinkInfoBase)hyperlinkInfo).navigate(myProject, point);
final Point point = myEditor.logicalPositionToXY(logical);
final MouseEvent event = new MouseEvent(myEditor.getContentComponent(), 0, 0, 0, point.x, point.y, 1, false);
((HyperlinkInfoBase)hyperlinkInfo).navigate(myProject, new RelativePoint(event));
}
else {
hyperlinkInfo.navigate(myProject);
@@ -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,11 +53,23 @@ 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);
defaults.put("ComboBox.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() {
@@ -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 {
@@ -189,6 +189,7 @@ public class MacIntelliJComboBoxUI extends BasicComboBoxUI implements Border, UI
@Override
protected Rectangle rectangleForCurrentValue() {
Rectangle rect = super.rectangleForCurrentValue();
rect.height=Math.min(rect.height, COMBOBOX.getIconHeight());
rect.y+=2;
rect.x+=5;
rect.height-=4;
@@ -257,17 +258,21 @@ public class MacIntelliJComboBoxUI extends BasicComboBoxUI implements Border, UI
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
}
public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) {
super.paintCurrentValue(g, bounds, comboBox.isPopupVisible());
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
int stop = arrowButton.getBounds().x;
Rectangle r = arrowButton.getBounds();
int stop = r.x;
g.setClip(0,0, stop, COMBOBOX.getIconHeight());
COMBOBOX_LEFT.paintIcon(c,g,0,0);
COMBOBOX_LEFT.paintIcon(c,g,0,r.y);
int x = COMBOBOX_LEFT.getIconWidth();
while (x < stop) {
COMBOBOX_TOP_BOTTOM.paintIcon(c, g, x, 0);
COMBOBOX_TOP_BOTTOM.paintIcon(c, g, x, r.y);
x+=COMBOBOX_TOP_BOTTOM.getIconWidth();
}
((Graphics2D)g).scale(0.5d, 0.5d);
@@ -1,4 +1,7 @@
# suppress inspection "UnusedProperty" for whole file
intellijlaf.background=ececec
intellijlaf.selectionBackgroundInactive=dcdcdc
intellijlaf.selectionInactiveBackground=dcdcdc
window=ececec
CheckBoxUI=com.intellij.ide.ui.laf.intellij.MacIntelliJCheckBoxUI
@@ -9,6 +12,10 @@ Spinner.background=ececec
Spinner.darcula.disabledButtonColor=ececec
ComboBoxUI=com.intellij.ide.ui.laf.intellij.MacIntelliJComboBoxUI
MenuItem.acceleratorSelectionForeground=ffffff
PopupMenu.background=f6f6f6
MenuItem.background=f6f6f6
Menu.background=f6f6f6
SplitPane.highlight=ececec
@@ -1,83 +0,0 @@
/*
* Copyright 2000-2010 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.openapi.editor.impl.softwrap;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.DocumentListener;
import com.intellij.openapi.editor.ex.PrioritizedDocumentListener;
/**
* Adapter class for {@link DocumentListener} interface that allows to represent document change events
* in terms of logical lines affected by it.
*
* @author Denis Zhdanov
* @since Jul 7, 2010 4:24:52 PM
*/
public abstract class LineOrientedDocumentChangeAdapter implements PrioritizedDocumentListener {
@Override
public void beforeDocumentChange(DocumentEvent event) {
Document document = event.getDocument();
int startLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset()));
int endLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset() + event.getOldLength()));
int symbolsDifference = event.getNewLength() - event.getOldLength();
beforeDocumentChange(startLine, endLine, symbolsDifference);
}
@Override
public void documentChanged(DocumentEvent event) {
Document document = event.getDocument();
int startLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset()));
int endLine = document.getLineNumber(normalize(event.getDocument(), event.getOffset() + event.getNewLength()));
int symbolsDifference = event.getNewLength() - event.getOldLength();
afterDocumentChange(startLine, endLine, symbolsDifference);
}
@Override
public int getPriority() {
return Integer.MAX_VALUE;
}
/**
* Callback adapter method for {@link DocumentListener#beforeDocumentChange(DocumentEvent)} event.
*
* @param startLine first logical document line affected by the target event (inclusive)
* @param endLine old last logical document line affected by the target event (inclusive)
* @param symbolsDifference difference in number in symbols applied to the target document
*/
public abstract void beforeDocumentChange(int startLine, int endLine, int symbolsDifference);
/**
* Callback adapter method for {@link DocumentListener#documentChanged(DocumentEvent)} event.
*
* @param startLine first logical document line affected by the target event (inclusive)
* @param endLine new last logical document line affected by the target event (inclusive)
* @param symbolsDifference difference in number in symbols applied to the target document
*/
public abstract void afterDocumentChange(int startLine, int endLine, int symbolsDifference);
private static int normalize(Document document, int offset) {
if (offset < 0) {
return 0;
}
if (offset >= document.getTextLength()) {
return Math.max(document.getTextLength() - 1, 0);
}
return offset;
}
}
@@ -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.
@@ -566,7 +566,8 @@ public class CachingSoftWrapDataMapper implements SoftWrapAwareDocumentParsingLi
int borderSoftWrapColumnDiff = 0;
int borderSoftWrapLinesBeforeDiff = 0;
int borderSoftWrapLinesCurrentDiff = 0;
for (int i = 0; i < myAffectedByUpdateCacheEntries.size(); i++) {
int affectedEntriesCount = myAffectedByUpdateCacheEntries.size();
for (int i = 0; i < affectedEntriesCount; i++) {
CacheEntry entry = myAffectedByUpdateCacheEntries.get(i);
if (firstIndex < 0) {
if (entry.startOffset < recalcEndOffsetTranslated) {
@@ -574,15 +575,12 @@ public class CachingSoftWrapDataMapper implements SoftWrapAwareDocumentParsingLi
continue;
}
firstIndex = i;
if (lastEntry != null) {
borderLogicalLine = lastEntry.endLogicalLine;
if (entry.startLogicalLine + logicalLinesDiff == borderLogicalLine) {
borderColumnDiff = lastEntry.endLogicalColumn - entry.startLogicalColumn;
borderSoftWrapLinesBeforeDiff = lastEntry.endSoftWrapLinesBefore - entry.startSoftWrapLinesBefore;
borderSoftWrapLinesCurrentDiff = lastEntry.endSoftWrapLinesCurrent - entry.startSoftWrapLinesCurrent + 1;
borderFoldedColumnDiff = lastEntry.endFoldingColumnDiff - entry.startFoldingColumnDiff;
borderSoftWrapColumnDiff = - borderColumnDiff - borderFoldedColumnDiff;
}
if (lastEntry != null && entry.startLogicalLine + logicalLinesDiff == borderLogicalLine) {
borderColumnDiff = lastEntry.endLogicalColumn - entry.startLogicalColumn;
borderSoftWrapLinesBeforeDiff = lastEntry.endSoftWrapLinesBefore - entry.startSoftWrapLinesBefore;
borderSoftWrapLinesCurrentDiff = lastEntry.endSoftWrapLinesCurrent - entry.startSoftWrapLinesCurrent + 1;
borderFoldedColumnDiff = lastEntry.endFoldingColumnDiff - entry.startFoldingColumnDiff;
borderSoftWrapColumnDiff = -borderColumnDiff - borderFoldedColumnDiff;
}
if (lengthDiff == 0 && logicalLinesDiff == 0 && foldedLinesDiff == 0 && softWrappedLinesDiff == 0
&& borderColumnDiff == 0 && borderSoftWrapColumnDiff == 0 && borderFoldedColumnDiff == 0
@@ -626,6 +624,9 @@ public class CachingSoftWrapDataMapper implements SoftWrapAwareDocumentParsingLi
LOG.error("Invalid soft wrap cache update", new Attachment("state.txt", myEditor.getSoftWrapModel().toString()));
}
}
if (myAffectedByUpdateCacheEntries.get(affectedEntriesCount - 1).endOffset > myEditor.getDocument().getTextLength()) {
LOG.error("Invalid soft wrap cache entries emerged", new Attachment("state.txt", myEditor.getSoftWrapModel().toString()));
}
myCache.addAll(myAffectedByUpdateCacheEntries.subList(firstIndex, myAffectedByUpdateCacheEntries.size()));
}
myAffectedByUpdateCacheEntries.clear();
@@ -37,7 +37,7 @@ public class ColorProgressBar extends JComponent {
private static final Dimension PREFERRED_SIZE = new Dimension(146, 17);
public static final Color GREEN = new JBColor(new Color(0x6cad74), new Color(0x4a8c53));
public static final Color RED = new JBColor(new Color(0xd67b76), new Color(0xb25050));
public static final Color RED = new JBColor(new Color(0xd67b76), new Color(0xe55757));
public static final Color BLUE = new JBColor(new Color(1, 68, 208), JBColor.blue);
public static final Color YELLOW = new JBColor(new Color(0xa67a21), new Color(0x91703a));
private static final Color SHADOW1 = new JBColor(Gray._190, UIUtil.getBorderColor()) ;
@@ -44,7 +44,7 @@ public final class UrlImpl implements Url {
public UrlImpl(@Nullable String scheme, @Nullable String authority, @Nullable String path, @Nullable String parameters) {
this.scheme = scheme;
this.authority = authority;
this.path = StringUtil.isEmpty(path) && !StringUtil.isEmpty(authority) ? "/" : StringUtil.notNullize(path);
this.path = StringUtil.notNullize(path);
this.parameters = StringUtil.nullize(parameters);
}
@@ -112,7 +112,7 @@ public final class UrlImpl implements Url {
// relative path - special url, encoding is not required
// authority is null in case of URI
if ((path.charAt(0) != '/' || authority == null) && !isInLocalFileSystem()) {
if ((authority == null || (!path.isEmpty() && path.charAt(0) != '/')) && !isInLocalFileSystem()) {
return toDecodedForm();
}
@@ -1,6 +1,5 @@
package org.jetbrains.io;
import com.intellij.util.text.CharArrayCharSequence;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.ByteBufUtilEx;
@@ -13,13 +12,13 @@ import java.nio.CharBuffer;
public final class ChannelBufferToString {
@NotNull
public static CharSequence readChars(@NotNull ByteBuf buffer) throws IOException {
return new MyCharArrayCharSequence(readIntoCharBuffer(buffer, buffer.readableBytes(), null));
return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, buffer.readableBytes(), null));
}
@SuppressWarnings("unused")
@NotNull
public static CharSequence readChars(@NotNull ByteBuf buffer, int byteCount) throws IOException {
return new MyCharArrayCharSequence(readIntoCharBuffer(buffer, byteCount, null));
return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, byteCount, null));
}
@NotNull
@@ -34,16 +33,4 @@ public final class ChannelBufferToString {
public static void writeIntAsAscii(int value, @NotNull ByteBuf buffer) {
ByteBufUtil.writeAscii(buffer, new StringBuilder().append(value));
}
// we must return string on subSequence() - JsonReaderEx will call toString in any case
public static final class MyCharArrayCharSequence extends CharArrayCharSequence {
public MyCharArrayCharSequence(@NotNull CharBuffer charBuffer) {
super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position());
}
@Override
public CharSequence subSequence(int start, int end) {
return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start);
}
}
}
@@ -17,10 +17,12 @@ package org.jetbrains.io;
import com.google.gson.JsonParseException;
import com.google.gson.stream.JsonToken;
import com.intellij.util.text.CharArrayCharSequence;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.Closeable;
import java.nio.CharBuffer;
import java.util.Arrays;
public final class JsonReaderEx implements Closeable {
@@ -116,6 +118,26 @@ public final class JsonReaderEx implements Closeable {
this.stack = stack;
}
// we must return string on subSequence() - JsonReaderEx will call toString in any case
public static final class CharSequenceBackedByChars extends CharArrayCharSequence {
public CharSequenceBackedByChars(@NotNull CharBuffer charBuffer) {
super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position());
}
public CharSequenceBackedByChars(@NotNull char[] chars, int start, int end) {
super(chars, start, end);
}
public CharSequenceBackedByChars(@NotNull char[] chars) {
super(chars);
}
@Override
public CharSequence subSequence(int start, int end) {
return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start);
}
}
private final static class JsonScope {
/**
* An array with no elements requires no separators or newlines before
@@ -44,7 +44,7 @@ public abstract class MessageDecoder extends Decoder {
chunkedContent = null;
consumedContentByteCount = 0;
}
return new ChannelBufferToString.MyCharArrayCharSequence(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer));
return new JsonReaderEx.CharSequenceBackedByChars(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer));
}
}
@@ -164,6 +164,15 @@ html.add.table.column.after.action=Add a new column to the table after the curre
html.add.table.column.before.action=Add a new column to the table before the current one
xml.javadoc.enumeration.value.message=Enumeration value
xml.inspections.unused.schema=Unused XML schema declaration
xml.inspections.unused.schema.location=Namespace location is never used
xml.inspections.unused.schema.declaration=Namespace declaration is never used
xml.inspections.unused.schema.remove=Remove unused namespace declaration
xml.inspections.path.resolve=File path resolving in XML
xml.inspections.global=XML highlighting
#xsd2xml and xml2xsd
url.is.empty.validation.problem=Url is empty
invalid.number.validation.problem=Invalid number
@@ -390,64 +390,85 @@
<iconProvider implementation="com.intellij.xml.util.XmlIconProvider"/>
<localInspection language="XML" shortName="CheckTagEmptyBody" bundle="messages.XmlBundle" key="xml.inspections.check.tag.empty.body"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="CheckTagEmptyBody" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="xml.inspections.check.tag.empty.body"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckTagEmptyBodyInspection"/>
<!-- TODO: assign it to XML & DTD -->
<localInspection shortName="CheckDtdRefs" bundle="messages.XmlBundle" key="xml.inspections.check.dtd.references" groupName="XML"
enabledByDefault="true" level="ERROR" implementationClass="com.intellij.xml.util.CheckDtdReferencesInspection"/>
<localInspection language="XML" shortName="CheckEmptyScriptTag" bundle="messages.XmlBundle" key="html.inspections.check.empty.tag" groupName="HTML"
enabledByDefault="true" level="WARNING" implementationClass="com.intellij.xml.util.CheckEmptyTagInspection"/>
<localInspection language="XML" shortName="CheckValidXmlInScriptTagBody" bundle="messages.XmlBundle" key="html.inspections.check.valid.script.tag"
groupName="HTML" enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.xml.util.CheckValidXmlInScriptBodyInspection"/>
<localInspection language="XML" shortName="CheckXmlFileWithXercesValidator" bundle="messages.XmlBundle" key="xml.inspections.check.file.with.xerces"
groupName="XML" enabledByDefault="true" level="ERROR"
<localInspection shortName="CheckDtdRefs" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.check.dtd.references"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckDtdReferencesInspection"/>
<localInspection language="XML" shortName="CheckXmlFileWithXercesValidator" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.check.file.with.xerces"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckXmlFileWithXercesValidatorInspection" unfair="true"/>
<localInspection language="XML" bundle="messages.XmlBundle" key="xml.inspections.duplicate.id"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
<localInspection language="XML" enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
bundle="messages.XmlBundle" key="xml.inspections.duplicate.id"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.xml.util.XmlDuplicatedIdInspection"/>
<localInspection language="XML" bundle="messages.XmlBundle" key="xml.inspections.invalid.id"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
enabledByDefault="true" level="ERROR" runForWholeFile="true" unfair="true"
implementationClass="com.intellij.xml.util.XmlInvalidIdInspection"/>
<localInspection language="XML" shortName="RequiredAttributes" bundle="messages.InspectionsBundle" key="inspection.required.attributes.display.name"
groupName="HTML" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection" unfair="true"/>
<localInspection language="XML" shortName="HtmlExtraClosingTag" bundle="messages.XmlBundle" key="html.inspection.extra.closing.tag" groupName="HTML"
enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlExtraClosingTagInspection"/>
<localInspection language="XML" shortName="XmlWrongRootElement" bundle="messages.XmlBundle" key="xml.inspection.wrong.root.element" groupName="XML"
<localInspection language="XML" shortName="XmlWrongRootElement"
bundle="messages.XmlBundle" key="xml.inspection.wrong.root.element"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
enabledByDefault="true" level="ERROR"
implementationClass="com.intellij.codeInspection.htmlInspections.XmlWrongRootElementInspection"/>
<localInspection language="XML" shortName="HtmlUnknownTag" bundle="messages.XmlBundle" key="html.inspections.unknown.tag" groupName="HTML"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownTagInspection"/>
<localInspection language="XML" shortName="HtmlUnknownAttribute" bundle="messages.XmlBundle" key="html.inspections.unknown.attribute" groupName="HTML"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownAttributeInspection"/>
<localInspection language="XML" bundle="messages.XmlBundle" key="html.inspections.unknown.boolean.attribute" groupName="HTML"
enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownBooleanAttributeInspection"/>
<localInspection language="XML" shortName="XmlUnboundNsPrefix" bundle="messages.XmlBundle" key="xml.inspections.unbound.prefix"
groupKey="xml.inspections.group.name" enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="XmlUnboundNsPrefix" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="xml.inspections.unbound.prefix"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlUnboundNsPrefixInspection"/>
<localInspection language="XML" shortName="XmlUnusedNamespaceDeclaration" displayName="Unused XML schema declaration"
groupKey="xml.inspections.group.name" bundle="messages.XmlBundle" enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="XmlUnusedNamespaceDeclaration" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="xml.inspections.unused.schema"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlUnusedNamespaceInspection"/>
<localInspection language="XML" implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection"
displayName="File path resolving in XML"
groupName="XML" enabledByDefault="true" level="ERROR"/>
<localInspection language="XML" shortName="HtmlUnknownTarget" bundle="messages.XmlBundle" key="html.inspections.unknown.target" groupName="HTML"
enabledByDefault="true" level="WARNING"
<localInspection language="XML" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.path.resolve"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection"/>
<localInspection language="XML" shortName="CheckEmptyScriptTag" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.check.empty.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckEmptyTagInspection"/>
<localInspection language="XML" shortName="CheckValidXmlInScriptTagBody" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="html.inspections.check.valid.script.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.xml.util.CheckValidXmlInScriptBodyInspection"/>
<localInspection language="XML" shortName="RequiredAttributes" enabledByDefault="true" level="WARNING" unfair="true"
bundle="messages.InspectionsBundle" key="inspection.required.attributes.display.name"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection"/>
<localInspection language="XML" shortName="HtmlExtraClosingTag" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="html.inspection.extra.closing.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlExtraClosingTagInspection"/>
<localInspection language="XML" shortName="HtmlUnknownTag" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.tag"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownTagInspection"/>
<localInspection language="XML" shortName="HtmlUnknownAttribute" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.attribute"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownAttributeInspection"/>
<localInspection language="XML" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.boolean.attribute"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInspection.htmlInspections.HtmlUnknownBooleanAttributeInspection"/>
<localInspection language="XML" shortName="HtmlUnknownTarget" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.target"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.HtmlUnknownTargetInspection"/>
<localInspection language="XML" shortName="HtmlUnknownAnchorTarget" bundle="messages.XmlBundle" key="html.inspections.unknown.anchor" groupName="HTML"
enabledByDefault="true" level="WARNING"
<localInspection language="XML" shortName="HtmlUnknownAnchorTarget" enabledByDefault="true" level="WARNING"
bundle="messages.XmlBundle" key="html.inspections.unknown.anchor"
groupBundle="messages.XmlBundle" groupKey="html.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.HtmlUnknownAnchorTargetInspection"/>
<globalInspection language="XML" shortName="XmlHighlighting" displayName="XML highlighting" groupName="xml.inspections.group.name" enabledByDefault="true" level="ERROR"
<globalInspection language="XML" shortName="XmlHighlighting" enabledByDefault="true" level="ERROR"
bundle="messages.XmlBundle" key="xml.inspections.global"
groupBundle="messages.XmlBundle" groupKey="xml.inspections.group.name"
implementationClass="com.intellij.codeInsight.daemon.impl.analysis.XmlHighlightVisitorBasedInspection"/>
<codeFoldingOptionsProvider instance="com.intellij.application.options.editor.XmlCodeFoldingOptionsProvider"/>
@@ -13,7 +13,7 @@ org.jetbrains.kannotator 0.2.420
org.jetbrains.kotlin 0.10.555 0.10.4 0.8.1615 0.7.1360 0.7.1376 0.8.7
SBT 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.5.0 1.5.1 1.6.0 1.6.1
"JSTestDriver Plugin" 140.2109 140.1669 140.727 138.317 138.21 136.1141 134.1163 134.686 134.31 134.307 134.1039
AngularJS 141.2 140.1968 139.1112 139.12 134.1243 134.1341 134.1444 135.1063 135.565 135.831 135.937 138.1242 138.1988 134.1094 0.1.8 0.1.9
AngularJS 142.1935 141.2 140.1968 139.1112 139.12 134.1243 134.1341 134.1444 135.1063 135.565 135.831 135.937 138.1242 138.1988 134.1094 0.1.8 0.1.9
com.jetbrains.plugins.ini4idea 0.4 0.5 0.6 0.7 0.8 0.8.1 0.9 0.9.1 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 130.1176
org.jetbrains.plugins.vagrant 0.1 0.2
org.intellij.clojure 0.2.1.178
@@ -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.
@@ -141,4 +141,14 @@ public class EditorImplTest extends AbstractEditorTest {
assertEquals(new LogicalPosition(0, 3), myEditor.getCaretModel().getLogicalPosition());
assertEquals(new VisualPosition(0, 3), myEditor.getCaretModel().getVisualPosition());
}
public void testSoftWrapModeUpdateDuringBulkModeChange() throws Exception {
initText("long long line<caret>");
configureSoftWraps(12);
DocumentEx document = (DocumentEx)myEditor.getDocument();
document.setInBulkUpdate(true);
document.replaceString(4, 5, "-");
document.setInBulkUpdate(false);
assertEquals(new VisualPosition(1, 5), myEditor.getCaretModel().getVisualPosition());
}
}
@@ -1,152 +0,0 @@
/*
* 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.autodetect;
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 com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import java.io.File;
import java.util.List;
public class IndentAutoDetectionTest extends AbstractIndentAutoDetectionTest {
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/')
+ "/platform/platform-tests/testData/"
+ "codeStyle/autodetect/";
}
@NotNull
protected String getFileNameWithExtension() {
return getTestName(true) + ".java";
}
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 testNoZeroIndentsInStats() {
doTestIndentSize(4);
}
public void testNoIndentsUseLanguageSpecificSettings() {
CommonCodeStyleSettings.IndentOptions options = new CommonCodeStyleSettings.IndentOptions();
options.USE_TAB_CHARACTER = true;
doTestTabsUsed(options);
}
public void testManyZeroIndents() { doTestIndentSize(2); }
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);
}
}
}
@@ -16,6 +16,7 @@
package com.intellij.remoteServer.agent.util;
import com.intellij.remoteServer.agent.util.log.LogListener;
import com.intellij.remoteServer.agent.util.log.TerminalListener;
import java.io.InputStream;
import java.io.OutputStream;
@@ -35,5 +36,5 @@ public interface CloudAgentLoggingHandler {
boolean isTtySupported();
void createTerminal(String pipeName, OutputStream terminalInput, InputStream terminalOutput);
TerminalListener createTerminal(String pipeName, OutputStream terminalInput, InputStream terminalOutput);
}
@@ -0,0 +1,28 @@
/*
* 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.remoteServer.agent.util.log;
public interface TerminalListener {
void close();
static TerminalListener NULL = new TerminalListener() {
public void close() {
}
};
}
@@ -24,20 +24,22 @@ public abstract class TerminalPipe extends LogPipeBase {
private final String myLogPipeName;
private final CloudAgentLoggingHandler myLoggingHandler;
private TerminalListener myTerminalListener;
public TerminalPipe(String logPipeName, CloudAgentLoggingHandler loggingHandler) {
myLogPipeName = logPipeName;
myLoggingHandler = loggingHandler;
myTerminalListener = TerminalListener.NULL;
}
@Override
public void open() {
myLoggingHandler.createTerminal(myLogPipeName, getOutputStream(), getInputStream());
myTerminalListener = myLoggingHandler.createTerminal(myLogPipeName, getOutputStream(), getInputStream());
}
@Override
public void close() {
myTerminalListener.close();
}
protected abstract OutputStream getOutputStream();

Some files were not shown because too many files have changed in this diff Show More