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

Replace Guava's Objects by java.util.Objects #2992

Merged
merged 1 commit into from
Apr 15, 2024
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 @@ -14,6 +14,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -109,7 +110,6 @@
import org.eclipse.xtext.xbase.ui.imports.OrganizeImportsHandler;
import org.eclipse.xtext.xbase.ui.quickfix.XbaseQuickfixProvider;

import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
Expand Down Expand Up @@ -623,7 +623,7 @@ public void apply(EObject element, IModificationContext context) throws Exceptio
if (obj instanceof JvmDeclaredType) {
JvmDeclaredType type = (JvmDeclaredType) obj;
String typePackage = type.getPackageName();
if (Objects.equal(typePackage, oldPackageName) || typePackage != null && typePackage.startsWith(oldPackageName + ".")) {
if (Objects.equals(typePackage, oldPackageName) || typePackage != null && typePackage.startsWith(oldPackageName + ".")) {
type.internalSetIdentifier(null);
type.setPackageName(newPackageName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package org.eclipse.xtext.ide.tests.indentation;

import java.util.Objects;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.AbstractRule;
import org.eclipse.xtext.Action;
Expand All @@ -23,7 +25,6 @@
import org.junit.Test;

import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;
Expand Down Expand Up @@ -903,7 +904,7 @@ public boolean apply(T t) {
try {
return true;
} finally {
found = Objects.equal(t, element);
found = Objects.equals(t, element);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package org.eclipse.xtext.ide.tests.server.concurrent;

import java.util.Objects;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -36,7 +37,6 @@
import org.junit.Rule;
import org.junit.Test;

import com.google.common.base.Objects;
import com.google.common.util.concurrent.Uninterruptibles;
import com.google.inject.Guice;
import com.google.inject.Inject;
Expand Down Expand Up @@ -355,7 +355,7 @@ public void testReadCommandSubmitsWriteCommand() throws Exception {
@Override
protected void addRequest(AbstractRequest<?> request) {
if (((request instanceof WriteRequest)
&& Objects.equal(Thread.currentThread(), readerThreadRef.get()))) {
&& Objects.equals(Thread.currentThread(), readerThreadRef.get()))) {
super.addRequest(request);
addedFromReader.countDown();
Uninterruptibles.awaitUninterruptibly(submittedFromMain, 100, TimeUnit.MILLISECONDS);
Expand All @@ -366,7 +366,7 @@ protected void addRequest(AbstractRequest<?> request) {

@Override
protected void submitRequest(AbstractRequest<?> request) {
if (((request instanceof WriteRequest) && Objects.equal(Thread.currentThread(), mainThread))) {
if (((request instanceof WriteRequest) && Objects.equals(Thread.currentThread(), mainThread))) {
super.submitRequest(request);
submittedFromMain.countDown();
} else {
Expand All @@ -376,7 +376,7 @@ protected void submitRequest(AbstractRequest<?> request) {

@Override
protected CompletableFuture<Void> cancel() {
if (Objects.equal(Thread.currentThread(), mainThread)) {
if (Objects.equals(Thread.currentThread(), mainThread)) {
Uninterruptibles.awaitUninterruptibly(addedFromReader, 100, TimeUnit.MILLISECONDS);
}
return super.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import org.eclipse.emf.ecore.util.EcoreUtil;
Expand All @@ -25,7 +26,6 @@
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;

Expand Down Expand Up @@ -56,7 +56,7 @@ public void update(IReferenceUpdaterContext context) {
.head(delta.getSnapshot().getDescriptions()).getQualifiedName();
QualifiedName modified = IterableExtensions.head(delta.getDescriptions())
.getQualifiedName();
if (!Objects.equal(original, modified)) {
if (!Objects.equals(original, modified)) {
Import imp = imports.get(original);
if (imp != null) {
toChange.put(imp, modified);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package org.eclipse.xtext.ide.tests.testlanguage.rename;

import java.util.Objects;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.ide.server.rename.RenameService2;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
Expand All @@ -19,7 +21,6 @@
import org.eclipse.xtext.resource.EObjectAtOffsetHelper;
import org.eclipse.xtext.resource.XtextResource;

import com.google.common.base.Objects;
import com.google.inject.Inject;

public class TestLanguageRenameService extends RenameService2 {
Expand All @@ -43,8 +44,8 @@ protected EObject getElementWithIdentifierAt(XtextResource xtextResource, int of
QualifiedName fqn = nameProvider.getFullyQualifiedName(element);
if (fqn != null) {
String leafText = NodeModelUtils.getTokenText(leaf);
if (fqn.getSegmentCount() == 1 && Objects.equal(fqn.toString(), leafText)
|| Objects.equal(fqn.getLastSegment(), leafText)) {
if (fqn.getSegmentCount() == 1 && Objects.equals(fqn.toString(), leafText)
|| Objects.equals(fqn.getLastSegment(), leafText)) {
return element;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.lsp4j.ParameterInformation;
Expand All @@ -39,7 +40,6 @@
import org.eclipse.xtext.xbase.lib.IterableExtensions;

import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -199,7 +199,7 @@ private Iterable<Operation> getVisibleOperationsWithName(EObject object, String
scopeProvider.getScope(object, TestLanguagePackage.Literals.OPERATION_CALL__OPERATION)
.getAllElements(),
(IEObjectDescription it) -> it.getEClass() == TestLanguagePackage.Literals.OPERATION),
(IEObjectDescription it) -> Objects.equal(it.getQualifiedName().getLastSegment(), name)),
(IEObjectDescription it) -> Objects.equals(it.getQualifiedName().getLastSegment(), name)),
IEObjectDescription::getEObjectOrProxy), Operation.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
*/
package org.eclipse.xtext.ide.editor.contentassist;

import java.util.Objects;

import org.eclipse.xtext.resource.IEObjectDescription;

import com.google.common.base.Objects;
import com.google.inject.Singleton;

/**
Expand All @@ -34,7 +35,7 @@ protected int adjustPriority(ContentAssistEntry entry, int priority) {
if (!Character.isLetter(entry.getProposal().charAt(0))) {
adjustedPriority = adjustedPriority - 30;
}
if (Objects.equal(entry.getProposal(), entry.getPrefix())) {
if (Objects.equals(entry.getProposal(), entry.getPrefix())) {
adjustedPriority = adjustedPriority - 20;
}
return adjustedPriority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*******************************************************************************/
package org.eclipse.xtext.ide.editor.folding;

import org.eclipse.xtext.util.ITextRegion;
import java.util.Objects;

import com.google.common.base.Objects;
import org.eclipse.xtext.util.ITextRegion;

/**
* Represents an abstraction for different folding implementations.
Expand Down Expand Up @@ -70,15 +70,15 @@ public boolean equals(Object other) {
if (other instanceof FoldingRange) {
FoldingRange range = (FoldingRange) other;
return offset == range.offset && length == range.length && initiallyFolded == range.initiallyFolded
&& Objects.equal(kind, range.kind)
&& Objects.equal(visualPlaceholderRegion, range.visualPlaceholderRegion);
&& Objects.equals(kind, range.kind)
&& Objects.equals(visualPlaceholderRegion, range.visualPlaceholderRegion);
}
return false;
}

@Override
public int hashCode() {
return Objects.hashCode(offset, length, initiallyFolded, kind, visualPlaceholderRegion);
return Objects.hash(offset, length, initiallyFolded, kind, visualPlaceholderRegion);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package org.eclipse.xtext.ide.editor.hierarchy;

import java.util.Objects;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
Expand All @@ -24,7 +26,6 @@
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Provider;

Expand Down Expand Up @@ -65,7 +66,7 @@ protected IEObjectDescription getDescription(URI objectURI) {
return null;
}
for (IEObjectDescription o : resourceDescription.getExportedObjects()) {
if (Objects.equal(o.getEObjectURI(), objectURI)) {
if (Objects.equals(o.getEObjectURI(), objectURI)) {
return o;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.eclipse.emf.common.util.URI;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.util.Wrapper;

import com.google.common.base.Objects;

/**
* @author kosyakov - Initial contribution and API
* @since 2.10
Expand Down Expand Up @@ -54,7 +53,7 @@ protected boolean internalIsRecursive() {
while (node != null) {
URI nodeElementUri = node.getElement().getEObjectURI();
URI elementUri = this.element.getEObjectURI();
if (Objects.equal(nodeElementUri, elementUri)) {
if (Objects.equals(nodeElementUri, elementUri)) {
return true;
}
node = node.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;

Expand All @@ -23,7 +24,6 @@
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.util.Arrays;

import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -131,7 +131,7 @@ protected boolean isUserDataEqual(IEObjectDescription oldObj, IEObjectDescriptio
return false;
String oldValue = oldObj.getUserData(key);
String newValue = newObj.getUserData(key);
if (!Objects.equal(oldValue, newValue))
if (!Objects.equals(oldValue, newValue))
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.eclipse.xtext.ide.serializer.impl;

import java.util.List;
import java.util.Objects;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
Expand Down Expand Up @@ -39,7 +40,6 @@
import org.eclipse.xtext.scoping.IScopeProvider;
import org.eclipse.xtext.serializer.tokens.SerializerScopeProviderBinding;

import com.google.common.base.Objects;
import com.google.inject.Inject;

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ protected boolean needsUpdating(IReferenceUpdaterContext context, IUpdatableRefe
return true;
}
Delta sourceDelta = findContainingDelta(deltas, ref.getSourceEObject());
return !Objects.equal(sourceDelta, targetDelta);
return !Objects.equals(sourceDelta, targetDelta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -145,7 +146,6 @@
import org.eclipse.xtext.xbase.lib.Pair;

import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
Expand Down Expand Up @@ -248,7 +248,7 @@ public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
protected boolean clientSupportsWorkspaceFolders() {
return this.initializeParams.getCapabilities() != null
&& this.initializeParams.getCapabilities().getWorkspace() != null
&& Objects.equal(this.initializeParams.getCapabilities().getWorkspace().getWorkspaceFolders(), Boolean.TRUE);
&& Objects.equals(this.initializeParams.getCapabilities().getWorkspace().getWorkspaceFolders(), Boolean.TRUE);
}

/**
Expand Down Expand Up @@ -312,7 +312,7 @@ protected ServerCapabilities createServerCapabilities(InitializeParams params) {
if (rename != null) {
prepareSupport = rename.getPrepareSupport();
}
boolean clientPrepareSupport = Objects.equal(Boolean.TRUE, prepareSupport);
boolean clientPrepareSupport = Objects.equals(Boolean.TRUE, prepareSupport);
if (clientPrepareSupport && allLanguages.stream()
.anyMatch(serviceProvider -> serviceProvider.get(IRenameService2.class) != null)) {
RenameOptions renameOptions = new RenameOptions();
Expand Down Expand Up @@ -1123,7 +1123,7 @@ public Map<String, JsonRpcMethod> supportedMethods() {
+ "\' can not be an extension as it is already defined in the LSP standard.");
} else {
JsonRpcMethod existing = extensions.put(entry.getKey(), entry.getValue());
if (existing != null && !Objects.equal(existing, entry.getValue())) {
if (existing != null && !Objects.equals(existing, entry.getValue())) {
LOG.error("An incompatible LSP extension \'" + entry.getKey()
+ "\' has already been registered. Using 1 ignoring 2. \n1 : " + existing
+ " \n2 : " + entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.concurrent.Future;

import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.InputOutput;

import com.google.common.base.Objects;
import com.google.common.io.ByteStreams;
import com.google.inject.Guice;
import com.google.inject.Inject;
Expand Down Expand Up @@ -119,7 +119,7 @@ public static boolean testArg(String[] args, String... values) {

public static boolean testArg(String arg, String... values) {
for(String value : values) {
if (Objects.equal(value, arg)) {
if (Objects.equals(value, arg)) {
return true;
}
}
Expand Down
Loading
Loading