Merge remote-tracking branch 'origin/master'

This commit is contained in:
Konstantin Bulenkov
2017-01-18 05:56:15 +08:00
11 changed files with 92 additions and 11 deletions
@@ -69,7 +69,17 @@ public abstract class RequestResultProcessor {
/**
* A variant of {@link RequestResultProcessor} that processes all text occurrences at once, e.g. for performance purposes.
*/
@SuppressWarnings("unused")
public static abstract class BulkResultProcessor extends RequestResultProcessor {
public BulkResultProcessor() {
super();
}
public BulkResultProcessor(@NotNull Object... equality) {
super(equality);
}
@Override
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull Processor<PsiReference> consumer) {
return processTextOccurrences(element, new int[]{offsetInElement}, consumer);
@@ -104,11 +104,14 @@ public abstract class CompletionPhase implements Disposable {
}
public void ignoreCurrentDocumentChange() {
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
if (commandProcessor.getCurrentCommand() == null) return;
ignoreDocumentChanges = true;
CommandProcessor.getInstance().addCommandListener(new CommandAdapter() {
commandProcessor.addCommandListener(new CommandAdapter() {
@Override
public void commandFinished(CommandEvent event) {
CommandProcessor.getInstance().removeCommandListener(this);
commandProcessor.removeCommandListener(this);
ignoreDocumentChanges = false;
}
});
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -544,6 +544,7 @@ public class GroovyFileImpl extends GroovyFileBaseImpl implements GroovyFile, Ps
@Override
public boolean shouldChangeModificationCount(PsiElement place) {
if (!isContentsLoaded()) return true;
// 1. We actually should never get GrTypeDefinition as a parent, because it is a PsiClass,
// and PsiClasses prevent to go up in a tree any further
// 2. If place is under a variable then @BaseScript or @Field may be changed,
@@ -651,15 +651,10 @@ public class ClassWriter {
if (attr != null) {
descriptor = GenericMain.parseMethodSignature(attr.getSignature());
if (descriptor != null) {
int actualParams = md.params.length;
long actualParams = md.params.length;
List<VarVersionPair> sigFields = methodWrapper.signatureFields;
if (sigFields != null) {
actualParams = 0;
for (VarVersionPair field : methodWrapper.signatureFields) {
if (field == null) {
actualParams++;
}
}
actualParams = sigFields.stream().filter(Objects::isNull).count();
}
else if (isEnum && init) actualParams -= 2;
if (actualParams != descriptor.params.size()) {
@@ -405,8 +405,10 @@ public class NestedClassProcessor {
MethodWrapper method = nestedNode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, entry.getKey());
method.signatureFields = new ArrayList<>();
boolean firstSignField = nestedNode.type != ClassNode.CLASS_ANONYMOUS;
for (VarFieldPair pair : entry.getValue()) {
method.signatureFields.add(pair == null || pair.fieldKey.isEmpty() ? null : pair.varPair);
method.signatureFields.add(pair == null || (!firstSignField && pair.fieldKey.isEmpty()) ? null : pair.varPair);
firstSignField = false;
}
}
}
@@ -96,6 +96,7 @@ public class SingleClassesTest {
@Test public void testAsserts() { doTest("pkg/TestAsserts"); }
@Test public void testLocalsNames() { doTest("pkg/TestLocalsNames"); }
@Test public void testAnonymousParamNames() { doTest("pkg/TestAnonymousParamNames"); }
@Test public void testAnonymousParams() { doTest("pkg/TestAnonymousParams"); }
private void doTest(String testFile, String... companionFiles) {
ConsoleDecompiler decompiler = fixture.getDecompiler();
@@ -0,0 +1,36 @@
package pkg;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
public class TestAnonymousParams {
void foo(InputStream in, final int a) throws IOException {
FilterInputStream filterInputStream = new FilterInputStream(in) {
public int read() throws IOException {
return a;// 27
}
};// 24
filterInputStream.read();// 30
}// 31
}
class 'pkg/TestAnonymousParams$1' {
method 'read ()I' {
4 10
}
}
class 'pkg/TestAnonymousParams' {
method 'foo (Ljava/io/InputStream;I)V' {
a 12
c 13
10 14
}
}
Lines mapping:
24 <-> 13
27 <-> 11
30 <-> 14
31 <-> 15
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2016 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 pkg;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
public class TestAnonymousParams {
void foo(InputStream in, int a) throws IOException {
FilterInputStream filterInputStream = new FilterInputStream(in) {
@Override
public int read() throws IOException {
return a;
}
};
filterInputStream.read();
}
}
@@ -24,6 +24,7 @@ The Python plug-in provides smart editing for Python scripts. The feature set of
<depends optional="true" config-file="python-community-plugin-java.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="python-plugin-minor-ide.xml">com.intellij.modules.clion</depends>
<depends optional="true" config-file="python-plugin-minor-ide.xml">com.intellij.modules.webstorm</depends>
<depends optional="true" config-file="python-plugin-rider.xml">com.intellij.modules.rider</depends>
<!-- Two different versions of this file exist: one is used when building from sources (when auxiliary