1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Removed redundant methods.

This commit is contained in:
Sergey Prigogin 2014-02-18 17:59:39 -08:00
parent 0c0523d642
commit 6677a74ae0
7 changed files with 23 additions and 52 deletions

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.Objects;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
@ -63,6 +65,6 @@ public class CHMultiDefNode extends CHNode {
return false;
final CHMultiDefNode rhs = (CHMultiDefNode) o;
return CoreUtility.safeEquals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
return Objects.equals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.eclipse.core.runtime.IAdaptable;
@ -83,7 +84,7 @@ public class CHNode implements IAdaptable {
return false;
}
return CoreUtility.safeEquals(fRepresentedDecl, rhs.fRepresentedDecl);
return Objects.equals(fRepresentedDecl, rhs.fRepresentedDecl);
}
private boolean computeIsRecursive(CHNode parent, ICElement decl) {

View file

@ -77,7 +77,6 @@ import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.CopyTreeAction;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
import org.eclipse.cdt.internal.ui.util.Messages;
import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
@ -480,7 +479,7 @@ public class CHViewPart extends ViewPart {
CHNode n2= (CHNode) e2;
int offset1= n1.getFirstReferenceOffset();
int offset2= n2.getFirstReferenceOffset();
return CoreUtility.compare(offset1, offset2);
return Integer.compare(offset1, offset2);
}
};

View file

@ -12,6 +12,8 @@
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.Objects;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@ -60,17 +62,17 @@ public class IBFile {
public boolean equals(Object obj) {
if (obj instanceof IBFile) {
IBFile file = (IBFile) obj;
return (CoreUtility.safeEquals(fLocation, file.fLocation) &&
CoreUtility.safeEquals(fTU, file.fTU));
return (Objects.equals(fLocation, file.fLocation) &&
Objects.equals(fTU, file.fTU));
}
return super.equals(obj);
}
@Override
public int hashCode() {
return CoreUtility.safeHashcode(fLocation)
+ 31* (CoreUtility.safeHashcode(fTU)
+ 31* CoreUtility.safeHashcode(fName));
return Objects.hashCode(fLocation)
+ 31* (Objects.hashCode(fTU)
+ 31* Objects.hashCode(fName));
}
public ITranslationUnit getTranslationUnit() {

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser;
import java.util.Objects;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
@ -80,7 +82,7 @@ public class IBNode implements IAdaptable {
return false;
}
return CoreUtility.safeEquals(fRepresentedFile, rhs.fRepresentedFile);
return Objects.equals(fRepresentedFile, rhs.fRepresentedFile);
}
private boolean computeIsRecursive(IBNode parent, IIndexFileLocation ifl) {

View file

@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import org.eclipse.core.runtime.IAdaptable;
@ -66,7 +67,7 @@ public class THNode implements IAdaptable {
return false;
}
return CoreUtility.safeEquals(fElement, rhs.fElement);
return Objects.equals(fElement, rhs.fElement);
}
/**

View file

@ -21,36 +21,33 @@ import org.eclipse.swt.custom.BusyIndicator;
import org.osgi.framework.Bundle;
public class CoreUtility {
/**
* Creates a folder and all parent folders if not existing.
* Project must exist.
* <code> org.eclipse.ui.dialogs.ContainerGenerator</code> is too heavy
* {@link org.eclipse.ui.dialogs.ContainerGenerator} is too heavy
* (creates a runnable)
*/
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
if (!folder.exists()) {
IContainer parent= folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder)parent, force, local, null);
createFolder((IFolder) parent, force, local, null);
}
folder.create(force, local, monitor);
}
}
/**
* Creates an extension. If the extension plugin has not
* been loaded a busy cursor will be activated during the duration of
* the load.
* Creates an extension. If the extension plugin has not been loaded,
* a busy cursor will be activated during the duration of the load.
*
* @param element the config element defining the extension
* @param classAttribute the name of the attribute carrying the class
* @return the extension object
*/
public static Object createExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
// If plugin has been loaded create extension.
// If plugin has been loaded, create extension.
// Otherwise, show busy cursor then create extension.
String id= element.getContributor().getName();
Bundle bundle = Platform.getBundle(id);
if(bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
@ -72,38 +69,5 @@ public class CoreUtility {
throw exc[0];
return ret[0];
}
/**
* Calls equals after checking for nulls
*/
public static boolean safeEquals(Object lhs, Object rhs) {
if (lhs==rhs) {
return true;
}
if (lhs == null || rhs == null) {
return false;
}
return lhs.equals(rhs);
}
/**
* Calls hashCode after checking for null
*/
public static int safeHashcode(Object o) {
return o == null ? 0 : o.hashCode();
}
/**
* Comparse two integers.
*/
public static int compare(int lhs, int rhs) {
if (lhs < rhs) {
return -1;
}
if (lhs > rhs) {
return 1;
}
return 0;
}
}