mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
+1
-4
@@ -1,11 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>file:///Users/bas/Projects/IntelliJ IDEA Ultimate/community/plugins/InspectionGadgets/test/com/siyeh/igtest/j2me/abstract_class_with_only_one_direct_inheritor/AbstractClassWithOnlyOneDirectInheritor.java</file>
|
||||
<file>AbstractClassWithOnlyOneDirectInheritor.java</file>
|
||||
<line>3</line>
|
||||
<module>test_4290229602261428953</module>
|
||||
<package>com.siyeh.igtest.j2me.abstract_class_with_only_one_direct_inheritor</package>
|
||||
<entry_point TYPE="class" FQNAME="com.siyeh.igtest.j2me.abstract_class_with_only_one_direct_inheritor.AbstractClassWithOnlyOneDirectInheritor" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Abstract class which has only one direct inheritor</problem_class>
|
||||
<description>Abstract class <code>AbstractClassWithOnlyOneDirectInheritor</code> has only one direct inheritor #loc</description>
|
||||
</problem>
|
||||
|
||||
+2
-1
@@ -96,7 +96,8 @@ public class InjectLanguageAction implements IntentionAction {
|
||||
final PsiLanguageInjectionHost host = findInjectionHost(editor, file);
|
||||
if (host == null) return;
|
||||
if (defaultFunctionalityWorked(host, languageId)) return;
|
||||
final Language language = InjectedLanguage.findLanguageById(languageId);
|
||||
Language language = InjectedLanguage.findLanguageById(languageId);
|
||||
if (language == null) return;
|
||||
try {
|
||||
for (LanguageInjectionSupport support : InjectorUtils.getActiveInjectionSupports()) {
|
||||
if (support.addInjectionInPlace(language, host)) return;
|
||||
|
||||
@@ -319,7 +319,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
final PsiElement parent = typeDefinitionBody.getParent();
|
||||
if (parent instanceof GrAnonymousClassDefinition) {
|
||||
final PsiElement prev = typeDefinitionBody.getPrevSibling();
|
||||
if (prev != null && TokenSets.WHITE_SPACES_SET.contains(prev.getNode().getElementType()) && prev.getText().contains("\n")) {
|
||||
if (PsiUtil.isLineFeed(prev)) {
|
||||
myHolder.createErrorAnnotation(typeDefinitionBody, GroovyBundle.message("ambiguous.code.block"));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -134,7 +134,8 @@ public class GroovyStatementSelectioner implements ExtendWordSelectionHandler {
|
||||
if (!TokenSets.WHITE_SPACES_SET.contains(e.getNode().getElementType())) return false;
|
||||
|
||||
final String text = e.getText();
|
||||
return text.indexOf('\n') == text.lastIndexOf('\n');
|
||||
final int i = text.indexOf('\n');
|
||||
return i >= 0 && i == text.lastIndexOf('\n');
|
||||
}
|
||||
|
||||
private static boolean isSpaceWithoutLineFeed(PsiElement e) {
|
||||
|
||||
+3
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,6 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
|
||||
@@ -45,6 +44,7 @@ import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ControlFlowBuilder;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -162,7 +162,7 @@ public abstract class GrBlockImpl extends LazyParseablePsiElement implements GrC
|
||||
if (prev instanceof GrParameterList && prev.getTextLength() == 0 && prev.getPrevSibling() != null) {
|
||||
prev = prev.getPrevSibling();
|
||||
}
|
||||
if (!isNls(prev)) {
|
||||
if (!PsiUtil.isLineFeed(prev)) {
|
||||
addBefore(nls.getPsi(), actualAnchor);
|
||||
}
|
||||
}
|
||||
@@ -175,11 +175,6 @@ public abstract class GrBlockImpl extends LazyParseablePsiElement implements GrC
|
||||
}
|
||||
return element;
|
||||
}
|
||||
private static boolean isNls(PsiElement element) {
|
||||
if (!TokenSets.WHITE_SPACES_SET.contains(element.getNode().getElementType())) return false;
|
||||
String text = element.getText();
|
||||
return text.contains("\n") || text.contains("\r");
|
||||
}
|
||||
|
||||
public PsiElement getLBrace() {
|
||||
return findPsiChildByType(GroovyTokenTypes.mLCURLY);
|
||||
|
||||
@@ -1292,4 +1292,10 @@ public class PsiUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLineFeed(@Nullable PsiElement e) {
|
||||
return e != null &&
|
||||
TokenSets.WHITE_SPACES_SET.contains(e.getNode().getElementType()) &&
|
||||
(e.getText().indexOf('\n') >= 0 || e.getText().indexOf('\r') >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -352,8 +352,12 @@ public class ClassItemGeneratorImpl implements ClassItemGenerator {
|
||||
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(context.project);
|
||||
final String name = typeDefinition.getName();
|
||||
GrTypeDefinition tempClass = factory.createTypeDefinition("class " + name + " extends groovy.lang.Script {\n" +
|
||||
" def " + name + "(groovy.lang.Binding binding){ super(binding);}\n" +
|
||||
" def " + name + "(){super();}\n" +
|
||||
" def " + name + "(groovy.lang.Binding binding){\n" +
|
||||
" super(binding);\n" +
|
||||
" }\n" +
|
||||
" def " + name + "(){\n" +
|
||||
" super();\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
ContainerUtil.addAll(result, tempClass.getCodeConstructors());
|
||||
}
|
||||
|
||||
+32
-5
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.refactoring.convertToJava;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
@@ -23,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.noReturnMethod.MissingReturnInspection;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
|
||||
@@ -65,6 +68,8 @@ import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter.
|
||||
public class CodeBlockGenerator extends Generator {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.refactoring.convertToJava.CodeBlockGenerator");
|
||||
|
||||
private static final boolean IN_TEST = ApplicationManager.getApplication().isUnitTestMode();
|
||||
|
||||
private final StringBuilder builder;
|
||||
private final ExpressionContext context;
|
||||
|
||||
@@ -122,7 +127,7 @@ public class CodeBlockGenerator extends Generator {
|
||||
}
|
||||
|
||||
public void generateCodeBlock(GrCodeBlock block, boolean shouldInsertReturnNull) {
|
||||
builder.append("{\n");
|
||||
builder.append("{");
|
||||
GrParameter[] parameters;
|
||||
if (block.getParent() instanceof GrMethod) {
|
||||
GrMethod method = (GrMethod)block.getParent();
|
||||
@@ -149,16 +154,38 @@ public class CodeBlockGenerator extends Generator {
|
||||
}
|
||||
|
||||
public void visitStatementOwner(GrStatementOwner owner, boolean shouldInsertReturnNull) {
|
||||
final GrStatement[] statements = owner.getStatements();
|
||||
for (GrStatement statement : statements) {
|
||||
statement.accept(this);
|
||||
builder.append('\n');
|
||||
boolean hasLineFeed = false;
|
||||
for (PsiElement e = owner.getFirstChild(); e != null; e = e.getNextSibling()) {
|
||||
if (e instanceof GrStatement) {
|
||||
((GrStatement)e).accept(this);
|
||||
hasLineFeed = false;
|
||||
}
|
||||
else if (TokenSets.COMMENT_SET.contains(e.getNode().getElementType())) {
|
||||
builder.append(e.getText());
|
||||
}
|
||||
else if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isLineFeed(e)) {
|
||||
hasLineFeed = true;
|
||||
if (IN_TEST) {
|
||||
builder.append(genSameLineFeed(e.getText()));
|
||||
}
|
||||
else {
|
||||
builder.append(e.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldInsertReturnNull) {
|
||||
if (!hasLineFeed) {
|
||||
builder.append('\n');
|
||||
}
|
||||
builder.append("return null;\n");
|
||||
}
|
||||
}
|
||||
|
||||
private static String genSameLineFeed(String text) {
|
||||
final int count = StringUtil.countChars(text, '\n');
|
||||
return StringUtil.repeatSymbol('\n', count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitConstructorInvocation(final GrConstructorInvocation invocation) {
|
||||
GenerationUtil.writeStatement(builder, context, invocation, new StatementWriter() {
|
||||
|
||||
+1
-4
@@ -26,7 +26,6 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
@@ -39,7 +38,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
@@ -185,8 +183,7 @@ public class GroovyExtractMethodHandler implements RefactoringActionHandler {
|
||||
renameParameterOccurrences(newMethod, helper);
|
||||
GrReferenceAdjuster.shortenReferences(newMethod);
|
||||
PsiElement prev = newMethod.getPrevSibling();
|
||||
IElementType elementType = prev.getNode().getElementType();
|
||||
if (!TokenSets.WHITE_SPACES_SET.contains(elementType) || !prev.getText().contains("\n")) {
|
||||
if (!PsiUtil.isLineFeed(prev)) {
|
||||
newMethod.getParent().getNode().addLeaf(GroovyTokenTypes.mNLS, "\n", newMethod.getNode());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
print(new java.lang.Runnable() {
|
||||
public void run(java.lang.Object it) {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(anonymousFromMap.this, "foo}");
|
||||
}
|
||||
public void run(java.lang.Object it) {org.codehaus.groovy.runtime.DefaultGroovyMethods.print(anonymousFromMap.this, "foo}");}
|
||||
public void run() {
|
||||
this.run(null);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ org.codehaus.groovy.runtime.DefaultGroovyMethods.println(this, foo);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
an.run();
|
||||
|
||||
println(foo);
|
||||
return null;
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ org.codehaus.groovy.runtime.DefaultGroovyMethods.println(this, getFoo());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
an.run();
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
public class Foo {
|
||||
public void putAt(java.lang.String s, java.lang.Integer x, java.lang.Object value) {
|
||||
|
||||
}
|
||||
|
||||
public java.lang.Object getAt(java.lang.String s, java.lang.Integer x) {
|
||||
@@ -14,16 +15,23 @@ new arrayAccess(new groovy.lang.Binding(args)).run();
|
||||
|
||||
public java.lang.Object run() {
|
||||
java.util.HashMap<java.lang.String, java.lang.String> map = new java.util.HashMap<java.lang.String, java.lang.String>();
|
||||
|
||||
print(putAt0(map, "1", "6"));
|
||||
print(putAt0(map, 2, "7"));
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.putAt(map, "6", 1);
|
||||
|
||||
print(map.get("1"));
|
||||
print(map.get(2));
|
||||
|
||||
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.putAt("a", 2, 4);
|
||||
print(putAt1(foo, "a", 2, 4));
|
||||
|
||||
print(foo.getAt("b", 1));
|
||||
print(org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(foo, "4"));
|
||||
|
||||
java.lang.Integer[] arr = new java.lang.Integer[]{1, 2, 3};
|
||||
print(arr[1]);
|
||||
return arr[1] = 3;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
public class X {
|
||||
public X plus(X x) {
|
||||
return new X();
|
||||
}
|
||||
public X plus(X x) {return new X();}
|
||||
|
||||
}
|
||||
public class casts extends groovy.lang.Script {
|
||||
@@ -12,21 +10,33 @@ new casts(new groovy.lang.Binding(args)).run();
|
||||
public java.lang.Object run() {
|
||||
java.lang.Object a = new java.util.Date();
|
||||
java.util.Date d = (java.util.Date)a;
|
||||
|
||||
|
||||
|
||||
foo((java.util.Date)a);
|
||||
|
||||
d = ((java.util.Date)(a));
|
||||
|
||||
java.util.Date b = (java.util.Date)a;
|
||||
|
||||
a = org.codehaus.groovy.runtime.DateGroovyMethods.plus(a, 2);
|
||||
|
||||
|
||||
|
||||
X x = new X();
|
||||
|
||||
x = x.plus(new X());
|
||||
|
||||
x = x.plus(x);
|
||||
|
||||
print(x);
|
||||
|
||||
X y = true?x:new X();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void foo(java.util.Date d) {
|
||||
}
|
||||
public void foo(java.util.Date d) {}
|
||||
|
||||
public casts(groovy.lang.Binding binding) {
|
||||
super(binding);
|
||||
|
||||
+4
-7
@@ -1,11 +1,7 @@
|
||||
public class IntCat {
|
||||
public static void call(java.lang.Integer i) {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, i);
|
||||
}
|
||||
public static void call(java.lang.Integer i) {org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, i);}
|
||||
|
||||
public static void call(java.lang.Integer i, java.lang.String s) {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, s);
|
||||
}
|
||||
public static void call(java.lang.Integer i, java.lang.String s) {org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, s);}
|
||||
|
||||
}
|
||||
public class closureInUse extends groovy.lang.Script {
|
||||
@@ -14,6 +10,8 @@ new closureInUse(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
return org.codehaus.groovy.runtime.DefaultGroovyMethods.use(this, IntCat.class, new groovy.lang.Closure<java.lang.Void>(this, this) {
|
||||
public void doCall(java.lang.Object it) {
|
||||
IntCat.call(2);
|
||||
@@ -27,7 +25,6 @@ doCall(null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public closureInUse(groovy.lang.Binding binding) {
|
||||
|
||||
Vendored
+4
-2
@@ -6,12 +6,14 @@ public void setFoo(groovy.lang.Closure<java.lang.Integer> foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
private groovy.lang.Closure<java.lang.Integer> foo = new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(int x) {
|
||||
final groovy.lang.Reference<java.lang.Integer> i1 = new groovy.lang.Reference<java.lang.Integer>(x);
|
||||
public java.lang.Integer doCall(int x) {final groovy.lang.Reference<java.lang.Integer> i1 = new groovy.lang.Reference<java.lang.Integer>(x);
|
||||
|
||||
|
||||
return org.codehaus.groovy.runtime.DefaultGroovyMethods.each(1, new groovy.lang.Closure<java.lang.Void>(X.this, X.this) {
|
||||
public void doCall(java.lang.Object it) {
|
||||
i1.set(2);
|
||||
int i = 3;
|
||||
|
||||
}
|
||||
|
||||
public void doCall() {
|
||||
|
||||
@@ -4,7 +4,12 @@ new concurency(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
final java.util.concurrent.atomic.AtomicInteger counter = new java.util.concurrent.atomic.AtomicInteger();
|
||||
|
||||
|
||||
|
||||
java.lang.Thread th = org.codehaus.groovy.runtime.DefaultGroovyStaticMethods.start(null, new groovy.lang.Closure<java.lang.Void>(this, this) {
|
||||
public void doCall(java.lang.Object it) {
|
||||
for(java.lang.Integer i : new groovy.lang.IntRange(1, 8)){
|
||||
@@ -20,13 +25,16 @@ doCall(null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for(java.lang.Integer j : new groovy.lang.IntRange(1, 4)){
|
||||
org.codehaus.groovy.runtime.DefaultGroovyStaticMethods.sleep(null, 50);
|
||||
out("main loop " + java.lang.String.valueOf(j));
|
||||
counter.incrementAndGet();
|
||||
}
|
||||
|
||||
|
||||
th.join();
|
||||
|
||||
assert counter.get() == 12;
|
||||
return null;
|
||||
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
public class Base {
|
||||
public Base(java.lang.Integer a) {
|
||||
}
|
||||
public Base(java.lang.Integer a) {}
|
||||
}
|
||||
public class Inheritor extends Base {
|
||||
public Inheritor(int x, int y) {
|
||||
|
||||
+1
@@ -7,6 +7,7 @@ org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, invokeMethod("bar",
|
||||
java.lang.String s = "a";
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "bar", new java.lang.Object[]{4});
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "bar", new java.lang.Object[]{5}));
|
||||
|
||||
return org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "anme", new java.util.ArrayList<java.lang.Object>());
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, setProperty0(this,
|
||||
java.lang.String s = "a";
|
||||
s.bar = 4;
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, s.bar = 5);
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, getProperty("bar"));
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, s.bar);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
public enum E {
|
||||
abc{
|
||||
public java.lang.Integer foo() {
|
||||
return 0;
|
||||
}
|
||||
public java.lang.Integer foo() {return 0;}
|
||||
|
||||
private java.lang.Integer i = 23;
|
||||
|
||||
},cde(),efg(1);
|
||||
E(int x) {
|
||||
|
||||
}
|
||||
E() {
|
||||
this(2);
|
||||
|
||||
+1
-3
@@ -1,9 +1,7 @@
|
||||
public class Abc {
|
||||
public void foo(final int x) {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.times(2, new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(java.lang.Object it) {
|
||||
return x;
|
||||
}
|
||||
public java.lang.Integer doCall(java.lang.Object it) {return x;}
|
||||
|
||||
public java.lang.Integer doCall() {
|
||||
return doCall(null);
|
||||
|
||||
+1
-2
@@ -3,8 +3,7 @@ public class Foo {
|
||||
* method comment
|
||||
* @param f
|
||||
*/
|
||||
public <A, B> void abc(java.lang.Object f) {
|
||||
}
|
||||
public <A, B> void abc(java.lang.Object f) {}
|
||||
|
||||
public void abr() {
|
||||
abc(null);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
public class BigInteger {
|
||||
public BigInteger(int i, java.lang.Byte[] arr) {
|
||||
}
|
||||
public java.lang.String toString(int radix) {
|
||||
return "";
|
||||
}
|
||||
public BigInteger(int i, java.lang.Byte[] arr) {}
|
||||
public java.lang.String toString(int radix) {return "";}
|
||||
|
||||
}
|
||||
public class NoSuchAlgorithmException extends java.lang.Exception {
|
||||
@@ -13,12 +10,9 @@ public static MessageDigest getInstance(java.lang.String algorithm) throws NoSuc
|
||||
return new MessageDigest();
|
||||
}
|
||||
|
||||
public java.lang.Byte[] digest() {
|
||||
return new java.lang.Byte[0];
|
||||
}
|
||||
public java.lang.Byte[] digest() {return new java.lang.Byte[0];}
|
||||
|
||||
public void update(java.lang.Byte[] input, int offset, int len) {
|
||||
}
|
||||
public void update(java.lang.Byte[] input, int offset, int len) {}
|
||||
|
||||
}
|
||||
public class hash extends groovy.lang.Script {
|
||||
@@ -27,24 +21,37 @@ new hash(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int KB = 1024;
|
||||
int MB = 1024 * KB;
|
||||
|
||||
java.io.File f = new java.io.File(this.getBinding().getProperty("args")[0]);
|
||||
if (!f.exists() || !f.isFile()){
|
||||
println("Invalid file " + java.lang.String.valueOf(f) + " provided");
|
||||
println("Usage: groovy sha1.groovy <file_to_hash>");
|
||||
}
|
||||
|
||||
|
||||
final MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
|
||||
|
||||
long start = java.lang.System.currentTimeMillis();
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(f, MB, new groovy.lang.Closure<java.lang.Void>(this, this) {
|
||||
public void doCall(java.lang.Byte[] buf, int bytesRead) {
|
||||
messageDigest.update(buf, 0, bytesRead);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
java.lang.String sha1Hex = org.codehaus.groovy.runtime.DefaultGroovyMethods.padLeft(new BigInteger(1, messageDigest.digest()).toString(16), 40, "0");
|
||||
long delta = java.lang.System.currentTimeMillis() - start;
|
||||
|
||||
println(sha1Hex + " took " + java.lang.String.valueOf(delta) + " ms to calculate");
|
||||
return null;
|
||||
|
||||
|
||||
+3
@@ -13,7 +13,10 @@ new intPropAssignment(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
A a = new A();
|
||||
|
||||
print(3 + (setProp(a, 2 + 1)));
|
||||
return null;
|
||||
|
||||
|
||||
plugins/groovy/testdata/refactoring/convertGroovyToJava/file/methodParamInClosureImplicitReturn.java
Vendored
+5
-2
@@ -4,12 +4,13 @@ new methodParamInClosureImplicitReturn(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void foo(int x) {
|
||||
final groovy.lang.Reference<java.lang.Integer> i = new groovy.lang.Reference<java.lang.Integer>(x);
|
||||
public void foo(int x) {final groovy.lang.Reference<java.lang.Integer> i = new groovy.lang.Reference<java.lang.Integer>(x);
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(new java.util.ArrayList<java.lang.Integer>(java.util.Arrays.asList(1, 2, 3)), new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(java.lang.Object it) {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(methodParamInClosureImplicitReturn.this, i.get());
|
||||
@@ -21,6 +22,7 @@ return doCall(null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(new java.util.ArrayList<java.lang.Integer>(java.util.Arrays.asList(1, 2, 3)), new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(java.lang.Object it) {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(methodParamInClosureImplicitReturn.this, i.get());
|
||||
@@ -33,6 +35,7 @@ return doCall(null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
print(i.get());
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
public class X {
|
||||
public java.lang.Integer foo(int x) {
|
||||
final groovy.lang.Reference<java.lang.Integer> i1 = new groovy.lang.Reference<java.lang.Integer>(x);
|
||||
public java.lang.Integer foo(int x) {final groovy.lang.Reference<java.lang.Integer> i1 = new groovy.lang.Reference<java.lang.Integer>(x);
|
||||
|
||||
|
||||
return org.codehaus.groovy.runtime.DefaultGroovyMethods.each(1, new groovy.lang.Closure<java.lang.Void>(this, this) {
|
||||
public void doCall(java.lang.Object it) {
|
||||
i1.set(2);
|
||||
int i = 3;
|
||||
|
||||
}
|
||||
|
||||
public void doCall() {
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
public class A {
|
||||
public void foo(java.lang.Object p) {
|
||||
}
|
||||
public void foo(java.lang.Object p) {}
|
||||
|
||||
public void bar() {
|
||||
foo(null);
|
||||
|
||||
+3
@@ -13,7 +13,10 @@ new propAssignment(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
A a = new A();
|
||||
|
||||
print(3 + (setProp(a, 2 + 1)));
|
||||
return null;
|
||||
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
public class A {
|
||||
public void foo() {
|
||||
final groovy.lang.Reference<java.lang.Integer> x = new groovy.lang.Reference<java.lang.Integer>(2);
|
||||
|
||||
new java.lang.Runnable(){
|
||||
public void run() {
|
||||
x.set(4);
|
||||
|
||||
+3
@@ -1,11 +1,13 @@
|
||||
public class X {
|
||||
public void foo() {
|
||||
final groovy.lang.Reference<java.lang.Integer> ab = new groovy.lang.Reference<java.lang.Integer>(4);
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.each(this, new groovy.lang.Closure<X>(this, this) {
|
||||
public X doCall(java.lang.Object it) {
|
||||
return org.codehaus.groovy.runtime.DefaultGroovyMethods.each(X.this, new groovy.lang.Closure<java.lang.Integer>(X.this, X.this) {
|
||||
public java.lang.Integer doCall(java.lang.Object it) {
|
||||
return setGroovyRef(ab, 2);
|
||||
|
||||
}
|
||||
|
||||
public java.lang.Integer doCall() {
|
||||
@@ -20,6 +22,7 @@ return doCall(null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, ab.get());
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -5,6 +5,7 @@ new refInClosureInScript(new groovy.lang.Binding(args)).run();
|
||||
|
||||
public java.lang.Object run() {
|
||||
final groovy.lang.Reference<java.lang.Integer> foo = new groovy.lang.Reference<java.lang.Integer>(2);
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.times(3, new groovy.lang.Closure<java.lang.Void>(this, this) {
|
||||
public void doCall(java.lang.Object it) {
|
||||
foo.set(foo.get()++);
|
||||
|
||||
Vendored
+1
-2
@@ -1,6 +1,5 @@
|
||||
public class X {
|
||||
public void abc(foo.A a) {
|
||||
}
|
||||
public void abc(foo.A a) {}
|
||||
|
||||
public void cde() {
|
||||
abc(foo.A.Const);
|
||||
|
||||
Vendored
+1
@@ -4,6 +4,7 @@ new resolveMethodInsideClosure(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ new return2(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public boolean foo() {
|
||||
java.lang.Integer a = 5;
|
||||
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.times(a, new groovy.lang.Closure<java.lang.Integer>(this, this) {
|
||||
public java.lang.Integer doCall(java.lang.Object it) {
|
||||
if (it == 2)return 5;
|
||||
@@ -20,6 +22,7 @@ return doCall(null);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public return2(groovy.lang.Binding binding) {
|
||||
|
||||
@@ -11,17 +11,11 @@ public int foo3() {
|
||||
org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, "foo");
|
||||
}
|
||||
|
||||
public java.lang.Integer foo4() {
|
||||
return 1;
|
||||
}
|
||||
public java.lang.Integer foo4() {return 1;}
|
||||
|
||||
public java.lang.Integer foo5() {
|
||||
return 2;
|
||||
}
|
||||
public java.lang.Integer foo5() {return 2;}
|
||||
|
||||
public int foo6() {
|
||||
return 2;
|
||||
}
|
||||
public int foo6() {return 2;}
|
||||
|
||||
public java.lang.Integer foo7() {
|
||||
if (true)return 3; else return 4;
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ public void foo() {
|
||||
foox();
|
||||
}
|
||||
|
||||
public static void foox() {
|
||||
}
|
||||
public static void foox() {}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -13,6 +13,8 @@ new staticPropAssignment(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
print(3 + (setProp(2 + 1)));
|
||||
return null;
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ public @interface I {
|
||||
public int x() ;
|
||||
}
|
||||
@p.I public class A {
|
||||
@p.I public A() {
|
||||
}
|
||||
@p.I public A() {}
|
||||
}
|
||||
public class useAnno extends groovy.lang.Script {
|
||||
public static void main(java.lang.String[] args) {
|
||||
@@ -13,7 +12,17 @@ new p.useAnno(new groovy.lang.Binding(args)).run();
|
||||
}
|
||||
|
||||
public java.lang.Object run() {
|
||||
|
||||
|
||||
|
||||
|
||||
@p.I public java.lang.Integer var = 3;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user