mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Cosmetics.
This commit is contained in:
parent
830c09b3be
commit
1e598a2202
3 changed files with 52 additions and 57 deletions
|
@ -9,7 +9,6 @@
|
|||
* Andrew Gvozdev - Initial API and implementation
|
||||
* James Blackburn (Broadcom Corp.)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.testplugin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -27,8 +26,6 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
|
@ -54,6 +51,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* This class contains utility methods for creating resources
|
||||
|
@ -66,7 +64,6 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
*
|
||||
* @since 6.0
|
||||
*/
|
||||
|
||||
public class ResourceHelper {
|
||||
private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
|
||||
private static final int MAX_RETRY= 5;
|
||||
|
@ -193,7 +190,7 @@ public class ResourceHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a plain Eclipse project.
|
||||
* Creates a plain Eclipse project.
|
||||
*
|
||||
* @param projectName
|
||||
* @return the project handle
|
||||
|
@ -202,10 +199,11 @@ public class ResourceHelper {
|
|||
public static IProject createProject(String projectName) throws CoreException {
|
||||
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project= root.getProject(projectName);
|
||||
if (!project.exists())
|
||||
if (!project.exists()) {
|
||||
project.create(NULL_MONITOR);
|
||||
else
|
||||
} else {
|
||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
}
|
||||
|
||||
if (!project.isOpen())
|
||||
project.open(NULL_MONITOR);
|
||||
|
@ -215,7 +213,7 @@ public class ResourceHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete project by name.
|
||||
* Deletes project by name.
|
||||
*
|
||||
* @param projectName
|
||||
* @throws CoreException
|
||||
|
@ -228,7 +226,7 @@ public class ResourceHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete given project with content.
|
||||
* Deletes given project with content.
|
||||
*
|
||||
* @param project
|
||||
* @throws CoreException
|
||||
|
@ -238,7 +236,7 @@ public class ResourceHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete project.
|
||||
* Deletes project.
|
||||
*
|
||||
* @param project
|
||||
* @param deleteContent whether to delete project content
|
||||
|
@ -542,7 +540,6 @@ public class ResourceHelper {
|
|||
*/
|
||||
public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath)
|
||||
throws IOException, CoreException, UnsupportedOperationException {
|
||||
|
||||
if (!isSymbolicLinkSupported()) {
|
||||
throw new UnsupportedOperationException("Windows links .lnk are not supported.");
|
||||
}
|
||||
|
@ -589,13 +586,13 @@ public class ResourceHelper {
|
|||
for (int i = 0; i < 5; i++) {
|
||||
try {
|
||||
Assert.assertTrue("ln process exited with non-zero status", process.waitFor() == 0);
|
||||
// If exitValue succeeded, then the process has exitted successfully.
|
||||
// If exitValue succeeded, then the process has exited successfully.
|
||||
break;
|
||||
} catch (InterruptedException e) {
|
||||
// Clear interrupted state, see Java bug http://bugs.sun.com/view_bug.do?bug_id=6420270
|
||||
Thread.interrupted();
|
||||
}
|
||||
// wait for a 500ms before checking again
|
||||
// Wait for a 500ms before checking again.
|
||||
try { Thread.sleep(500); } catch (InterruptedException e) {/*don't care*/}
|
||||
}
|
||||
Assert.assertTrue("Symbolic link not created, command=[" + command + "]", linkPath.toFile().exists());
|
||||
|
@ -617,7 +614,6 @@ public class ResourceHelper {
|
|||
*/
|
||||
public static IResource createSymbolicLink(IProject project, String linkName, String realPath)
|
||||
throws IOException, CoreException, UnsupportedOperationException {
|
||||
|
||||
return createSymbolicLink(project, linkName, new Path(realPath));
|
||||
}
|
||||
|
||||
|
@ -701,13 +697,14 @@ public class ResourceHelper {
|
|||
|
||||
// Remove IResources created by this helper
|
||||
for (IResource r : resourcesCreated) {
|
||||
if (r.exists())
|
||||
if (r.exists()) {
|
||||
try {
|
||||
r.delete(true, NULL_MONITOR);
|
||||
} catch (CoreException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
resourcesCreated.clear();
|
||||
}
|
||||
|
||||
|
@ -733,12 +730,15 @@ public class ResourceHelper {
|
|||
// Ensure that the file being deleted is a child of the workspace
|
||||
// root to prevent anything nasty happening
|
||||
if (!f.getAbsolutePath().startsWith(
|
||||
ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath()))
|
||||
ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath())) {
|
||||
throw new IllegalArgumentException("File must exist within the workspace!");
|
||||
}
|
||||
|
||||
if (f.isDirectory())
|
||||
for (File f1 : f.listFiles())
|
||||
if (f.isDirectory()) {
|
||||
for (File f1 : f.listFiles()) {
|
||||
deleteRecursive(f1);
|
||||
}
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.browser;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.IFunctionInfo;
|
||||
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
|
||||
|
@ -39,22 +37,13 @@ import org.eclipse.core.runtime.Assert;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Type info object needed to support search for local variables.
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
|
||||
private static int hashCode(String[] array) {
|
||||
int prime = 31;
|
||||
if (array == null)
|
||||
return 0;
|
||||
int result = 1;
|
||||
for (String element : array) {
|
||||
result = prime * result + (element == null ? 0 : element.hashCode());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private final String[] fqn;
|
||||
private final int elementType;
|
||||
private final String[] params;
|
||||
|
@ -74,13 +63,11 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
|
|||
elementType = IndexModelUtil.getElementType(binding);
|
||||
if (binding instanceof ICPPBinding) {
|
||||
fqn= ((ICPPBinding)binding).getQualifiedName();
|
||||
}
|
||||
else if (binding instanceof IField) {
|
||||
} else if (binding instanceof IField) {
|
||||
IField field= (IField) binding;
|
||||
ICompositeType owner= field.getCompositeTypeOwner();
|
||||
fqn= new String[] {owner.getName(), field.getName()};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fqn= new String[] {binding.getName()};
|
||||
}
|
||||
if (binding instanceof IFunction) {
|
||||
|
@ -107,6 +94,17 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
|
|||
this.reference= reference;
|
||||
}
|
||||
|
||||
private static int hashCode(String[] array) {
|
||||
int prime = 31;
|
||||
if (array == null)
|
||||
return 0;
|
||||
int result = 1;
|
||||
for (String element : array) {
|
||||
result = prime * result + (element == null ? 0 : element.hashCode());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCElementType() {
|
||||
return elementType;
|
||||
|
@ -148,9 +146,6 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
|
|||
return params;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getReturnType()
|
||||
*/
|
||||
@Override
|
||||
public String getReturnType() {
|
||||
return returnType;
|
||||
|
|
Loading…
Add table
Reference in a new issue