mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Removed redundant methods.
This commit is contained in:
parent
0c0523d642
commit
6677a74ae0
7 changed files with 23 additions and 52 deletions
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.callhierarchy;
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
|
@ -63,6 +65,6 @@ public class CHMultiDefNode extends CHNode {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
final CHMultiDefNode rhs = (CHMultiDefNode) o;
|
final CHMultiDefNode rhs = (CHMultiDefNode) o;
|
||||||
return CoreUtility.safeEquals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
|
return Objects.equals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public class CHNode implements IAdaptable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreUtility.safeEquals(fRepresentedDecl, rhs.fRepresentedDecl);
|
return Objects.equals(fRepresentedDecl, rhs.fRepresentedDecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean computeIsRecursive(CHNode parent, ICElement decl) {
|
private boolean computeIsRecursive(CHNode parent, ICElement decl) {
|
||||||
|
|
|
@ -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.actions.CopyTreeAction;
|
||||||
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
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.util.Messages;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||||
|
@ -480,7 +479,7 @@ public class CHViewPart extends ViewPart {
|
||||||
CHNode n2= (CHNode) e2;
|
CHNode n2= (CHNode) e2;
|
||||||
int offset1= n1.getFirstReferenceOffset();
|
int offset1= n1.getFirstReferenceOffset();
|
||||||
int offset2= n2.getFirstReferenceOffset();
|
int offset2= n2.getFirstReferenceOffset();
|
||||||
return CoreUtility.compare(offset1, offset2);
|
return Integer.compare(offset1, offset2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
@ -60,17 +62,17 @@ public class IBFile {
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof IBFile) {
|
if (obj instanceof IBFile) {
|
||||||
IBFile file = (IBFile) obj;
|
IBFile file = (IBFile) obj;
|
||||||
return (CoreUtility.safeEquals(fLocation, file.fLocation) &&
|
return (Objects.equals(fLocation, file.fLocation) &&
|
||||||
CoreUtility.safeEquals(fTU, file.fTU));
|
Objects.equals(fTU, file.fTU));
|
||||||
}
|
}
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return CoreUtility.safeHashcode(fLocation)
|
return Objects.hashCode(fLocation)
|
||||||
+ 31* (CoreUtility.safeHashcode(fTU)
|
+ 31* (Objects.hashCode(fTU)
|
||||||
+ 31* CoreUtility.safeHashcode(fName));
|
+ 31* Objects.hashCode(fName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITranslationUnit getTranslationUnit() {
|
public ITranslationUnit getTranslationUnit() {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.includebrowser;
|
package org.eclipse.cdt.internal.ui.includebrowser;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -80,7 +82,7 @@ public class IBNode implements IAdaptable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreUtility.safeEquals(fRepresentedFile, rhs.fRepresentedFile);
|
return Objects.equals(fRepresentedFile, rhs.fRepresentedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean computeIsRecursive(IBNode parent, IIndexFileLocation ifl) {
|
private boolean computeIsRecursive(IBNode parent, IIndexFileLocation ifl) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ public class THNode implements IAdaptable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreUtility.safeEquals(fElement, rhs.fElement);
|
return Objects.equals(fElement, rhs.fElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,11 +21,10 @@ import org.eclipse.swt.custom.BusyIndicator;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
public class CoreUtility {
|
public class CoreUtility {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a folder and all parent folders if not existing.
|
* Creates a folder and all parent folders if not existing.
|
||||||
* Project must exist.
|
* 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)
|
* (creates a runnable)
|
||||||
*/
|
*/
|
||||||
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
|
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
|
||||||
|
@ -39,18 +38,16 @@ public class CoreUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an extension. If the extension plugin has not
|
* Creates an extension. If the extension plugin has not been loaded,
|
||||||
* been loaded a busy cursor will be activated during the duration of
|
* a busy cursor will be activated during the duration of the load.
|
||||||
* the load.
|
|
||||||
*
|
*
|
||||||
* @param element the config element defining the extension
|
* @param element the config element defining the extension
|
||||||
* @param classAttribute the name of the attribute carrying the class
|
* @param classAttribute the name of the attribute carrying the class
|
||||||
* @return the extension object
|
* @return the extension object
|
||||||
*/
|
*/
|
||||||
public static Object createExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
|
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.
|
// Otherwise, show busy cursor then create extension.
|
||||||
|
|
||||||
String id= element.getContributor().getName();
|
String id= element.getContributor().getName();
|
||||||
Bundle bundle = Platform.getBundle(id);
|
Bundle bundle = Platform.getBundle(id);
|
||||||
if(bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
|
if(bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
|
||||||
|
@ -72,38 +69,5 @@ public class CoreUtility {
|
||||||
throw exc[0];
|
throw exc[0];
|
||||||
return ret[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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue