1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-09-30 14:07:01 -07:00
parent 830c09b3be
commit 1e598a2202
3 changed files with 52 additions and 57 deletions

View file

@ -9,7 +9,6 @@
* Andrew Gvozdev - Initial API and implementation * Andrew Gvozdev - Initial API and implementation
* James Blackburn (Broadcom Corp.) * James Blackburn (Broadcom Corp.)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.testplugin; package org.eclipse.cdt.core.testplugin;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -27,8 +26,6 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import junit.framework.Assert;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; 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.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.junit.Assert;
/** /**
* This class contains utility methods for creating resources * This class contains utility methods for creating resources
@ -66,7 +64,6 @@ import org.eclipse.core.runtime.jobs.Job;
* *
* @since 6.0 * @since 6.0
*/ */
public class ResourceHelper { public class ResourceHelper {
private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor(); private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
private static final int MAX_RETRY= 5; 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 * @param projectName
* @return the project handle * @return the project handle
@ -202,10 +199,11 @@ public class ResourceHelper {
public static IProject createProject(String projectName) throws CoreException { public static IProject createProject(String projectName) throws CoreException {
IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
IProject project= root.getProject(projectName); IProject project= root.getProject(projectName);
if (!project.exists()) if (!project.exists()) {
project.create(NULL_MONITOR); project.create(NULL_MONITOR);
else } else {
project.refreshLocal(IResource.DEPTH_INFINITE, null); project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
if (!project.isOpen()) if (!project.isOpen())
project.open(NULL_MONITOR); project.open(NULL_MONITOR);
@ -215,7 +213,7 @@ public class ResourceHelper {
} }
/** /**
* Delete project by name. * Deletes project by name.
* *
* @param projectName * @param projectName
* @throws CoreException * @throws CoreException
@ -228,7 +226,7 @@ public class ResourceHelper {
} }
/** /**
* Delete given project with content. * Deletes given project with content.
* *
* @param project * @param project
* @throws CoreException * @throws CoreException
@ -238,7 +236,7 @@ public class ResourceHelper {
} }
/** /**
* Delete project. * Deletes project.
* *
* @param project * @param project
* @param deleteContent whether to delete project content * @param deleteContent whether to delete project content
@ -542,7 +540,6 @@ public class ResourceHelper {
*/ */
public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath) public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath)
throws IOException, CoreException, UnsupportedOperationException { throws IOException, CoreException, UnsupportedOperationException {
if (!isSymbolicLinkSupported()) { if (!isSymbolicLinkSupported()) {
throw new UnsupportedOperationException("Windows links .lnk are not supported."); throw new UnsupportedOperationException("Windows links .lnk are not supported.");
} }
@ -589,13 +586,13 @@ public class ResourceHelper {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
try { try {
Assert.assertTrue("ln process exited with non-zero status", process.waitFor() == 0); 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; break;
} catch (InterruptedException e) { } catch (InterruptedException e) {
// Clear interrupted state, see Java bug http://bugs.sun.com/view_bug.do?bug_id=6420270 // Clear interrupted state, see Java bug http://bugs.sun.com/view_bug.do?bug_id=6420270
Thread.interrupted(); 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*/} try { Thread.sleep(500); } catch (InterruptedException e) {/*don't care*/}
} }
Assert.assertTrue("Symbolic link not created, command=[" + command + "]", linkPath.toFile().exists()); 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) public static IResource createSymbolicLink(IProject project, String linkName, String realPath)
throws IOException, CoreException, UnsupportedOperationException { throws IOException, CoreException, UnsupportedOperationException {
return createSymbolicLink(project, linkName, new Path(realPath)); return createSymbolicLink(project, linkName, new Path(realPath));
} }
@ -701,13 +697,14 @@ public class ResourceHelper {
// Remove IResources created by this helper // Remove IResources created by this helper
for (IResource r : resourcesCreated) { for (IResource r : resourcesCreated) {
if (r.exists()) if (r.exists()) {
try { try {
r.delete(true, NULL_MONITOR); r.delete(true, NULL_MONITOR);
} catch (CoreException e) { } catch (CoreException e) {
// Ignore // Ignore
} }
} }
}
resourcesCreated.clear(); resourcesCreated.clear();
} }
@ -733,12 +730,15 @@ public class ResourceHelper {
// Ensure that the file being deleted is a child of the workspace // Ensure that the file being deleted is a child of the workspace
// root to prevent anything nasty happening // root to prevent anything nasty happening
if (!f.getAbsolutePath().startsWith( 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!"); throw new IllegalArgumentException("File must exist within the workspace!");
}
if (f.isDirectory()) if (f.isDirectory()) {
for (File f1 : f.listFiles()) for (File f1 : f.listFiles()) {
deleteRecursive(f1); deleteRecursive(f1);
}
}
f.delete(); f.delete();
} }
} }

View file

@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.browser; package org.eclipse.cdt.internal.core.browser;
import java.util.Arrays;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.browser.IFunctionInfo; import org.eclipse.cdt.core.browser.IFunctionInfo;
import org.eclipse.cdt.core.browser.IQualifiedTypeName; 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.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import java.util.Arrays;
/** /**
* Type info object needed to support search for local variables. * Type info object needed to support search for local variables.
* @since 5.0 * @since 5.0
*/ */
public class ASTTypeInfo implements ITypeInfo, IFunctionInfo { 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 String[] fqn;
private final int elementType; private final int elementType;
private final String[] params; private final String[] params;
@ -74,13 +63,11 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
elementType = IndexModelUtil.getElementType(binding); elementType = IndexModelUtil.getElementType(binding);
if (binding instanceof ICPPBinding) { if (binding instanceof ICPPBinding) {
fqn= ((ICPPBinding)binding).getQualifiedName(); fqn= ((ICPPBinding)binding).getQualifiedName();
} } else if (binding instanceof IField) {
else if (binding instanceof IField) {
IField field= (IField) binding; IField field= (IField) binding;
ICompositeType owner= field.getCompositeTypeOwner(); ICompositeType owner= field.getCompositeTypeOwner();
fqn= new String[] {owner.getName(), field.getName()}; fqn= new String[] {owner.getName(), field.getName()};
} } else {
else {
fqn= new String[] {binding.getName()}; fqn= new String[] {binding.getName()};
} }
if (binding instanceof IFunction) { if (binding instanceof IFunction) {
@ -107,6 +94,17 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
this.reference= reference; 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 @Override
public int getCElementType() { public int getCElementType() {
return elementType; return elementType;
@ -148,9 +146,6 @@ public class ASTTypeInfo implements ITypeInfo, IFunctionInfo {
return params; return params;
} }
/*
* @see org.eclipse.cdt.internal.core.browser.IFunctionInfo#getReturnType()
*/
@Override @Override
public String getReturnType() { public String getReturnType() {
return returnType; return returnType;