mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 02:05:39 +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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<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.8"/>
|
||||||
<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 exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</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.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
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.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.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=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.deprecationInDeprecatedCode=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
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.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.fallthroughCase=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
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.includeNullInfoFromAsserts=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=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.localVariableHiding=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
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.rawTypeReference=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
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.unnecessaryElse=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
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.unusedWarningToken=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=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-Name: %bundleName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.autotools.tests;singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.autotools.tests;singleton:=true
|
||||||
Bundle-Version: 2.0.0.qualifier
|
Bundle-Version: 2.0.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.autotools.tests.AutotoolsTestsPlugin
|
|
||||||
Bundle-Vendor: %provider
|
Bundle-Vendor: %provider
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.ui,
|
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.autotools.ui;bundle-version="1.0.0",
|
||||||
org.eclipse.cdt.core.tests
|
org.eclipse.cdt.core.tests
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
Export-Package: org.eclipse.cdt.autotools.tests,
|
Export-Package: org.eclipse.cdt.autotools.tests,
|
||||||
org.eclipse.cdt.autotools.tests.autoconf,
|
org.eclipse.cdt.autotools.tests.autoconf,
|
||||||
org.eclipse.cdt.autotools.tests.editors
|
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.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -36,7 +37,7 @@ public class AutotoolsEnvironmentVarTest {
|
||||||
private IProject testProject;
|
private IProject testProject;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws CoreException {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
fail("could not perform basic project workspace setup");
|
fail("could not perform basic project workspace setup");
|
||||||
testProject = ProjectTools.createProject("testProject0");
|
testProject = ProjectTools.createProject("testProject0");
|
||||||
|
@ -57,7 +58,7 @@ public class AutotoolsEnvironmentVarTest {
|
||||||
public void testAutotoolsEnvironmentVar() throws Exception {
|
public void testAutotoolsEnvironmentVar() throws Exception {
|
||||||
|
|
||||||
Path p = new Path("zip/project1.zip");
|
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));
|
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||||
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject)
|
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject)
|
||||||
.getActiveConfiguration();
|
.getActiveConfiguration();
|
||||||
|
|
|
@ -15,12 +15,13 @@ import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
|
import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class AutotoolsProjectNatureTest {
|
public class AutotoolsProjectNatureTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws CoreException {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
fail("could not perform basic project workspace setup");
|
fail("could not perform basic project workspace setup");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class AutotoolsProjectTest0 {
|
||||||
@Test
|
@Test
|
||||||
public void testAutotoolsProject0() throws Exception {
|
public void testAutotoolsProject0() throws Exception {
|
||||||
Path p = new Path("zip/project1.zip");
|
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));
|
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||||
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("ChangeLog");
|
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("ChangeLog");
|
||||||
assertTrue(testProject.exists(x));
|
assertTrue(testProject.exists(x));
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class AutotoolsProjectTest1 {
|
||||||
@Test
|
@Test
|
||||||
public void testAutotoolsProject1() throws Exception {
|
public void testAutotoolsProject1() throws Exception {
|
||||||
Path p = new Path("zip/project1.zip");
|
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));
|
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||||
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog");
|
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog");
|
||||||
assertTrue(testProject.exists(x));
|
assertTrue(testProject.exists(x));
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class AutotoolsProjectTest2 {
|
||||||
@Test
|
@Test
|
||||||
public void testAutotoolsProject2() throws Exception {
|
public void testAutotoolsProject2() throws Exception {
|
||||||
Path p = new Path("zip/project2.zip");
|
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));
|
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||||
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog");
|
org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog");
|
||||||
assertTrue(testProject.exists(x));
|
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();
|
configDir.deleteOnExit();
|
||||||
assertTrue(configDir.mkdir());
|
assertTrue(configDir.mkdir());
|
||||||
ProjectTools.createLinkedFolder(testProject, "src", URIUtil.append(root.getLocationURI(), "config"));
|
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(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||||
assertTrue(exists("src/ChangeLog"));
|
assertTrue(exists("src/ChangeLog"));
|
||||||
ProjectTools.setConfigDir(testProject, "src");
|
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.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Path;
|
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.PlatformUI;
|
||||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||||
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
|
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
|
||||||
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
|
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
|
||||||
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
|
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
|
||||||
|
import org.osgi.framework.FrameworkUtil;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
|
@ -61,9 +62,9 @@ public class ProjectTools {
|
||||||
/**
|
/**
|
||||||
* Setup routine for tests.
|
* Setup routine for tests.
|
||||||
* @return true if setup successful, false otherwise
|
* @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) {
|
if (!setupComplete) {
|
||||||
IWorkspaceDescription desc;
|
IWorkspaceDescription desc;
|
||||||
workspace = ResourcesPlugin.getWorkspace();
|
workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
@ -151,8 +152,8 @@ public class ProjectTools {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(
|
if (launcher.waitAndRead(stdout, stderr,
|
||||||
monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -185,8 +186,7 @@ public class ProjectTools {
|
||||||
@Override
|
@Override
|
||||||
public IConfiguration[] getSelectedConfigurations() {
|
public IConfiguration[] getSelectedConfigurations() {
|
||||||
IProjectType projectType = ManagedBuildManager.getExtensionProjectType("org.eclipse.linuxtools.cdt.autotools.core.projectType"); //$NON-NLS-1$
|
IProjectType projectType = ManagedBuildManager.getExtensionProjectType("org.eclipse.linuxtools.cdt.autotools.core.projectType"); //$NON-NLS-1$
|
||||||
IConfiguration[] cfgs = projectType.getConfigurations();
|
return projectType.getConfigurations();
|
||||||
return cfgs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,10 +204,7 @@ public class ProjectTools {
|
||||||
try {
|
try {
|
||||||
testProject.create(monitor);
|
testProject.create(monitor);
|
||||||
testProject.open(monitor);
|
testProject.open(monitor);
|
||||||
// IProjectDescription description = workspace.newProjectDescription(name);
|
IProject newProject = CCorePlugin.getDefault().createCDTProject(description, testProject, SubMonitor.convert(monitor,25));
|
||||||
// if(location != null)
|
|
||||||
// description.setLocationURI(location);
|
|
||||||
IProject newProject = CCorePlugin.getDefault().createCDTProject(description, testProject, new SubProgressMonitor(monitor,25));
|
|
||||||
ConvertToAutotoolsProjectWizardTest wizard = new ConvertToAutotoolsProjectWizardTest();
|
ConvertToAutotoolsProjectWizardTest wizard = new ConvertToAutotoolsProjectWizardTest();
|
||||||
wizard.addPages();
|
wizard.addPages();
|
||||||
ConvertToAutotoolsProjectWizardPage page = new ConvertToAutotoolsProjectWizardPage("test", wizard);
|
ConvertToAutotoolsProjectWizardPage page = new ConvertToAutotoolsProjectWizardPage("test", wizard);
|
||||||
|
@ -230,22 +227,6 @@ public class ProjectTools {
|
||||||
String id = cfgd.getId();
|
String id = cfgd.getId();
|
||||||
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, id, true);
|
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, id, true);
|
||||||
cfg.setConfigToolDirectory(dir);
|
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 {
|
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
|
||||||
|
@ -282,7 +263,7 @@ public class ProjectTools {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(
|
if (launcher.waitAndRead(stdout, stderr, SubMonitor.convert(
|
||||||
monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -302,6 +283,7 @@ public class ProjectTools {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
||||||
|
@Override
|
||||||
public String queryOverwrite(String file) {
|
public String queryOverwrite(String file) {
|
||||||
return ALL;
|
return ALL;
|
||||||
}
|
}
|
||||||
|
@ -315,31 +297,6 @@ public class ProjectTools {
|
||||||
* @throws CoreException Creation failed
|
* @throws CoreException Creation failed
|
||||||
*/
|
*/
|
||||||
public static IContainer addSourceContainer(IProject jproject, String containerName) throws CoreException {
|
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 {
|
|
||||||
IProject project= jproject.getProject();
|
IProject project= jproject.getProject();
|
||||||
IContainer container= null;
|
IContainer container= null;
|
||||||
if (containerName == null || containerName.length() == 0) {
|
if (containerName == null || containerName.length() == 0) {
|
||||||
|
@ -347,7 +304,7 @@ public class ProjectTools {
|
||||||
} else {
|
} else {
|
||||||
IFolder folder= project.getFolder(containerName);
|
IFolder folder= project.getFolder(containerName);
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
CoreUtility.createFolder(folder, false, true, null);
|
createFolder(folder, false, true, null);
|
||||||
}
|
}
|
||||||
container= folder;
|
container= folder;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +318,6 @@ public class ProjectTools {
|
||||||
* @param project The parent project
|
* @param project The parent project
|
||||||
* @param containerName Name of the source container
|
* @param containerName Name of the source container
|
||||||
* @param zipFile Archive to import
|
* @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 generate true if configuration files need to be pre-generated
|
||||||
* @param exclusionFilters Exclusion filters to set
|
* @param exclusionFilters Exclusion filters to set
|
||||||
* @return The handle to the new source container
|
* @return The handle to the new source container
|
||||||
|
@ -369,21 +325,14 @@ public class ProjectTools {
|
||||||
* @throws CoreException Creation failed
|
* @throws CoreException Creation failed
|
||||||
* @throws IOException 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 {
|
public static IContainer addSourceContainerWithImport(IProject project, String containerName, File zipFile, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
||||||
ZipFile file= new ZipFile(zipFile);
|
try (ZipFile file= new ZipFile(zipFile)){
|
||||||
try {
|
IContainer root= addSourceContainer(project, containerName);
|
||||||
// IPackageFragmentRoot root= addSourceContainer(jproject, containerName, exclusionFilters);
|
|
||||||
// ((IContainer) root.getCorrespondingResource()).setDefaultCharset(containerEncoding, null);
|
|
||||||
IContainer root= addSourceContainer(project, containerName, exclusionFilters);
|
|
||||||
if (generate)
|
if (generate)
|
||||||
importFilesFromZipAndGenerate(file, root.getFullPath(), null);
|
importFilesFromZipAndGenerate(file, root.getFullPath(), null);
|
||||||
else
|
else
|
||||||
importFilesFromZip(file, root.getFullPath(), null);
|
importFilesFromZip(file, root.getFullPath(), null);
|
||||||
return root;
|
return root;
|
||||||
} finally {
|
|
||||||
if (file != null) {
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,16 +342,15 @@ public class ProjectTools {
|
||||||
* @param project The parent project
|
* @param project The parent project
|
||||||
* @param containerName Name of the source container
|
* @param containerName Name of the source container
|
||||||
* @param path path of zipFile Archive to import
|
* @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
|
* @param generate true if configuration files need to be pre-generated
|
||||||
* @return The handle to the new source container
|
* @return The handle to the new source container
|
||||||
* @throws InvocationTargetException Creation failed
|
* @throws InvocationTargetException Creation failed
|
||||||
* @throws CoreException Creation failed
|
* @throws CoreException Creation failed
|
||||||
* @throws IOException Creation failed
|
* @throws IOException Creation failed
|
||||||
*/
|
*/
|
||||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath, String containerEncoding, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
||||||
File zipFile = new File(FileLocator.toFileURL(FileLocator.find(AutotoolsTestsPlugin.getDefault().getBundle(), zipFilePath, null)).getFile());
|
File zipFile = new File(FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(ProjectTools.class), zipFilePath, null)).getFile());
|
||||||
return addSourceContainerWithImport(project, containerName, zipFile, containerEncoding, generate, null);
|
return addSourceContainerWithImport(project, containerName, zipFile, generate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -411,27 +359,13 @@ public class ProjectTools {
|
||||||
* @param project The parent project
|
* @param project The parent project
|
||||||
* @param containerName Name of the source container
|
* @param containerName Name of the source container
|
||||||
* @param path path of zipFile Archive to import
|
* @param path path of zipFile Archive to import
|
||||||
* @param containerEncoding encoding for the generated source container
|
|
||||||
* @return The handle to the new source container
|
* @return The handle to the new source container
|
||||||
* @throws InvocationTargetException Creation failed
|
* @throws InvocationTargetException Creation failed
|
||||||
* @throws CoreException Creation failed
|
* @throws CoreException Creation failed
|
||||||
* @throws IOException Creation failed
|
* @throws IOException Creation failed
|
||||||
*/
|
*/
|
||||||
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath, String containerEncoding) throws InvocationTargetException, CoreException, IOException {
|
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath) throws InvocationTargetException, CoreException, IOException {
|
||||||
return addSourceContainerWithImport(project, containerName, zipFilePath, containerEncoding, false);
|
return addSourceContainerWithImport(project, containerName, zipFilePath, 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -449,53 +383,6 @@ public class ProjectTools {
|
||||||
return file;
|
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
|
* Create a linked folder for a project
|
||||||
* @param project The project
|
* @param project The project
|
||||||
|
@ -509,17 +396,14 @@ public class ProjectTools {
|
||||||
final IFolder folderHandle = root.getFolder(project.getFullPath().append(folderName));
|
final IFolder folderHandle = root.getFolder(project.getFullPath().append(folderName));
|
||||||
|
|
||||||
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
|
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
|
||||||
|
@Override
|
||||||
public void execute(IProgressMonitor monitor) throws CoreException {
|
public void execute(IProgressMonitor monitor) throws CoreException {
|
||||||
try {
|
try {
|
||||||
monitor
|
monitor.beginTask(IDEWorkbenchMessages.NewFolderDialog_progress, 2000);
|
||||||
.beginTask(
|
|
||||||
IDEWorkbenchMessages.NewFolderDialog_progress,
|
|
||||||
2000);
|
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
folderHandle.createLink(linkTarget,
|
folderHandle.createLink(linkTarget, IResource.ALLOW_MISSING_LOCAL, monitor);
|
||||||
IResource.ALLOW_MISSING_LOCAL, monitor);
|
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
|
@ -529,15 +413,27 @@ public class ProjectTools {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
|
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation);
|
||||||
operation);
|
|
||||||
} catch (InterruptedException exception) {
|
} catch (InterruptedException exception) {
|
||||||
return null;
|
return null;
|
||||||
} catch (InvocationTargetException exception) {
|
|
||||||
throw exception;
|
|
||||||
}
|
}
|
||||||
return folderHandle;
|
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
|
@Test
|
||||||
public void testGprofGcovDebugFlagOptions() throws Exception {
|
public void testGprofGcovDebugFlagOptions() throws Exception {
|
||||||
Path p = new Path("zip/project2.zip");
|
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));
|
assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||||
ProjectTools.setConfigDir(testProject, "src");
|
ProjectTools.setConfigDir(testProject, "src");
|
||||||
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
||||||
|
@ -98,16 +98,12 @@ public class UpdateConfigureTest {
|
||||||
|
|
||||||
File f = r.getLocation().toFile();
|
File f = r.getLocation().toFile();
|
||||||
|
|
||||||
FileReader fr = new FileReader(f);
|
|
||||||
|
|
||||||
char[] cbuf = new char[2000];
|
char[] cbuf = new char[2000];
|
||||||
|
try (FileReader fr = new FileReader(f)) {
|
||||||
fr.read(cbuf);
|
fr.read(cbuf);
|
||||||
|
|
||||||
String s = new String(cbuf);
|
String s = new String(cbuf);
|
||||||
|
|
||||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-pg CXXFLAGS=-pg"));
|
assertTrue(s.contains("testProject2/src/configure CFLAGS=-pg CXXFLAGS=-pg"));
|
||||||
|
}
|
||||||
fr.close();
|
|
||||||
|
|
||||||
// Reset gprof opt and set gcov opt
|
// Reset gprof opt and set gcov opt
|
||||||
opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
|
opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
|
||||||
|
@ -125,14 +121,13 @@ public class UpdateConfigureTest {
|
||||||
|
|
||||||
r = testProject.findMember(x);
|
r = testProject.findMember(x);
|
||||||
f = r.getLocation().toFile();
|
f = r.getLocation().toFile();
|
||||||
fr = new FileReader(f);
|
try (FileReader fr = new FileReader(f)) {
|
||||||
fr.read(cbuf);
|
fr.read(cbuf);
|
||||||
|
String s = new String(cbuf);
|
||||||
|
assertTrue(s.contains(
|
||||||
|
"testProject2/src/configure CFLAGS=-fprofile-arcs -ftest-coverage CXXFLAGS=-fprofile-arcs -ftest-coverage"));
|
||||||
|
|
||||||
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
|
// Reset gcov opt and set debug opt
|
||||||
opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
|
opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
|
||||||
|
@ -150,14 +145,11 @@ public class UpdateConfigureTest {
|
||||||
|
|
||||||
r = testProject.findMember(x);
|
r = testProject.findMember(x);
|
||||||
f = r.getLocation().toFile();
|
f = r.getLocation().toFile();
|
||||||
fr = new FileReader(f);
|
try (FileReader fr = new FileReader(f)) {
|
||||||
fr.read(cbuf);
|
fr.read(cbuf);
|
||||||
|
String s = new String(cbuf);
|
||||||
s = new String(cbuf);
|
|
||||||
|
|
||||||
assertTrue(s.contains("testProject2/src/configure CFLAGS=-g CXXFLAGS=-g"));
|
assertTrue(s.contains("testProject2/src/configure CFLAGS=-g CXXFLAGS=-g"));
|
||||||
|
}
|
||||||
fr.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +160,7 @@ public class UpdateConfigureTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetAndUpdateConfigureOptions() throws Exception {
|
public void testGetAndUpdateConfigureOptions() throws Exception {
|
||||||
Path p = new Path("zip/project2.zip");
|
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));
|
assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
|
||||||
ProjectTools.setConfigDir(testProject, "src");
|
ProjectTools.setConfigDir(testProject, "src");
|
||||||
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
||||||
|
@ -557,14 +549,7 @@ public class UpdateConfigureTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (IOException|ParserConfigurationException|SAXException 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
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,12 @@
|
||||||
package org.eclipse.cdt.autotools.tests.autoconf;
|
package org.eclipse.cdt.autotools.tests.autoconf;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -40,35 +39,22 @@ public abstract class BaseParserTest {
|
||||||
private Set<String> macroNames;
|
private Set<String> macroNames;
|
||||||
private AutoconfMacroDetector macroDetector;
|
private AutoconfMacroDetector macroDetector;
|
||||||
|
|
||||||
public BaseParserTest() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() {
|
||||||
errors = new ArrayList<>();
|
errors = new ArrayList<>();
|
||||||
this.errorHandler = new IAutoconfErrorHandler() {
|
this.errorHandler = (ParseException exception) -> {
|
||||||
@Override
|
|
||||||
public void handleError(ParseException exception) {
|
|
||||||
assertNotNull(exception);
|
assertNotNull(exception);
|
||||||
errors.add(exception);
|
errors.add(exception);
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.macroDetector = new AutoconfMacroDetector();
|
this.macroDetector = new AutoconfMacroDetector();
|
||||||
|
|
||||||
macroNames = new HashSet<>();
|
macroNames = new HashSet<>();
|
||||||
this.macroValidator = new IAutoconfMacroValidator() {
|
this.macroValidator = (AutoconfMacroElement element) -> {
|
||||||
@Override
|
|
||||||
public void validateMacroCall(AutoconfMacroElement element)
|
|
||||||
throws ParseException {
|
|
||||||
assertNotNull(element);
|
assertNotNull(element);
|
||||||
assertNotNull(element.getName());
|
assertNotNull(element.getName());
|
||||||
assertNotNull(element.getChildren());
|
assertNotNull(element.getChildren());
|
||||||
macroNames.add(element.getName());
|
macroNames.add(element.getName());
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,23 +120,22 @@ public abstract class BaseParserTest {
|
||||||
assertEquals(string, document.get());
|
assertEquals(string, document.get());
|
||||||
|
|
||||||
if (!allowErrors) {
|
if (!allowErrors) {
|
||||||
if (errors.size() > 0)
|
if (!errors.isEmpty())
|
||||||
fail("got errors" + errors.get(0));
|
fail("got errors" + errors.get(0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assertTrue(errors.size() > 0);
|
assertFalse(errors.isEmpty());
|
||||||
|
|
||||||
return root2;
|
return root2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkError(String msgKey) {
|
protected void checkError(String msgKey) {
|
||||||
for (Iterator<ParseException> iter = errors.iterator(); iter.hasNext(); ) {
|
for (ParseException exc: errors) {
|
||||||
ParseException exc = iter.next();
|
|
||||||
if (exc.getMessage().contains(msgKey))
|
if (exc.getMessage().contains(msgKey))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String any = "";
|
String any = "";
|
||||||
if (errors.size() > 0)
|
if (!errors.isEmpty())
|
||||||
any = ", but saw " + errors.get(0).toString();
|
any = ", but saw " + errors.get(0).toString();
|
||||||
fail("did not find error: " + msgKey + any );
|
fail("did not find error: " + msgKey + any );
|
||||||
}
|
}
|
||||||
|
@ -158,8 +143,7 @@ public abstract class BaseParserTest {
|
||||||
protected void checkError(String msgKey, int line) {
|
protected void checkError(String msgKey, int line) {
|
||||||
ParseException possible = null;
|
ParseException possible = null;
|
||||||
int distance = 999;
|
int distance = 999;
|
||||||
for (Iterator<ParseException> iter = errors.iterator(); iter.hasNext(); ) {
|
for (ParseException exc : errors) {
|
||||||
ParseException exc = iter.next();
|
|
||||||
if (exc.getMessage().contains(msgKey)) {
|
if (exc.getMessage().contains(msgKey)) {
|
||||||
int curDistance = Math.abs(exc.getLineNumber() - line);
|
int curDistance = Math.abs(exc.getLineNumber() - line);
|
||||||
if (curDistance < distance) {
|
if (curDistance < distance) {
|
||||||
|
|
|
@ -31,12 +31,12 @@ import org.junit.Test;
|
||||||
public class TestMacroParser extends BaseParserTest {
|
public class TestMacroParser extends BaseParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmpty() throws Exception {
|
public void testEmpty() {
|
||||||
parse("");
|
parse("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComments() throws Exception {
|
public void testComments() {
|
||||||
//
|
//
|
||||||
String text =
|
String text =
|
||||||
"dnl first line\n" +
|
"dnl first line\n" +
|
||||||
|
@ -49,7 +49,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing1() throws Exception {
|
public void testMacroParsing1() {
|
||||||
//
|
//
|
||||||
String text =
|
String text =
|
||||||
"AC_REQUIRE([AM_SANITY_CHECK])\n" +
|
"AC_REQUIRE([AM_SANITY_CHECK])\n" +
|
||||||
|
@ -77,7 +77,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing2() throws Exception {
|
public void testMacroParsing2() {
|
||||||
//
|
//
|
||||||
String text =
|
String text =
|
||||||
"AC_TWO_ARGS(first,second)\n" +
|
"AC_TWO_ARGS(first,second)\n" +
|
||||||
|
@ -107,7 +107,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing3() throws Exception {
|
public void testMacroParsing3() {
|
||||||
//
|
//
|
||||||
String text =
|
String text =
|
||||||
"AC_ONE_ARG( [quoted( arg ), second] )\n" +
|
"AC_ONE_ARG( [quoted( arg ), second] )\n" +
|
||||||
|
@ -135,7 +135,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing4() throws Exception {
|
public void testMacroParsing4() {
|
||||||
//
|
//
|
||||||
String text =
|
String text =
|
||||||
"AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],\r\n" +
|
"AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],\r\n" +
|
||||||
|
@ -160,7 +160,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing5() throws Exception {
|
public void testMacroParsing5() {
|
||||||
// check that complex shell constructs don't throw off the
|
// check that complex shell constructs don't throw off the
|
||||||
// parser, and also that we don't mistake shell tokens in a macro argument
|
// parser, and also that we don't mistake shell tokens in a macro argument
|
||||||
String arg2 =
|
String arg2 =
|
||||||
|
@ -205,7 +205,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing6() throws Exception {
|
public void testMacroParsing6() {
|
||||||
// empty arguments
|
// empty arguments
|
||||||
String text =
|
String text =
|
||||||
"AC_DEFUN( ,\n" +
|
"AC_DEFUN( ,\n" +
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfTokenizer;
|
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.ITokenConstants;
|
||||||
import org.eclipse.cdt.autotools.ui.editors.parser.ParseException;
|
import org.eclipse.cdt.autotools.ui.editors.parser.ParseException;
|
||||||
import org.eclipse.cdt.autotools.ui.editors.parser.Token;
|
import org.eclipse.cdt.autotools.ui.editors.parser.Token;
|
||||||
|
@ -43,23 +42,14 @@ public class TestTokenizer {
|
||||||
return new Document(text);
|
return new Document(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Token> tokenize(IDocument document) {
|
|
||||||
return tokenize(document, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<Token> tokenize(IDocument document, boolean isM4Mode) {
|
protected List<Token> tokenize(IDocument document, boolean isM4Mode) {
|
||||||
tokenizerErrors = new ArrayList<>();
|
tokenizerErrors = new ArrayList<>();
|
||||||
AutoconfTokenizer tokenizer = new AutoconfTokenizer(document, new IAutoconfErrorHandler() {
|
AutoconfTokenizer tokenizer = new AutoconfTokenizer(document, (ParseException exception) -> {
|
||||||
@Override
|
|
||||||
public void handleError(ParseException exception) {
|
|
||||||
tokenizerErrors.add(exception);
|
tokenizerErrors.add(exception);
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
tokenizer.setM4Context(isM4Mode);
|
tokenizer.setM4Context(isM4Mode);
|
||||||
|
|
||||||
List<Token> tokens = tokenize(tokenizer);
|
return tokenize(tokenizer);
|
||||||
return tokens;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Token> tokenize(AutoconfTokenizer tokenizer) {
|
protected List<Token> tokenize(AutoconfTokenizer tokenizer) {
|
||||||
|
@ -444,12 +434,8 @@ public class TestTokenizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private AutoconfTokenizer createTokenizer(IDocument document) {
|
private AutoconfTokenizer createTokenizer(IDocument document) {
|
||||||
return new AutoconfTokenizer(document, new IAutoconfErrorHandler() {
|
return new AutoconfTokenizer(document, (ParseException exception) -> {
|
||||||
@Override
|
|
||||||
public void handleError(ParseException exception) {
|
|
||||||
fail(exception.toString());
|
fail(exception.toString());
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.eclipse.cdt.autotools.tests.AutotoolsTestsPlugin;
|
|
||||||
import org.eclipse.cdt.autotools.tests.ProjectTools;
|
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.AutomakeDocumentProvider;
|
||||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
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.swt.widgets.Display;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -40,7 +40,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class AutomakeColourizationTests {
|
public class AutomakeColourizationTests {
|
||||||
|
|
||||||
ProjectTools tools;
|
private ProjectTools tools;
|
||||||
private IProject project;
|
private IProject project;
|
||||||
private IFile makefileAmFile;
|
private IFile makefileAmFile;
|
||||||
|
|
||||||
|
@ -70,31 +70,26 @@ public class AutomakeColourizationTests {
|
||||||
|
|
||||||
project.open(new NullProgressMonitor());
|
project.open(new NullProgressMonitor());
|
||||||
|
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
||||||
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
|
workbench = PlatformUI.getWorkbench();
|
||||||
|
|
||||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
|
IEditorPart openEditor = org.eclipse.ui.ide.IDE
|
||||||
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
|
.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), makefileAmFile, true);
|
||||||
true);
|
|
||||||
|
|
||||||
AutomakeEditor automakeEditor = (AutomakeEditor) openEditor;
|
AutomakeEditor automakeEditor = (AutomakeEditor) openEditor;
|
||||||
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
||||||
IDocument automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
IDocument automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
||||||
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
|
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor
|
||||||
|
.getAutomakeSourceViewerConfiguration();
|
||||||
|
|
||||||
ITypedRegion region = automakeDocument.getPartition(0);
|
ITypedRegion region = automakeDocument.getPartition(0);
|
||||||
codeScanner = automakeSourceViewerConfig.getAutomakeCodeScanner();
|
codeScanner = automakeSourceViewerConfig.getAutomakeCodeScanner();
|
||||||
codeScanner.setRange(automakeDocument, region.getOffset(), region.getLength());
|
codeScanner.setRange(automakeDocument, region.getOffset(), region.getLength());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail();
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -103,7 +98,7 @@ public class AutomakeColourizationTests {
|
||||||
return codeScanner.nextToken();
|
return codeScanner.nextToken();
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testAutomakeEditorColourization() throws Exception {
|
public void testAutomakeEditorColourization() {
|
||||||
// # This is a comment
|
// # This is a comment
|
||||||
IToken token0 = getNextToken();
|
IToken token0 = getNextToken();
|
||||||
assertTrue(token0 instanceof Token);
|
assertTrue(token0 instanceof Token);
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.autotools.tests.editors;
|
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.autotools.tests.ProjectTools;
|
||||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
||||||
import org.eclipse.core.resources.IFile;
|
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.swt.widgets.Display;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import junit.framework.TestCase;
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class AutomakeEditorTests extends TestCase {
|
public class AutomakeEditorTests {
|
||||||
|
|
||||||
ProjectTools tools;
|
private ProjectTools tools;
|
||||||
private IProject project;
|
private IProject project;
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
@Before
|
||||||
super.setUp();
|
public void setUp() throws Exception {
|
||||||
tools = new ProjectTools();
|
tools = new ProjectTools();
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
fail("could not perform basic project workspace setup");
|
fail("could not perform basic project workspace setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAutomakeEditorAssociation() throws Exception {
|
public void testAutomakeEditorAssociation() throws Exception {
|
||||||
project = ProjectTools.createProject("testProjectAET");
|
project = ProjectTools.createProject("testProjectAET");
|
||||||
|
|
||||||
|
@ -44,24 +48,19 @@ public class AutomakeEditorTests extends TestCase {
|
||||||
|
|
||||||
project.open(new NullProgressMonitor());
|
project.open(new NullProgressMonitor());
|
||||||
|
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
|
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
|
||||||
assertTrue(makefileAmFile.exists());
|
assertTrue(makefileAmFile.exists());
|
||||||
|
|
||||||
IWorkbench workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
|
IWorkbench workbench = PlatformUI.getWorkbench();
|
||||||
|
|
||||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
|
IEditorPart openEditor = org.eclipse.ui.ide.IDE
|
||||||
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
|
.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), makefileAmFile, true);
|
||||||
true);
|
|
||||||
assertTrue(openEditor instanceof AutomakeEditor);
|
assertTrue(openEditor instanceof AutomakeEditor);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail();
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
project.delete(true, false, ProjectTools.getMonitor());
|
project.delete(true, false, ProjectTools.getMonitor());
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.autotools.tests.editors;
|
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.autotools.tests.ProjectTools;
|
||||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeDocumentProvider;
|
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeDocumentProvider;
|
||||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.AutomakeEditor;
|
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.swt.widgets.Display;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbench;
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import junit.framework.TestCase;
|
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 IProject project;
|
||||||
private IFile makefileAmFile;
|
private IFile makefileAmFile;
|
||||||
private AutomakeTextHover textHover;
|
private AutomakeTextHover textHover;
|
||||||
|
@ -67,8 +71,8 @@ public class AutomakeTextHoverTest extends TestCase {
|
||||||
"";
|
"";
|
||||||
private IWorkbench workbench;
|
private IWorkbench workbench;
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
@Before
|
||||||
super.setUp();
|
public void setUp() throws Exception {
|
||||||
tools = new ProjectTools();
|
tools = new ProjectTools();
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
fail("could not perform basic project workspace setup");
|
fail("could not perform basic project workspace setup");
|
||||||
|
@ -81,39 +85,34 @@ public class AutomakeTextHoverTest extends TestCase {
|
||||||
|
|
||||||
project.open(new NullProgressMonitor());
|
project.open(new NullProgressMonitor());
|
||||||
|
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
makefileAmFile = tools.createFile(project, "Makefile.am", makefileAmContents);
|
||||||
workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
|
workbench = PlatformUI.getWorkbench();
|
||||||
|
|
||||||
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
|
IEditorPart openEditor = org.eclipse.ui.ide.IDE
|
||||||
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
|
.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), makefileAmFile, true);
|
||||||
true);
|
|
||||||
|
|
||||||
automakeEditor = (AutomakeEditor) openEditor;
|
automakeEditor = (AutomakeEditor) openEditor;
|
||||||
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
AutomakeDocumentProvider docProvider = automakeEditor.getAutomakefileDocumentProvider();
|
||||||
automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
automakeDocument = docProvider.getDocument(openEditor.getEditorInput());
|
||||||
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor.getAutomakeSourceViewerConfiguration();
|
AutomakefileSourceConfiguration automakeSourceViewerConfig = automakeEditor
|
||||||
|
.getAutomakeSourceViewerConfiguration();
|
||||||
textHover = (AutomakeTextHover) automakeSourceViewerConfig.getTextHover(null, "");
|
textHover = (AutomakeTextHover) automakeSourceViewerConfig.getTextHover(null, "");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail();
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
@After
|
||||||
super.tearDown();
|
public void tearDown() throws Exception {
|
||||||
project.delete(true, false, ProjectTools.getMonitor());
|
project.delete(true, false, ProjectTools.getMonitor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testGetHoverInfoTargetName1() {
|
public void testGetHoverInfoTargetName1() {
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 45);
|
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 45);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
fail("Null hoverRegion");
|
fail("Null hoverRegion");
|
||||||
|
@ -121,91 +120,72 @@ public class AutomakeTextHoverTest extends TestCase {
|
||||||
assertEquals(44, hoverRegion.getOffset());
|
assertEquals(44, hoverRegion.getOffset());
|
||||||
assertEquals(2, hoverRegion.getLength());
|
assertEquals(2, hoverRegion.getLength());
|
||||||
try {
|
try {
|
||||||
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
|
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||||
hoverRegion.getLength()));
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
fail("BadLocationException");
|
fail("BadLocationException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertEquals("target1", textHover.getHoverInfo(
|
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
public void testGetHoverInfoTargetName2() {
|
public void testGetHoverInfoTargetName2() {
|
||||||
// hover between the $ and the @ in target2
|
// hover between the $ and the @ in target2
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 87);
|
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 87);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
fail("Null hoverRegion");
|
fail("Null hoverRegion");
|
||||||
assertEquals(86, hoverRegion.getOffset());
|
assertEquals(86, hoverRegion.getOffset());
|
||||||
assertEquals(2, hoverRegion.getLength());
|
assertEquals(2, hoverRegion.getLength());
|
||||||
try {
|
try {
|
||||||
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(),
|
assertEquals("$@", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||||
hoverRegion.getLength()));
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
fail("BadLocationException");
|
fail("BadLocationException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertEquals("target2", textHover.getHoverInfo(
|
assertEquals("target2", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
public void testGetHoverInfoForTargetDependency() {
|
public void testGetHoverInfoForTargetDependency() {
|
||||||
// hover between the $ and the < in target2
|
// hover between the $ and the < in target2
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 96);
|
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 96);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
fail("Null hoverRegion");
|
fail("Null hoverRegion");
|
||||||
assertEquals(95, hoverRegion.getOffset());
|
assertEquals(95, hoverRegion.getOffset());
|
||||||
assertEquals(2, hoverRegion.getLength());
|
assertEquals(2, hoverRegion.getLength());
|
||||||
try {
|
try {
|
||||||
assertEquals("$<", automakeDocument.get(hoverRegion.getOffset(),
|
assertEquals("$<", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||||
hoverRegion.getLength()));
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
fail("BadLocationException");
|
fail("BadLocationException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertEquals("target1", textHover.getHoverInfo(
|
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
public void testGetHoverInfoForTargetDependencies() {
|
public void testGetHoverInfoForTargetDependencies() {
|
||||||
// hover between the $ and the ? in target3
|
// hover between the $ and the ? in target3
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 131);
|
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 131);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
fail("Null hoverRegion");
|
fail("Null hoverRegion");
|
||||||
assertEquals(130, hoverRegion.getOffset());
|
assertEquals(130, hoverRegion.getOffset());
|
||||||
assertEquals(2, hoverRegion.getLength());
|
assertEquals(2, hoverRegion.getLength());
|
||||||
try {
|
try {
|
||||||
assertEquals("$?", automakeDocument.get(hoverRegion.getOffset(),
|
assertEquals("$?", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||||
hoverRegion.getLength()));
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
fail("BadLocationException");
|
fail("BadLocationException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertEquals("target1 target2", textHover.getHoverInfo(
|
assertEquals("target1 target2",
|
||||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
public void testGetHoverForMacro1() {
|
public void testGetHoverForMacro1() {
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 32);
|
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 32);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
fail("Null hoverRegion");
|
fail("Null hoverRegion");
|
||||||
|
@ -213,38 +193,30 @@ public class AutomakeTextHoverTest extends TestCase {
|
||||||
assertEquals(31, hoverRegion.getOffset());
|
assertEquals(31, hoverRegion.getOffset());
|
||||||
assertEquals(5, hoverRegion.getLength());
|
assertEquals(5, hoverRegion.getLength());
|
||||||
try {
|
try {
|
||||||
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
|
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||||
hoverRegion.getLength()));
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
fail("BadLocationException");
|
fail("BadLocationException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertEquals("case1", textHover.getHoverInfo(
|
assertEquals("case1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
public void testGetHoverForMacro2() {
|
public void testGetHoverForMacro2() {
|
||||||
// hover between the M and the A in the ${MACRO} reference in target2
|
// hover between the M and the A in the ${MACRO} reference in target2
|
||||||
Display.getDefault().syncExec(new Runnable() {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 74);
|
IRegion hoverRegion = textHover.getHoverRegion(automakeEditor.getAutomakeSourceViewer(), 74);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
fail("Null hoverRegion");
|
fail("Null hoverRegion");
|
||||||
assertEquals(73, hoverRegion.getOffset());
|
assertEquals(73, hoverRegion.getOffset());
|
||||||
assertEquals(5, hoverRegion.getLength());
|
assertEquals(5, hoverRegion.getLength());
|
||||||
try {
|
try {
|
||||||
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(),
|
assertEquals("MACRO", automakeDocument.get(hoverRegion.getOffset(), hoverRegion.getLength()));
|
||||||
hoverRegion.getLength()));
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
fail("BadLocationException");
|
fail("BadLocationException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
assertEquals("case1", textHover.getHoverInfo(
|
assertEquals("case1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue