mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
autotools: Modernize o.e.cdt.autotools.tests bundle. (take 2)
* Bump BREE to Java 1.8. * Start using lambdas. * Removed unused helper methods/activator/etc. * More JUnit 4 migration. * Enable more warnings by default and fix them. Change-Id: If2df6114fb18b66822849ce2e1b956dd0ce6b514 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
46db6d71cf
commit
41d04dd376
20 changed files with 268 additions and 658 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -7,9 +7,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
|||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
|
@ -22,9 +22,9 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
|||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
|
@ -35,7 +35,7 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
|||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
|
@ -62,8 +62,8 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
|||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
|
@ -81,21 +81,21 @@ org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
|||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %bundleName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.autotools.tests;singleton:=true
|
||||
Bundle-Version: 2.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.autotools.tests.AutotoolsTestsPlugin
|
||||
Bundle-Vendor: %provider
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
|
@ -23,7 +22,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.cdt.autotools.ui;bundle-version="1.0.0",
|
||||
org.eclipse.cdt.core.tests
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: org.eclipse.cdt.autotools.tests,
|
||||
org.eclipse.cdt.autotools.tests.autoconf,
|
||||
org.eclipse.cdt.autotools.tests.editors
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.CoreModel;
|
|||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.junit.After;
|
||||
|
@ -36,7 +37,7 @@ public class AutotoolsEnvironmentVarTest {
|
|||
private IProject testProject;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() throws CoreException {
|
||||
if (!ProjectTools.setup())
|
||||
fail("could not perform basic project workspace setup");
|
||||
testProject = ProjectTools.createProject("testProject0");
|
||||
|
@ -57,7 +58,7 @@ public class AutotoolsEnvironmentVarTest {
|
|||
public void testAutotoolsEnvironmentVar() throws Exception {
|
||||
|
||||
Path p = new Path("zip/project1.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, null, p, null, true);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, null, p, true);
|
||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject)
|
||||
.getActiveConfiguration();
|
||||
|
|
|
@ -15,12 +15,13 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AutotoolsProjectNatureTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() throws CoreException {
|
||||
if (!ProjectTools.setup())
|
||||
fail("could not perform basic project workspace setup");
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AutotoolsProjectTest0 {
|
|||
@Test
|
||||
public void testAutotoolsProject0() throws Exception {
|
||||
Path p = new Path("zip/project1.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, null, p, null, true);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, null, p, true);
|
||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("ChangeLog");
|
||||
assertTrue(testProject.exists(x));
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AutotoolsProjectTest1 {
|
|||
@Test
|
||||
public void testAutotoolsProject1() throws Exception {
|
||||
Path p = new Path("zip/project1.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p, null, true);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p, true);
|
||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog");
|
||||
assertTrue(testProject.exists(x));
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AutotoolsProjectTest2 {
|
|||
@Test
|
||||
public void testAutotoolsProject2() throws Exception {
|
||||
Path p = new Path("zip/project2.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p);
|
||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog");
|
||||
assertTrue(testProject.exists(x));
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
package org.eclipse.cdt.autotools.tests;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class AutotoolsTestsPlugin extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.autotools.tests";
|
||||
|
||||
// The shared instance
|
||||
private static AutotoolsTestsPlugin plugin;
|
||||
private ResourceBundle resourceBundle;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public AutotoolsTestsPlugin() {
|
||||
try {
|
||||
resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.autotools.tests.Resources");
|
||||
} catch (MissingResourceException x) {
|
||||
resourceBundle = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static AutotoolsTestsPlugin getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given
|
||||
* plug-in relative path
|
||||
*
|
||||
* @param path the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return imageDescriptorFromPlugin(PLUGIN_ID, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns active shell.
|
||||
*/
|
||||
public static Shell getActiveWorkbenchShell() {
|
||||
IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
|
||||
if (window != null) {
|
||||
return window.getShell();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string from the plugin's resource bundle,
|
||||
* or 'key' if not found.
|
||||
*/
|
||||
public static String getResourceString(String key) {
|
||||
ResourceBundle bundle = AutotoolsTestsPlugin.getDefault().getResourceBundle();
|
||||
try {
|
||||
return (bundle != null) ? bundle.getString(key) : key;
|
||||
} catch (MissingResourceException e) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin's resource bundle,
|
||||
*/
|
||||
public ResourceBundle getResourceBundle() {
|
||||
return resourceBundle;
|
||||
}
|
||||
}
|
|
@ -61,7 +61,7 @@ public class AutotoolsVirtualFolderTest {
|
|||
configDir.deleteOnExit();
|
||||
assertTrue(configDir.mkdir());
|
||||
ProjectTools.createLinkedFolder(testProject, "src", URIUtil.append(root.getLocationURI(), "config"));
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p);
|
||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||
assertTrue(exists("src/ChangeLog"));
|
||||
ProjectTools.setConfigDir(testProject, "src");
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.tests;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
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
|
||||
* (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);
|
||||
}
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
// 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) {
|
||||
return element.createExecutableExtension(classAttribute);
|
||||
}
|
||||
final Object[] ret = new Object[1];
|
||||
final CoreException[] exc = new CoreException[1];
|
||||
BusyIndicator.showWhile(null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ret[0] = element.createExecutableExtension(classAttribute);
|
||||
} catch (CoreException e) {
|
||||
exc[0] = e;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (exc[0] != null)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -39,13 +39,14 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
|
||||
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
|
||||
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
@ -61,9 +62,9 @@ public class ProjectTools {
|
|||
/**
|
||||
* Setup routine for tests.
|
||||
* @return true if setup successful, false otherwise
|
||||
* @throws Exception
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static boolean setup() throws Exception {
|
||||
public static boolean setup() throws CoreException {
|
||||
if (!setupComplete) {
|
||||
IWorkspaceDescription desc;
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
@ -151,8 +152,8 @@ public class ProjectTools {
|
|||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(
|
||||
monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
||||
if (launcher.waitAndRead(stdout, stderr,
|
||||
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
|
@ -185,8 +186,7 @@ public class ProjectTools {
|
|||
@Override
|
||||
public IConfiguration[] getSelectedConfigurations() {
|
||||
IProjectType projectType = ManagedBuildManager.getExtensionProjectType("org.eclipse.linuxtools.cdt.autotools.core.projectType"); //$NON-NLS-1$
|
||||
IConfiguration[] cfgs = projectType.getConfigurations();
|
||||
return cfgs;
|
||||
return projectType.getConfigurations();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,10 +204,7 @@ public class ProjectTools {
|
|||
try {
|
||||
testProject.create(monitor);
|
||||
testProject.open(monitor);
|
||||
// IProjectDescription description = workspace.newProjectDescription(name);
|
||||
// if(location != null)
|
||||
// description.setLocationURI(location);
|
||||
IProject newProject = CCorePlugin.getDefault().createCDTProject(description, testProject, new SubProgressMonitor(monitor,25));
|
||||
IProject newProject = CCorePlugin.getDefault().createCDTProject(description, testProject, SubMonitor.convert(monitor,25));
|
||||
ConvertToAutotoolsProjectWizardTest wizard = new ConvertToAutotoolsProjectWizardTest();
|
||||
wizard.addPages();
|
||||
ConvertToAutotoolsProjectWizardPage page = new ConvertToAutotoolsProjectWizardPage("test", wizard);
|
||||
|
@ -230,22 +227,6 @@ public class ProjectTools {
|
|||
String id = cfgd.getId();
|
||||
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, id, true);
|
||||
cfg.setConfigToolDirectory(dir);
|
||||
// IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||
// ITool tool = info.getToolFromOutputExtension("status"); //$NON-NLS-1$
|
||||
// IOption[] options = tool.getOptions();
|
||||
// try {
|
||||
// for (int i = 0; i < options.length; ++i) {
|
||||
// if (options[i].getValueType() == IOption.STRING) {
|
||||
// String id = options[i].getId();
|
||||
// if (id.indexOf("configdir") > 0) { //$NON-NLS-1$
|
||||
// options[i].setValue(dir);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (BuildException e) {
|
||||
// // do nothing
|
||||
// }
|
||||
}
|
||||
|
||||
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
|
||||
|
@ -282,7 +263,7 @@ public class ProjectTools {
|
|||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(
|
||||
if (launcher.waitAndRead(stdout, stderr, SubMonitor.convert(
|
||||
monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
||||
return false;
|
||||
}
|
||||
|
@ -302,6 +283,7 @@ public class ProjectTools {
|
|||
}
|
||||
|
||||
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
||||
@Override
|
||||
public String queryOverwrite(String file) {
|
||||
return ALL;
|
||||
}
|
||||
|
@ -313,33 +295,8 @@ public class ProjectTools {
|
|||
* @param containerName The name of the new source container
|
||||
* @return The handle to the new source container
|
||||
* @throws CoreException Creation failed
|
||||
*/
|
||||
public static IContainer addSourceContainer(IProject jproject, String containerName) throws CoreException {
|
||||
return addSourceContainer(jproject, containerName, new Path[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a source container to a IProject.
|
||||
* @param jproject The parent project
|
||||
* @param containerName The name of the new source container
|
||||
* @param exclusionFilters Exclusion filters to set
|
||||
* @return The handle to the new source container
|
||||
* @throws CoreException Creation failed
|
||||
*/
|
||||
public static IContainer addSourceContainer(IProject jproject, String containerName, IPath[] exclusionFilters) throws CoreException {
|
||||
return addSourceContainer(jproject, containerName, new Path[0], exclusionFilters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a source container to a IProject.
|
||||
* @param jproject The parent project
|
||||
* @param containerName The name of the new source container
|
||||
* @param inclusionFilters Inclusion filters to set
|
||||
* @param exclusionFilters Exclusion filters to set
|
||||
* @return The handle to the new source container
|
||||
* @throws CoreException Creation failed
|
||||
*/
|
||||
public static IContainer addSourceContainer(IProject jproject, String containerName, IPath[] inclusionFilters, IPath[] exclusionFilters) throws CoreException {
|
||||
public static IContainer addSourceContainer(IProject jproject, String containerName) throws CoreException {
|
||||
IProject project= jproject.getProject();
|
||||
IContainer container= null;
|
||||
if (containerName == null || containerName.length() == 0) {
|
||||
|
@ -347,7 +304,7 @@ public class ProjectTools {
|
|||
} else {
|
||||
IFolder folder= project.getFolder(containerName);
|
||||
if (!folder.exists()) {
|
||||
CoreUtility.createFolder(folder, false, true, null);
|
||||
createFolder(folder, false, true, null);
|
||||
}
|
||||
container= folder;
|
||||
}
|
||||
|
@ -361,7 +318,6 @@ public class ProjectTools {
|
|||
* @param project The parent project
|
||||
* @param containerName Name of the source container
|
||||
* @param zipFile Archive to import
|
||||
* @param containerEncoding encoding for the generated source container
|
||||
* @param generate true if configuration files need to be pre-generated
|
||||
* @param exclusionFilters Exclusion filters to set
|
||||
* @return The handle to the new source container
|
||||
|
@ -369,21 +325,14 @@ public class ProjectTools {
|
|||
* @throws CoreException Creation failed
|
||||
* @throws IOException Creation failed
|
||||
*/
|
||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, File zipFile, String containerEncoding, boolean generate, IPath[] exclusionFilters) throws InvocationTargetException, CoreException, IOException {
|
||||
ZipFile file= new ZipFile(zipFile);
|
||||
try {
|
||||
// IPackageFragmentRoot root= addSourceContainer(jproject, containerName, exclusionFilters);
|
||||
// ((IContainer) root.getCorrespondingResource()).setDefaultCharset(containerEncoding, null);
|
||||
IContainer root= addSourceContainer(project, containerName, exclusionFilters);
|
||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, File zipFile, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
||||
try (ZipFile file= new ZipFile(zipFile)){
|
||||
IContainer root= addSourceContainer(project, containerName);
|
||||
if (generate)
|
||||
importFilesFromZipAndGenerate(file, root.getFullPath(), null);
|
||||
else
|
||||
importFilesFromZip(file, root.getFullPath(), null);
|
||||
return root;
|
||||
} finally {
|
||||
if (file != null) {
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,16 +342,15 @@ public class ProjectTools {
|
|||
* @param project The parent project
|
||||
* @param containerName Name of the source container
|
||||
* @param path path of zipFile Archive to import
|
||||
* @param containerEncoding encoding for the generated source container
|
||||
* @param generate true if configuration files need to be pre-generated
|
||||
* @return The handle to the new source container
|
||||
* @throws InvocationTargetException Creation failed
|
||||
* @throws CoreException Creation failed
|
||||
* @throws IOException Creation failed
|
||||
*/
|
||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath, String containerEncoding, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
||||
File zipFile = new File(FileLocator.toFileURL(FileLocator.find(AutotoolsTestsPlugin.getDefault().getBundle(), zipFilePath, null)).getFile());
|
||||
return addSourceContainerWithImport(project, containerName, zipFile, containerEncoding, generate, null);
|
||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
||||
File zipFile = new File(FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(ProjectTools.class), zipFilePath, null)).getFile());
|
||||
return addSourceContainerWithImport(project, containerName, zipFile, generate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -411,27 +359,13 @@ public class ProjectTools {
|
|||
* @param project The parent project
|
||||
* @param containerName Name of the source container
|
||||
* @param path path of zipFile Archive to import
|
||||
* @param containerEncoding encoding for the generated source container
|
||||
* @return The handle to the new source container
|
||||
* @throws InvocationTargetException Creation failed
|
||||
* @throws CoreException Creation failed
|
||||
* @throws IOException Creation failed
|
||||
*/
|
||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath, String containerEncoding) throws InvocationTargetException, CoreException, IOException {
|
||||
return addSourceContainerWithImport(project, containerName, zipFilePath, containerEncoding, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an empty file for a project.
|
||||
* @param project The project to create the file for
|
||||
* @param filename The name of the new file
|
||||
* @return the created file
|
||||
* @throws CoreException
|
||||
*/
|
||||
public IFile createEmptyFile(IProject project, String filename) throws CoreException {
|
||||
IFile emptyFile = project.getFile(filename);
|
||||
emptyFile.create(null, false, null);
|
||||
return emptyFile;
|
||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath) throws InvocationTargetException, CoreException, IOException {
|
||||
return addSourceContainerWithImport(project, containerName, zipFilePath, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,53 +383,6 @@ public class ProjectTools {
|
|||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a virtual folder for a project
|
||||
* @param project The project
|
||||
* @param path Folder path
|
||||
* @return the virtual folder
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static IContainer createVirtualFolder(IProject project, IPath path) throws CoreException {
|
||||
int segmentCount = path.segmentCount();
|
||||
IContainer currentFolder = project;
|
||||
|
||||
for (int i = 0; i < segmentCount; i++) {
|
||||
currentFolder = currentFolder.getFolder(new Path(path.segment(i)));
|
||||
if (!currentFolder.exists()) {
|
||||
((IFolder) currentFolder).create(IResource.VIRTUAL
|
||||
| IResource.DERIVED, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
return currentFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a linked resource for a project
|
||||
* @param project The project
|
||||
* @param folderName Name of the linked folder in the project
|
||||
* @param path The URI of the real file/folder
|
||||
*
|
||||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static IContainer createLinkedFolder(IProject project, IPath projectPath, IPath realPath) throws CoreException {
|
||||
int segmentCount = projectPath.segmentCount() - 1;
|
||||
IContainer currentFolder = project;
|
||||
|
||||
for (int i = 0; i < segmentCount; i++) {
|
||||
currentFolder = currentFolder.getFolder(new Path(projectPath.segment(i)));
|
||||
if (!currentFolder.exists()) {
|
||||
((IFolder) currentFolder).create(IResource.DERIVED | IResource.VIRTUAL, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
IFolder folder = currentFolder.getFolder(new Path(projectPath.lastSegment()));
|
||||
if (!folder.isLinked()) {
|
||||
((IFolder)folder).createLink(realPath, 0, null);
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a linked folder for a project
|
||||
* @param project The project
|
||||
|
@ -509,17 +396,14 @@ public class ProjectTools {
|
|||
final IFolder folderHandle = root.getFolder(project.getFullPath().append(folderName));
|
||||
|
||||
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
|
||||
@Override
|
||||
public void execute(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
monitor
|
||||
.beginTask(
|
||||
IDEWorkbenchMessages.NewFolderDialog_progress,
|
||||
2000);
|
||||
monitor.beginTask(IDEWorkbenchMessages.NewFolderDialog_progress, 2000);
|
||||
if (monitor.isCanceled()) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
folderHandle.createLink(linkTarget,
|
||||
IResource.ALLOW_MISSING_LOCAL, monitor);
|
||||
folderHandle.createLink(linkTarget, IResource.ALLOW_MISSING_LOCAL, monitor);
|
||||
if (monitor.isCanceled()) {
|
||||
throw new OperationCanceledException();
|
||||
}
|
||||
|
@ -529,15 +413,27 @@ public class ProjectTools {
|
|||
}
|
||||
};
|
||||
try {
|
||||
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
|
||||
operation);
|
||||
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation);
|
||||
} catch (InterruptedException exception) {
|
||||
return null;
|
||||
} catch (InvocationTargetException exception) {
|
||||
throw exception;
|
||||
}
|
||||
return folderHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a folder and all parent folders if not existing.
|
||||
* Project must exist.
|
||||
* <code> org.eclipse.ui.dialogs.ContainerGenerator</code> 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);
|
||||
}
|
||||
folder.create(force, local, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
ProjectTools.ErrorDialog.Title="Project Creation Error"
|
||||
ProjectTools.Exist.Error="Project already exists"
|
|
@ -72,7 +72,7 @@ public class UpdateConfigureTest {
|
|||
@Test
|
||||
public void testGprofGcovDebugFlagOptions() throws Exception {
|
||||
Path p = new Path("zip/project2.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p);
|
||||
assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
ProjectTools.setConfigDir(testProject, "src");
|
||||
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
||||
|
@ -98,16 +98,12 @@ public class UpdateConfigureTest {
|
|||
|
||||
File f = r.getLocation().toFile();
|
||||
|
||||
FileReader fr = new FileReader(f);
|
||||
|
||||
char[] cbuf = new char[2000];
|
||||
fr.read(cbuf);
|
||||
|
||||
String s = new String(cbuf);
|
||||
|
||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-pg CXXFLAGS=-pg"));
|
||||
|
||||
fr.close();
|
||||
try (FileReader fr = new FileReader(f)) {
|
||||
fr.read(cbuf);
|
||||
String s = new String(cbuf);
|
||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-pg CXXFLAGS=-pg"));
|
||||
}
|
||||
|
||||
// Reset gprof opt and set gcov opt
|
||||
opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
|
||||
|
@ -125,14 +121,13 @@ public class UpdateConfigureTest {
|
|||
|
||||
r = testProject.findMember(x);
|
||||
f = r.getLocation().toFile();
|
||||
fr = new FileReader(f);
|
||||
fr.read(cbuf);
|
||||
|
||||
s = new String(cbuf);
|
||||
|
||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-fprofile-arcs -ftest-coverage CXXFLAGS=-fprofile-arcs -ftest-coverage"));
|
||||
try (FileReader fr = new FileReader(f)) {
|
||||
fr.read(cbuf);
|
||||
String s = new String(cbuf);
|
||||
assertTrue(s.contains(
|
||||
"testProject2/src/configure CFLAGS=-fprofile-arcs -ftest-coverage CXXFLAGS=-fprofile-arcs -ftest-coverage"));
|
||||
|
||||
fr.close();
|
||||
}
|
||||
|
||||
// Reset gcov opt and set debug opt
|
||||
opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
|
||||
|
@ -150,14 +145,11 @@ public class UpdateConfigureTest {
|
|||
|
||||
r = testProject.findMember(x);
|
||||
f = r.getLocation().toFile();
|
||||
fr = new FileReader(f);
|
||||
fr.read(cbuf);
|
||||
|
||||
s = new String(cbuf);
|
||||
|
||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-g CXXFLAGS=-g"));
|
||||
|
||||
fr.close();
|
||||
try (FileReader fr = new FileReader(f)) {
|
||||
fr.read(cbuf);
|
||||
String s = new String(cbuf);
|
||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-g CXXFLAGS=-g"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +160,7 @@ public class UpdateConfigureTest {
|
|||
@Test
|
||||
public void testGetAndUpdateConfigureOptions() throws Exception {
|
||||
Path p = new Path("zip/project2.zip");
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
|
||||
ProjectTools.addSourceContainerWithImport(testProject, "src", p);
|
||||
assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||
ProjectTools.setConfigDir(testProject, "src");
|
||||
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
||||
|
@ -557,14 +549,7 @@ public class UpdateConfigureTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
} catch (IOException|ParserConfigurationException|SAXException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,13 +11,12 @@
|
|||
package org.eclipse.cdt.autotools.tests.autoconf;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -40,35 +39,22 @@ public abstract class BaseParserTest {
|
|||
private Set<String> macroNames;
|
||||
private AutoconfMacroDetector macroDetector;
|
||||
|
||||
public BaseParserTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
errors = new ArrayList<>();
|
||||
this.errorHandler = new IAutoconfErrorHandler() {
|
||||
@Override
|
||||
public void handleError(ParseException exception) {
|
||||
assertNotNull(exception);
|
||||
errors.add(exception);
|
||||
}
|
||||
|
||||
this.errorHandler = (ParseException exception) -> {
|
||||
assertNotNull(exception);
|
||||
errors.add(exception);
|
||||
};
|
||||
|
||||
this.macroDetector = new AutoconfMacroDetector();
|
||||
|
||||
macroNames = new HashSet<>();
|
||||
this.macroValidator = new IAutoconfMacroValidator() {
|
||||
@Override
|
||||
public void validateMacroCall(AutoconfMacroElement element)
|
||||
throws ParseException {
|
||||
assertNotNull(element);
|
||||
assertNotNull(element.getName());
|
||||
assertNotNull(element.getChildren());
|
||||
macroNames.add(element.getName());
|
||||
}
|
||||
|
||||
this.macroValidator = (AutoconfMacroElement element) -> {
|
||||
assertNotNull(element);
|
||||
assertNotNull(element.getName());
|
||||
assertNotNull(element.getChildren());
|
||||
macroNames.add(element.getName());
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -134,23 +120,22 @@ public abstract class BaseParserTest {
|
|||
assertEquals(string, document.get());
|
||||
|
||||
if (!allowErrors) {
|
||||
if (errors.size() > 0)
|
||||
if (!errors.isEmpty())
|
||||
fail("got errors" + errors.get(0));
|
||||
}
|
||||
else
|
||||
assertTrue(errors.size() > 0);
|
||||
assertFalse(errors.isEmpty());
|
||||
|
||||
return root2;
|
||||
}
|
||||
|
||||
protected void checkError(String msgKey) {
|
||||
for (Iterator<ParseException> iter = errors.iterator(); iter.hasNext(); ) {
|
||||
ParseException exc = iter.next();
|
||||
for (ParseException exc: errors) {
|
||||
if (exc.getMessage().contains(msgKey))
|
||||
return;
|
||||
}
|
||||
String any = "";
|
||||
if (errors.size() > 0)
|
||||
if (!errors.isEmpty())
|
||||
any = ", but saw " + errors.get(0).toString();
|
||||
fail("did not find error: " + msgKey + any );
|
||||
}
|
||||
|
@ -158,8 +143,7 @@ public abstract class BaseParserTest {
|
|||
protected void checkError(String msgKey, int line) {
|
||||
ParseException possible = null;
|
||||
int distance = 999;
|
||||
for (Iterator<ParseException> iter = errors.iterator(); iter.hasNext(); ) {
|
||||
ParseException exc = iter.next();
|
||||
for (ParseException exc : errors) {
|
||||
if (exc.getMessage().contains(msgKey)) {
|
||||
int curDistance = Math.abs(exc.getLineNumber() - line);
|
||||
if (curDistance < distance) {
|
||||
|
|
|
@ -31,12 +31,12 @@ import org.junit.Test;
|
|||
public class TestMacroParser extends BaseParserTest {
|
||||
|
||||
@Test
|
||||
public void testEmpty() throws Exception {
|
||||
public void testEmpty() {
|
||||
parse("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComments() throws Exception {
|
||||
public void testComments() {
|
||||
//
|
||||
String text =
|
||||
"dnl first line\n" +
|
||||
|
@ -49,7 +49,7 @@ public class TestMacroParser extends BaseParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMacroParsing1() throws Exception {
|
||||
public void testMacroParsing1() {
|
||||
//
|
||||
String text =
|
||||
"AC_REQUIRE([AM_SANITY_CHECK])\n" +
|
||||
|
@ -77,7 +77,7 @@ public class TestMacroParser extends BaseParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMacroParsing2() throws Exception {
|
||||
public void testMacroParsing2() {
|
||||
//
|
||||
String text =
|
||||
"AC_TWO_ARGS(first,second)\n" +
|
||||
|
@ -107,7 +107,7 @@ public class TestMacroParser extends BaseParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMacroParsing3() throws Exception {
|
||||
public void testMacroParsing3() {
|
||||
//
|
||||
String text =
|
||||
"AC_ONE_ARG( [quoted( arg ), second] )\n" +
|
||||
|
@ -135,7 +135,7 @@ public class TestMacroParser extends BaseParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMacroParsing4() throws Exception {
|
||||
public void testMacroParsing4() {
|
||||
//
|
||||
String text =
|
||||
"AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],\r\n" +
|
||||
|
@ -160,7 +160,7 @@ public class TestMacroParser extends BaseParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMacroParsing5() throws Exception {
|
||||
public void testMacroParsing5() {
|
||||
// check that complex shell constructs don't throw off the
|
||||
// parser, and also that we don't mistake shell tokens in a macro argument
|
||||
String arg2 =
|
||||
|
@ -205,7 +205,7 @@ public class TestMacroParser extends BaseParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMacroParsing6() throws Exception {
|
||||
public void testMacroParsing6() {
|
||||
// empty arguments
|
||||
String text =
|
||||
"AC_DEFUN( ,\n" +
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfTokenizer;
|
||||
import org.eclipse.cdt.autotools.ui.editors.parser.IAutoconfErrorHandler;
|
||||
import org.eclipse.cdt.autotools.ui.editors.parser.ITokenConstants;
|
||||
import org.eclipse.cdt.autotools.ui.editors.parser.ParseException;
|
||||
import org.eclipse.cdt.autotools.ui.editors.parser.Token;
|
||||
|
@ -43,23 +42,14 @@ public class TestTokenizer {
|
|||
return new Document(text);
|
||||
}
|
||||
|
||||
protected List<Token> tokenize(IDocument document) {
|
||||
return tokenize(document, false);
|
||||
}
|
||||
|
||||
protected List<Token> tokenize(IDocument document, boolean isM4Mode) {
|
||||
tokenizerErrors = new ArrayList<>();
|
||||
AutoconfTokenizer tokenizer = new AutoconfTokenizer(document, new IAutoconfErrorHandler() {
|
||||
@Override
|
||||
public void handleError(ParseException exception) {
|
||||
tokenizerErrors.add(exception);
|
||||
}
|
||||
|
||||
AutoconfTokenizer tokenizer = new AutoconfTokenizer(document, (ParseException exception) -> {
|
||||
tokenizerErrors.add(exception);
|
||||
});
|
||||
tokenizer.setM4Context(isM4Mode);
|
||||
|
||||
List<Token> tokens = tokenize(tokenizer);
|
||||
return tokens;
|
||||
return tokenize(tokenizer);
|
||||
}
|
||||
|
||||
protected List<Token> tokenize(AutoconfTokenizer tokenizer) {
|
||||
|
@ -444,12 +434,8 @@ public class TestTokenizer {
|
|||
}
|
||||
|
||||
private AutoconfTokenizer createTokenizer(IDocument document) {
|
||||
return new AutoconfTokenizer(document, new IAutoconfErrorHandler() {
|
||||
@Override
|
||||
public void handleError(ParseException exception) {
|
||||
fail(exception.toString());
|
||||
}
|
||||
|
||||
return new AutoconfTokenizer(document, (ParseException exception) -> {
|
||||
fail(exception.toString());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.eclipse.cdt.autotools.tests.AutotoolsTestsPlugin;
|
||||
import org.eclipse.cdt.autotools.tests.ProjectTools;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeDocumentProvider;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
||||
|
@ -33,6 +32,7 @@ import org.eclipse.jface.text.rules.Token;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -40,7 +40,7 @@ import org.junit.Test;
|
|||
|
||||
public class AutomakeColourizationTests {
|
||||
|
||||
ProjectTools tools;
|
||||
private ProjectTools tools;
|
||||
private IProject project;
|
||||
private IFile makefileAmFile;
|
||||
|
||||
|
@ -70,32 +70,27 @@ public class AutomakeColourizationTests {
|
|||
|
||||
project.open(new NullProgressMonitor());
|
||||
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
Display.getDefault().syncExec(() -> {
|
||||
try {
|
||||
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
||||
workbench = PlatformUI.getWorkbench();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
||||
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
|
||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE
|
||||
.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), makefileAmFile, true);
|
||||
|
||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
|
||||
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
|
||||
true);
|
||||
AutomakeEditor automakeEditor = (AutomakeEditor) openEditor;
|
||||
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
||||
IDocument automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
||||
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor
|
||||
.getAutomakeSourceViewerConfiguration();
|
||||
|
||||
AutomakeEditor automakeEditor = (AutomakeEditor) openEditor;
|
||||
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
||||
IDocument automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
||||
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
|
||||
|
||||
ITypedRegion region = automakeDocument.getPartition(0);
|
||||
codeScanner = automakeSourceViewerConfig.getAutomakeCodeScanner();
|
||||
codeScanner.setRange(automakeDocument, region.getOffset(), region.getLength());
|
||||
} catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
ITypedRegion region = automakeDocument.getPartition(0);
|
||||
codeScanner = automakeSourceViewerConfig.getAutomakeCodeScanner();
|
||||
codeScanner.setRange(automakeDocument, region.getOffset(), region.getLength());
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -103,7 +98,7 @@ public class AutomakeColourizationTests {
|
|||
return codeScanner.nextToken();
|
||||
}
|
||||
@Test
|
||||
public void testAutomakeEditorColourization() throws Exception {
|
||||
public void testAutomakeEditorColourization() {
|
||||
// # This is a comment
|
||||
IToken token0 = getNextToken();
|
||||
assertTrue(token0 instanceof Token);
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.tests.editors;
|
||||
|
||||
import org.eclipse.cdt.autotools.tests.AutotoolsTestsPlugin;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.eclipse.cdt.autotools.tests.ProjectTools;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -19,22 +21,24 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class AutomakeEditorTests extends TestCase {
|
||||
public class AutomakeEditorTests {
|
||||
|
||||
ProjectTools tools;
|
||||
private ProjectTools tools;
|
||||
private IProject project;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tools = new ProjectTools();
|
||||
if (!ProjectTools.setup())
|
||||
fail("could not perform basic project workspace setup");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutomakeEditorAssociation() throws Exception {
|
||||
project = ProjectTools.createProject("testProjectAET");
|
||||
|
||||
|
@ -44,24 +48,19 @@ public class AutomakeEditorTests extends TestCase {
|
|||
|
||||
project.open(new NullProgressMonitor());
|
||||
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
Display.getDefault().syncExec(() -> {
|
||||
try {
|
||||
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
|
||||
assertTrue(makefileAmFile.exists());
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
|
||||
assertTrue(makefileAmFile.exists());
|
||||
IWorkbench workbench = PlatformUI.getWorkbench();
|
||||
|
||||
IWorkbench workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
|
||||
|
||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
|
||||
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
|
||||
true);
|
||||
assertTrue(openEditor instanceof AutomakeEditor);
|
||||
} catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE
|
||||
.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), makefileAmFile, true);
|
||||
assertTrue(openEditor instanceof AutomakeEditor);
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
project.delete(true, false, ProjectTools.getMonitor());
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.tests.editors;
|
||||
|
||||
import org.eclipse.cdt.autotools.tests.AutotoolsTestsPlugin;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.eclipse.cdt.autotools.tests.ProjectTools;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeDocumentProvider;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
||||
|
@ -25,13 +27,15 @@ import org.eclipse.jface.text.IRegion;
|
|||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class AutomakeTextHoverTest extends TestCase {
|
||||
public class AutomakeTextHoverTest {
|
||||
|
||||
ProjectTools tools;
|
||||
private ProjectTools tools;
|
||||
private IProject project;
|
||||
private IFile makefileAmFile;
|
||||
private AutomakeTextHover textHover;
|
||||
|
@ -67,8 +71,8 @@ public class AutomakeTextHoverTest extends TestCase {
|
|||
"";
|
||||
private IWorkbench workbench;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tools = new ProjectTools();
|
||||
if (!ProjectTools.setup())
|
||||
fail("could not perform basic project workspace setup");
|
||||
|
@ -81,170 +85,138 @@ public class AutomakeTextHoverTest extends TestCase {
|
|||
|
||||
project.open(new NullProgressMonitor());
|
||||
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
Display.getDefault().syncExec(() -> {
|
||||
try {
|
||||
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
||||
workbench = PlatformUI.getWorkbench();
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
||||
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
|
||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE
|
||||
.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), makefileAmFile, true);
|
||||
|
||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
|
||||
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
|
||||
true);
|
||||
|
||||
automakeEditor = (AutomakeEditor) openEditor;
|
||||
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
||||
automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
||||
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
|
||||
textHover = (AutomakeTextHover) automakeSourceViewerConfig.getTextHover(null, "");
|
||||
} catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
automakeEditor = (AutomakeEditor) openEditor;
|
||||
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
||||
automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
||||
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor
|
||||
.getAutomakeSourceViewerConfiguration();
|
||||
textHover = (AutomakeTextHover) automakeSourceViewerConfig.getTextHover(null, "");
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
project.delete(true, false, ProjectTools.getMonitor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHoverInfoTargetName1() {
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 45);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
// hover between the $ and the @ in target1
|
||||
assertEquals(44, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
|
||||
hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target1", textHover.getHoverInfo(
|
||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 45);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
// hover between the $ and the @ in target1
|
||||
assertEquals(44, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHoverInfoTargetName2() {
|
||||
// hover between the $ and the @ in target2
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 87);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(86, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
|
||||
hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target2", textHover.getHoverInfo(
|
||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 87);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(86, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target2", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHoverInfoForTargetDependency() {
|
||||
// hover between the $ and the < in target2
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 96);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(95, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$<", automakeDocument.get(hoverRegion.getOffset(),
|
||||
hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target1", textHover.getHoverInfo(
|
||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 96);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(95, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$<", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHoverInfoForTargetDependencies() {
|
||||
// hover between the $ and the ? in target3
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 131);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(130, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$?", automakeDocument.get(hoverRegion.getOffset(),
|
||||
hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target1 target2", textHover.getHoverInfo(
|
||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 131);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(130, hoverRegion.getOffset());
|
||||
assertEquals(2, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("$?", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("target1 target2",
|
||||
textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHoverForMacro1() {
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 32);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
// hover between the M and the A in the first $(MACRO) reference
|
||||
assertEquals(31, hoverRegion.getOffset());
|
||||
assertEquals(5, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
|
||||
hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("case1", textHover.getHoverInfo(
|
||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 32);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
// hover between the M and the A in the first $(MACRO) reference
|
||||
assertEquals(31, hoverRegion.getOffset());
|
||||
assertEquals(5, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("case1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHoverForMacro2() {
|
||||
// hover between the M and the A in the ${MACRO} reference in target2
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 74);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(73, hoverRegion.getOffset());
|
||||
assertEquals(5, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
|
||||
hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("case1", textHover.getHoverInfo(
|
||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
Display.getDefault().syncExec(() -> {
|
||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 74);
|
||||
if (hoverRegion == null)
|
||||
fail("Null hoverRegion");
|
||||
assertEquals(73, hoverRegion.getOffset());
|
||||
assertEquals(5, hoverRegion.getLength());
|
||||
try {
|
||||
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||
} catch (BadLocationException e) {
|
||||
fail("BadLocationException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("case1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue