Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit java.util.Objects in generated code instead of Guava's Objects #2993

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class CompilerBug424763Test extends AbstractXtendCompilerTest {
}
}
''', '''
import com.google.common.base.Objects;
import java.util.ArrayList;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Functions.Function0;

@SuppressWarnings("all")
Expand All @@ -118,7 +118,7 @@ class CompilerBug424763Test extends AbstractXtendCompilerTest {

public Test(final Function0<JAVA_TYPE> theConstructor, final Class<JAVA_TYPE> theType) {
Function0<JAVA_TYPE> _xifexpression = null;
boolean _equals = Objects.equal(theConstructor, null);
boolean _equals = Objects.equals(theConstructor, null);
if (_equals) {
_xifexpression = new NoConstructor<JAVA_TYPE>(theType);
} else {
Expand Down Expand Up @@ -237,7 +237,7 @@ class CompilerBug424763Test extends AbstractXtendCompilerTest {
}
}
''', '''
import com.google.common.base.Objects;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Functions.Function0;

@SuppressWarnings("all")
Expand All @@ -246,7 +246,7 @@ class CompilerBug424763Test extends AbstractXtendCompilerTest {

public Test(final Function0<JAVA_TYPE> theConstructor, final Class<JAVA_TYPE> theType) {
Function0<JAVA_TYPE> _xifexpression = null;
boolean _equals = Objects.equal(theConstructor, null);
boolean _equals = Objects.equals(theConstructor, null);
if (_equals) {
Class<JAVA_TYPE> _xtrycatchfinallyexpression = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1121,12 +1121,12 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
''', '''
package org.eclipse.xtext.xbase.formatting;

import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.preferences.PreferenceKey;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
Expand Down Expand Up @@ -1202,7 +1202,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
_elvis = Integer.valueOf(0);
}
final int newLines2 = (int) _elvis;
if (((Objects.equal(it.space, null) && Objects.equal(it.newLines, null)) || ((leafs.getNewLinesInComments() == 0) && ((newLines2 == 0) || Objects.equal(it.space, ""))))) {
if (((Objects.equals(it.space, null) && Objects.equals(it.newLines, null)) || ((leafs.getNewLinesInComments() == 0) && ((newLines2 == 0) || Objects.equals(it.space, ""))))) {
return FormattingDataFactory.this.newWhitespaceData(leafs, it.space, it.increaseIndentationChange, it.decreaseIndentationChange, doc.isDebugConflicts());
} else {
return FormattingDataFactory.this.newNewLineData(leafs, newLines2, newLines2, it.increaseIndentationChange, it.decreaseIndentationChange, doc.isDebugConflicts());
Expand Down Expand Up @@ -1472,7 +1472,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
WhitespaceData _whitespaceData_1 = new WhitespaceData(_offset_2, _length_1, increaseIndentationChange, decreaseIndentationChange, _xifexpression_3, _xifexpression_4);
result.add(_whitespaceData_1);
} else {
if ((equalIndentationChange && (!Objects.equal(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
int _offset_4 = ((WhitespaceInfo)leaf).getOffset();
int _length_2 = ((WhitespaceInfo)leaf).getLength();
RuntimeException _xifexpression_6 = null;
Expand Down Expand Up @@ -1515,7 +1515,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
if (_endsWithNewLine_2) {
newLines_1 = (newLines_1 - 1);
}
if ((equalIndentationChange && (!Objects.equal(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
if ((equalIndentationChange && (!Objects.equals(IterableExtensions.<LeafInfo>last(leafs.getLeafs()), leaf)))) {
int _offset_6 = ((WhitespaceInfo)leaf).getOffset();
int _length_4 = ((WhitespaceInfo)leaf).getLength();
RuntimeException _xifexpression_10 = null;
Expand Down Expand Up @@ -1550,7 +1550,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {

public Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> append(final INode node, final Procedure1<? super FormattingDataFactory.FormattingDataInit> init) {
Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _xifexpression = null;
boolean _notEquals = (!Objects.equal(node, null));
boolean _notEquals = (!Objects.equals(node, null));
if (_notEquals) {
_xifexpression = this.newFormattingData(this._hiddenLeafAccess.getHiddenLeafsAfter(node), init);
}
Expand All @@ -1559,7 +1559,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {

public Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> prepend(final INode node, final Procedure1<? super FormattingDataFactory.FormattingDataInit> init) {
Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _xifexpression = null;
boolean _notEquals = (!Objects.equal(node, null));
boolean _notEquals = (!Objects.equals(node, null));
if (_notEquals) {
_xifexpression = this.newFormattingData(this._hiddenLeafAccess.getHiddenLeafsBefore(node), init);
}
Expand All @@ -1572,7 +1572,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
ArrayList<FormattingData> _xblockexpression = null;
{
final ArrayList<FormattingData> result = CollectionLiterals.<FormattingData>newArrayList();
boolean _notEquals = (!Objects.equal(node, null));
boolean _notEquals = (!Objects.equals(node, null));
if (_notEquals) {
Iterable<FormattingData> _elvis = null;
Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData = FormattingDataFactory.this.newFormattingData(FormattingDataFactory.this._hiddenLeafAccess.getHiddenLeafsBefore(node), init);
Expand Down Expand Up @@ -1615,7 +1615,7 @@ class CompilerBug427637Test extends AbstractXtendCompilerTest {
ArrayList<FormattingData> _xblockexpression = null;
{
final ArrayList<FormattingData> result = CollectionLiterals.<FormattingData>newArrayList();
boolean _notEquals = (!Objects.equal(node, null));
boolean _notEquals = (!Objects.equals(node, null));
if (_notEquals) {
Iterable<FormattingData> _elvis = null;
Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData = FormattingDataFactory.this.newFormattingData(FormattingDataFactory.this._hiddenLeafAccess.getHiddenLeafsBefore(node), before);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class CompilerBug451814Test extends AbstractXtendCompilerTest {
}
}
''', '''
import com.google.common.base.Objects;
import com.google.common.io.LineReader;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Exceptions;

@SuppressWarnings("all")
Expand All @@ -67,7 +67,7 @@ class CompilerBug451814Test extends AbstractXtendCompilerTest {
try {
int counter = 0;
LineReader reader = null;
if (((counter == 0) && (!Objects.equal(reader.readLine(), null)))) {
if (((counter == 0) && (!Objects.equals(reader.readLine(), null)))) {
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
Expand All @@ -90,8 +90,8 @@ class CompilerBug451814Test extends AbstractXtendCompilerTest {
}
}
''', '''
import com.google.common.base.Objects;
import com.google.common.io.LineReader;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Exceptions;

@SuppressWarnings("all")
Expand All @@ -100,7 +100,7 @@ class CompilerBug451814Test extends AbstractXtendCompilerTest {
try {
int counter = 0;
LineReader reader = null;
while (((counter == 0) && (!Objects.equal(reader.readLine(), null)))) {
while (((counter == 0) && (!Objects.equals(reader.readLine(), null)))) {
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
Expand All @@ -121,8 +121,8 @@ class CompilerBug451814Test extends AbstractXtendCompilerTest {
}
}
''', '''
import com.google.common.base.Objects;
import com.google.common.io.LineReader;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Exceptions;

@SuppressWarnings("all")
Expand All @@ -131,7 +131,7 @@ class CompilerBug451814Test extends AbstractXtendCompilerTest {
try {
LineReader reader = null;
do {
} while((!Objects.equal(reader.readLine(), null)));
} while((!Objects.equals(reader.readLine(), null)));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
}
}
'''.assertCompilesTo('''
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

Expand All @@ -37,7 +37,7 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
public static <T extends Object> ImmutableList<T> m(final List<? extends T> list, final T value) {
final Function1<T, Boolean> _function = new Function1<T, Boolean>() {
public Boolean apply(final T it) {
return Boolean.valueOf((!Objects.equal(it, value)));
return Boolean.valueOf((!Objects.equals(it, value)));
}
};
return ImmutableList.<T>builder().addAll(IterableExtensions.filter(list, _function)).build();
Expand All @@ -57,9 +57,9 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
}
}
'''.assertCompilesTo('''
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

Expand All @@ -68,7 +68,7 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
public static <T extends Object> ImmutableList<T> m(final List<T> list, final T value) {
final Function1<T, Boolean> _function = new Function1<T, Boolean>() {
public Boolean apply(final T it) {
return Boolean.valueOf((!Objects.equal(it, value)));
return Boolean.valueOf((!Objects.equals(it, value)));
}
};
return ImmutableList.<T>builder().addAll(IterableExtensions.<T>filter(list, _function)).build();
Expand All @@ -88,9 +88,9 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
}
}
'''.assertCompilesTo('''
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

Expand All @@ -99,7 +99,7 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
public static <T extends Object> ImmutableList<Object> m(final List<? super T> list, final T value) {
final Function1<Object, Boolean> _function = new Function1<Object, Boolean>() {
public Boolean apply(final Object it) {
return Boolean.valueOf((!Objects.equal(it, value)));
return Boolean.valueOf((!Objects.equals(it, value)));
}
};
return ImmutableList.<Object>builder().addAll(IterableExtensions.filter(list, _function)).build();
Expand Down Expand Up @@ -237,8 +237,8 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
}
}
'''.assertCompilesTo('''
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import java.util.Objects;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
Expand All @@ -248,7 +248,7 @@ class CompilerBug461923Test extends AbstractXtendCompilerTest {
public static <T extends Object> ImmutableList<T> m(final T[] arr, final T value) {
final Function1<T, Boolean> _function = new Function1<T, Boolean>() {
public Boolean apply(final T it) {
return Boolean.valueOf((!Objects.equal(it, value)));
return Boolean.valueOf((!Objects.equals(it, value)));
}
};
return ImmutableList.<T>builder().addAll(IterableExtensions.<T>filter(((Iterable<T>)Conversions.doWrapArray(arr)), _function)).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class CompilerBug472142Test extends AbstractXtendCompilerTest {
}
}
'''.assertCompilesTo('''
import com.google.common.base.Objects;
import java.util.List;
import java.util.Objects;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

Expand All @@ -106,7 +106,7 @@ class CompilerBug472142Test extends AbstractXtendCompilerTest {
public CharSequence m() {
CharSequence _xblockexpression = null;
{
boolean _equals = Objects.equal(this.mySeq, null);
boolean _equals = Objects.equals(this.mySeq, null);
if (_equals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("s2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ class CompilerBug491931Test extends AbstractXtendCompilerTest {
}
}
'''.assertCompilesTo('''
import com.google.common.base.Objects;
import java.util.Objects;

@SuppressWarnings("all")
public class C {
public boolean foo(final CharSequence obj) {
return (!((obj.subSequence(1, 1) instanceof String) && (!Objects.equal(obj, null))));
return (!((obj.subSequence(1, 1) instanceof String) && (!Objects.equals(obj, null))));
}
}
''')
Expand Down
Loading
Loading