mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then Source -> Clean Up... -> choosing: - Format source code - Remove trailing white spaces on all lines and completing the wizard Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
This commit is contained in:
parent
35996a5c5c
commit
170e654b47
7984 changed files with 448190 additions and 465755 deletions
|
@ -80,7 +80,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
||||||
// Add the builder to the project
|
// Add the builder to the project
|
||||||
IProjectDescription description = project.getDescription();
|
IProjectDescription description = project.getDescription();
|
||||||
ICommand[] commands = description.getBuildSpec();
|
ICommand[] commands = description.getBuildSpec();
|
||||||
if(checkEquals(commands,getBuildCommandsList(description, commands))){
|
if (checkEquals(commands, getBuildCommandsList(description, commands))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
@ -102,7 +102,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
||||||
//need to make sure we are using the most recent ones
|
//need to make sure we are using the most recent ones
|
||||||
ICommand[] currentCommands = prDescription.getBuildSpec();
|
ICommand[] currentCommands = prDescription.getBuildSpec();
|
||||||
ICommand[] newCommands = getBuildCommandsList(prDescription, currentCommands);
|
ICommand[] newCommands = getBuildCommandsList(prDescription, currentCommands);
|
||||||
if(!checkEquals(currentCommands,newCommands)){
|
if (!checkEquals(currentCommands, newCommands)) {
|
||||||
prDescription.setBuildSpec(newCommands);
|
prDescription.setBuildSpec(newCommands);
|
||||||
proj.setDescription(prDescription, new NullProgressMonitor());
|
proj.setDescription(prDescription, new NullProgressMonitor());
|
||||||
}
|
}
|
||||||
|
@ -134,9 +134,8 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
||||||
backgroundJob.schedule();
|
backgroundJob.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkEquals(ICommand[] commands,
|
static boolean checkEquals(ICommand[] commands, ICommand[] newCommands) {
|
||||||
ICommand[] newCommands) {
|
if (newCommands.length != commands.length) {
|
||||||
if (newCommands.length != commands.length){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int j = 0; j < commands.length; ++j) {
|
for (int j = 0; j < commands.length; ++j) {
|
||||||
|
@ -147,8 +146,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ICommand[] getBuildCommandsList(IProjectDescription description,
|
static ICommand[] getBuildCommandsList(IProjectDescription description, ICommand[] commands) {
|
||||||
ICommand[] commands) {
|
|
||||||
ArrayList<ICommand> commandList = new ArrayList<>();
|
ArrayList<ICommand> commandList = new ArrayList<>();
|
||||||
|
|
||||||
// Make sure the Autotools Configuration builder just precedes the Common Builder
|
// Make sure the Autotools Configuration builder just precedes the Common Builder
|
||||||
|
@ -164,8 +162,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
|
||||||
}
|
}
|
||||||
// Make sure that the Autotools builder precedes the Managed builder
|
// Make sure that the Autotools builder precedes the Managed builder
|
||||||
// or the Remote Synchronized builder.
|
// or the Remote Synchronized builder.
|
||||||
if (command.getBuilderName().equals(BUILDER_ID) ||
|
if (command.getBuilderName().equals(BUILDER_ID) || command.getBuilderName().equals(REMOTE_BUILDER_ID)) {
|
||||||
command.getBuilderName().equals(REMOTE_BUILDER_ID)) {
|
|
||||||
// add Autotools Configuration builder just before builder
|
// add Autotools Configuration builder just before builder
|
||||||
ICommand newCommand = description.newCommand();
|
ICommand newCommand = description.newCommand();
|
||||||
newCommand.setBuilderName(AutotoolsConfigurationBuilder.BUILDER_ID);
|
newCommand.setBuilderName(AutotoolsConfigurationBuilder.BUILDER_ID);
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class AutotoolsPlugin extends AbstractUIPlugin {
|
||||||
* @return the resource bundle message
|
* @return the resource bundle message
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(String key, String[] args) {
|
public static String getFormattedString(String key, String[] args) {
|
||||||
return MessageFormat.format(getResourceString(key), (Object[])args);
|
return MessageFormat.format(getResourceString(key), (Object[]) args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,8 +194,7 @@ public class AutotoolsPlugin extends AbstractUIPlugin {
|
||||||
* @throws CoreException if project is not valid Autotools project or cfgId does not exist
|
* @throws CoreException if project is not valid Autotools project or cfgId does not exist
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public Map<String, IAutotoolsOption> getAutotoolCfgOptions(IProject project,
|
public Map<String, IAutotoolsOption> getAutotoolCfgOptions(IProject project, String cfgId) throws CoreException {
|
||||||
String cfgId) throws CoreException {
|
|
||||||
return AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(project, cfgId);
|
return AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(project, cfgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +208,8 @@ public class AutotoolsPlugin extends AbstractUIPlugin {
|
||||||
*
|
*
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public void updateAutotoolCfgOptions(IProject project, String cfgId,
|
public void updateAutotoolCfgOptions(IProject project, String cfgId, Map<String, IAutotoolsOption> options)
|
||||||
Map<String,IAutotoolsOption> options) throws CoreException {
|
throws CoreException {
|
||||||
AutotoolsConfigurationManager.getInstance().updateAutotoolCfgOptions(project, cfgId, options);
|
AutotoolsConfigurationManager.getInstance().updateAutotoolCfgOptions(project, cfgId, options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.autotools.core;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
|
||||||
public static final String BUILDER_ID = AutotoolsPlugin.getPluginId() + "." + BUILDER_NAME; //$NON-NLS-1$
|
public static final String BUILDER_ID = AutotoolsPlugin.getPluginId() + "." + BUILDER_NAME; //$NON-NLS-1$
|
||||||
public static final String OLD_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.core.genmakebuilderV2"; //$NON-NLS-1$
|
public static final String OLD_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.core.genmakebuilderV2"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String BUILD_STOPPED="AutotoolsMakefileBuilder.message.stopped"; //$NON-NLS-1$
|
private static final String BUILD_STOPPED = "AutotoolsMakefileBuilder.message.stopped"; //$NON-NLS-1$
|
||||||
private AutotoolsNewMakeGenerator generator;
|
private AutotoolsNewMakeGenerator generator;
|
||||||
|
|
||||||
public AutotoolsConfigurationBuilder() {
|
public AutotoolsConfigurationBuilder() {
|
||||||
|
@ -51,16 +51,15 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
|
||||||
generator = new AutotoolsNewMakeGenerator();
|
generator = new AutotoolsNewMakeGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isCdtProjectCreated(IProject project){
|
protected boolean isCdtProjectCreated(IProject project) {
|
||||||
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false);
|
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false);
|
||||||
return des != null && !des.isCdtProjectCreating();
|
return des != null && !des.isCdtProjectCreating();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor)
|
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
|
||||||
throws CoreException {
|
|
||||||
IProject project = getProject();
|
IProject project = getProject();
|
||||||
if(!isCdtProjectCreated(project))
|
if (!isCdtProjectCreated(project))
|
||||||
return project.getReferencedProjects();
|
return project.getReferencedProjects();
|
||||||
|
|
||||||
boolean bPerformBuild = true;
|
boolean bPerformBuild = true;
|
||||||
|
@ -118,14 +117,16 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
|
||||||
if (shouldBuild(CLEAN_BUILD, info)) {
|
if (shouldBuild(CLEAN_BUILD, info)) {
|
||||||
IConfiguration icfg = info.getDefaultConfiguration();
|
IConfiguration icfg = info.getDefaultConfiguration();
|
||||||
if (icfg instanceof IMultiConfiguration) {
|
if (icfg instanceof IMultiConfiguration) {
|
||||||
IMultiConfiguration mcfg = (IMultiConfiguration)icfg;
|
IMultiConfiguration mcfg = (IMultiConfiguration) icfg;
|
||||||
IConfiguration[] cfgs = (IConfiguration[])mcfg.getItems();
|
IConfiguration[] cfgs = (IConfiguration[]) mcfg.getItems();
|
||||||
for (int i = 0; i < cfgs.length; ++i) {
|
for (int i = 0; i < cfgs.length; ++i) {
|
||||||
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, icfg.getName());
|
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project,
|
||||||
|
icfg.getName());
|
||||||
cfg.setDirty(true);
|
cfg.setDirty(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, icfg.getName());
|
IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project,
|
||||||
|
icfg.getName());
|
||||||
cfg.setDirty(true); // Mark Configuration dirty so next build will do full reconfigure
|
cfg.setDirty(true); // Mark Configuration dirty so next build will do full reconfigure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,8 +141,7 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
|
||||||
result = generator.regenerateMakefiles(false);
|
result = generator.regenerateMakefiles(false);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
String errMsg = AutotoolsPlugin.getResourceString("MakeGenerator.didnt.generate"); //$NON-NLS-1$
|
String errMsg = AutotoolsPlugin.getResourceString("MakeGenerator.didnt.generate"); //$NON-NLS-1$
|
||||||
result = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR,
|
result = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, errMsg, e);
|
||||||
errMsg, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -161,12 +161,12 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
|
||||||
if (cfg != null) {
|
if (cfg != null) {
|
||||||
builder = cfg.getEditableBuilder();
|
builder = cfg.getEditableBuilder();
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case IncrementalProjectBuilder.AUTO_BUILD :
|
case IncrementalProjectBuilder.AUTO_BUILD:
|
||||||
return builder.isAutoBuildEnable();
|
return builder.isAutoBuildEnable();
|
||||||
case IncrementalProjectBuilder.INCREMENTAL_BUILD : // now treated as the same!
|
case IncrementalProjectBuilder.INCREMENTAL_BUILD: // now treated as the same!
|
||||||
case IncrementalProjectBuilder.FULL_BUILD :
|
case IncrementalProjectBuilder.FULL_BUILD:
|
||||||
return builder.isFullBuildEnabled() | builder.isIncrementalBuildEnabled() ;
|
return builder.isFullBuildEnabled() | builder.isIncrementalBuildEnabled();
|
||||||
case IncrementalProjectBuilder.CLEAN_BUILD :
|
case IncrementalProjectBuilder.CLEAN_BUILD:
|
||||||
return builder.isCleanBuildEnabled();
|
return builder.isCleanBuildEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,4 +174,3 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,14 @@ public class AutotoolsEnvironmentVariableSupplier implements IConfigurationEnvir
|
||||||
|
|
||||||
private static boolean isVar(String name) {
|
private static boolean isVar(String name) {
|
||||||
// Windows has case insensitive env var names
|
// Windows has case insensitive env var names
|
||||||
return Platform.getOS().equals(Platform.OS_WIN32) ? name.equalsIgnoreCase(VerboseEnvironmentVariable.VERBOSE_VAR_NAME)
|
return Platform.getOS().equals(Platform.OS_WIN32)
|
||||||
|
? name.equalsIgnoreCase(VerboseEnvironmentVariable.VERBOSE_VAR_NAME)
|
||||||
: name.equals(VerboseEnvironmentVariable.VERBOSE_VAR_NAME);
|
: name.equals(VerboseEnvironmentVariable.VERBOSE_VAR_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBuildEnvironmentVariable create() {
|
private static IBuildEnvironmentVariable create() {
|
||||||
return new VerboseEnvironmentVariable(VERBOSE_VAR_NAME, VERBOSE_VAR_VALUE, IEnvironmentVariable.ENVVAR_PREPEND, null);
|
return new VerboseEnvironmentVariable(VERBOSE_VAR_NAME, VERBOSE_VAR_VALUE,
|
||||||
|
IEnvironmentVariable.ENVVAR_PREPEND, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,6 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
|
|
||||||
public static final String RUN_IN_CONFIGURE_LAUNCHER = "org.eclipse.cdt.autotools.core.property.launchAutotoolsInContainer"; //$NON-NLS-1$
|
public static final String RUN_IN_CONFIGURE_LAUNCHER = "org.eclipse.cdt.autotools.core.property.launchAutotoolsInContainer"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
private IProject project;
|
private IProject project;
|
||||||
|
|
||||||
private IProgressMonitor monitor;
|
private IProgressMonitor monitor;
|
||||||
|
@ -140,8 +139,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
/**
|
/**
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public MultiStatus generateMakefiles()
|
public MultiStatus generateMakefiles() throws CoreException {
|
||||||
throws CoreException {
|
|
||||||
return regenerateMakefiles(false);
|
return regenerateMakefiles(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +162,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(IProject project, IManagedBuildInfo info,
|
public void initialize(IProject project, IManagedBuildInfo info, IProgressMonitor monitor) {
|
||||||
IProgressMonitor monitor) {
|
|
||||||
this.project = project;
|
this.project = project;
|
||||||
ICProjectDescription pdesc = CCorePlugin.getDefault().getProjectDescription(project);
|
ICProjectDescription pdesc = CCorePlugin.getDefault().getProjectDescription(project);
|
||||||
this.cdesc = pdesc.getActiveConfiguration();
|
this.cdesc = pdesc.getActiveConfiguration();
|
||||||
|
@ -267,7 +264,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh() throws CoreException{
|
private void refresh() throws CoreException {
|
||||||
IRemoteResource remRes = getProject().getAdapter(IRemoteResource.class);
|
IRemoteResource remRes = getProject().getAdapter(IRemoteResource.class);
|
||||||
if (remRes != null) {
|
if (remRes != null) {
|
||||||
remRes.refresh(SubMonitor.convert(monitor));
|
remRes.refresh(SubMonitor.convert(monitor));
|
||||||
|
@ -293,18 +290,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
public MultiStatus regenerateMakefiles(boolean reconfigure) throws CoreException {
|
public MultiStatus regenerateMakefiles(boolean reconfigure) throws CoreException {
|
||||||
MultiStatus status = null;
|
MultiStatus status = null;
|
||||||
if (cfg instanceof IMultiConfiguration) {
|
if (cfg instanceof IMultiConfiguration) {
|
||||||
IMultiConfiguration mfcg = (IMultiConfiguration)cfg;
|
IMultiConfiguration mfcg = (IMultiConfiguration) cfg;
|
||||||
Object[] objs = mfcg.getItems();
|
Object[] objs = mfcg.getItems();
|
||||||
for (int i = 0; i < objs.length; ++i) {
|
for (int i = 0; i < objs.length; ++i) {
|
||||||
IConfiguration icfg = (IConfiguration)objs[i];
|
IConfiguration icfg = (IConfiguration) objs[i];
|
||||||
Status rc = regenerateMakefiles(icfg, reconfigure);
|
Status rc = regenerateMakefiles(icfg, reconfigure);
|
||||||
if (!rc.isOK()) {
|
if (!rc.isOK()) {
|
||||||
if(status == null){
|
if (status == null) {
|
||||||
status = new MultiStatus(
|
status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, "", null);
|
||||||
AutotoolsPlugin.getUniqueIdentifier(),
|
|
||||||
IStatus.ERROR,
|
|
||||||
"",
|
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
status.add(rc);
|
status.add(rc);
|
||||||
}
|
}
|
||||||
|
@ -312,22 +305,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
} else {
|
} else {
|
||||||
Status rc = regenerateMakefiles(cfg, reconfigure);
|
Status rc = regenerateMakefiles(cfg, reconfigure);
|
||||||
if (!rc.isOK()) {
|
if (!rc.isOK()) {
|
||||||
if(status == null){
|
if (status == null) {
|
||||||
status = new MultiStatus(
|
status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, "", null);
|
||||||
AutotoolsPlugin.getUniqueIdentifier(),
|
|
||||||
IStatus.ERROR,
|
|
||||||
"",
|
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
status.add(rc);
|
status.add(rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(status == null){
|
if (status == null) {
|
||||||
status = new MultiStatus(
|
status = new MultiStatus(ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.OK, "", null);
|
||||||
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
|
||||||
IStatus.OK,
|
|
||||||
"",
|
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -357,14 +342,12 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the top-level directory for the build output
|
// Create the top-level directory for the build output
|
||||||
if (!createDirectory(buildDir)) {
|
if (!createDirectory(buildDir)) {
|
||||||
rc = IStatus.ERROR;
|
rc = IStatus.ERROR;
|
||||||
errMsg = AutotoolsPlugin.getFormattedString("MakeGenerator.createdir.error", //$NON-NLS-1$
|
errMsg = AutotoolsPlugin.getFormattedString("MakeGenerator.createdir.error", //$NON-NLS-1$
|
||||||
new String[] {buildDir});
|
new String[] { buildDir });
|
||||||
status = new MultiStatus(AutotoolsPlugin
|
status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), rc, errMsg, null);
|
||||||
.getUniqueIdentifier(), rc, errMsg, null);
|
|
||||||
}
|
}
|
||||||
checkCancel();
|
checkCancel();
|
||||||
|
|
||||||
|
@ -414,8 +397,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
}
|
}
|
||||||
makeargs[makeargs.length - 1] = target;
|
makeargs[makeargs.length - 1] = target;
|
||||||
rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd,
|
rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd,
|
||||||
getProjectLocation(),
|
getProjectLocation(), makeargs,
|
||||||
makeargs,
|
|
||||||
AutotoolsPlugin.getResourceString("MakeGenerator.clean.topdir"), //$NON-NLS-1$
|
AutotoolsPlugin.getResourceString("MakeGenerator.clean.topdir"), //$NON-NLS-1$
|
||||||
errMsg, console, consoleStart);
|
errMsg, console, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
|
@ -450,7 +432,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
IPath makeCmd = builder.getBuildCommand();
|
IPath makeCmd = builder.getBuildCommand();
|
||||||
String target = null;
|
String target = null;
|
||||||
try {
|
try {
|
||||||
target = getProject().getPersistentProperty(AutotoolsPropertyConstants.CLEAN_MAKE_TARGET);
|
target = getProject()
|
||||||
|
.getPersistentProperty(AutotoolsPropertyConstants.CLEAN_MAKE_TARGET);
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -464,9 +447,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
}
|
}
|
||||||
makeargs[makeargs.length - 1] = target;
|
makeargs[makeargs.length - 1] = target;
|
||||||
rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd,
|
rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd,
|
||||||
buildLocation,
|
buildLocation, makeargs,
|
||||||
makeargs,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.clean.builddir", //$NON-NLS-1$
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.clean.builddir", new String[]{buildDir}), //$NON-NLS-1$
|
new String[] { buildDir }),
|
||||||
errMsg, console, consoleStart);
|
errMsg, console, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
}
|
}
|
||||||
|
@ -495,17 +478,16 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
// created.
|
// created.
|
||||||
if (makefile == null || !makefile.exists()) {
|
if (makefile == null || !makefile.exists()) {
|
||||||
rc = runScript(configureLauncher, configfile, buildLocation, null,
|
rc = runScript(configureLauncher, configfile, buildLocation, null,
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.run.config.status", new String[]{buildDir}), //$NON-NLS-1$
|
AutotoolsPlugin.getFormattedString("MakeGenerator.run.config.status", //$NON-NLS-1$
|
||||||
|
new String[] { buildDir }),
|
||||||
errMsg, console, null, consoleStart);
|
errMsg, console, null, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Look for configure and configure from scratch
|
// Look for configure and configure from scratch
|
||||||
else if (configurePath.toFile().exists()) {
|
else if (configurePath.toFile().exists()) {
|
||||||
rc = runScript(configureLauncher, configurePath,
|
rc = runScript(configureLauncher, configurePath, buildLocation, configArgs,
|
||||||
buildLocation,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[] { buildDir }), //$NON-NLS-1$
|
||||||
configArgs,
|
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[]{buildDir}), //$NON-NLS-1$
|
|
||||||
errMsg, console, configureEnvs, consoleStart);
|
errMsg, console, configureEnvs, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
|
@ -527,7 +509,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
String[] autogenArgs = getAutogenArgs(autogenCmdParms);
|
String[] autogenArgs = getAutogenArgs(autogenCmdParms);
|
||||||
rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, autogenPath,
|
rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, autogenPath,
|
||||||
autogenPath.removeLastSegments(1), autogenArgs,
|
autogenPath.removeLastSegments(1), autogenArgs,
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.autogen.sh", new String[]{buildDir}), //$NON-NLS-1$
|
AutotoolsPlugin.getFormattedString("MakeGenerator.autogen.sh", new String[] { buildDir }), //$NON-NLS-1$
|
||||||
errMsg, console, autogenEnvs, consoleStart);
|
errMsg, console, autogenEnvs, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
|
@ -543,25 +525,25 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
if (!configurePath.toFile().exists()) {
|
if (!configurePath.toFile().exists()) {
|
||||||
// no configure script either...try running autoreconf
|
// no configure script either...try running autoreconf
|
||||||
String[] reconfArgs = new String[1];
|
String[] reconfArgs = new String[1];
|
||||||
String reconfCmd = project.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL);
|
String reconfCmd = project
|
||||||
|
.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL);
|
||||||
if (reconfCmd == null)
|
if (reconfCmd == null)
|
||||||
reconfCmd = DEFAULT_AUTORECONF;
|
reconfCmd = DEFAULT_AUTORECONF;
|
||||||
IPath reconfCmdPath = new Path(reconfCmd);
|
IPath reconfCmdPath = new Path(reconfCmd);
|
||||||
reconfArgs[0] = "-i"; //$NON-NLS-1$
|
reconfArgs[0] = "-i"; //$NON-NLS-1$
|
||||||
rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath,
|
rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath,
|
||||||
getSourcePath(),
|
getSourcePath(), reconfArgs,
|
||||||
reconfArgs,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", //$NON-NLS-1$
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$
|
new String[] { buildDir }),
|
||||||
errMsg, console, null, consoleStart);
|
errMsg, console, null, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
// Check if configure generated and if yes, run it.
|
// Check if configure generated and if yes, run it.
|
||||||
if (rc != IStatus.ERROR && configurePath.toFile().exists()) {
|
if (rc != IStatus.ERROR && configurePath.toFile().exists()) {
|
||||||
rc = runScript(configureLauncher, configurePath,
|
rc = runScript(configureLauncher, configurePath, buildLocation, configArgs,
|
||||||
buildLocation,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$
|
||||||
configArgs,
|
new String[] { buildDir }),
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[]{buildDir}), //$NON-NLS-1$
|
|
||||||
errMsg, console, configureEnvs, false);
|
errMsg, console, configureEnvs, false);
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
File makefileFile = buildLocation.append(MAKEFILE).toFile();
|
File makefileFile = buildLocation.append(MAKEFILE).toFile();
|
||||||
|
@ -582,9 +564,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
IPath makeCmd = builder.getBuildCommand();
|
IPath makeCmd = builder.getBuildCommand();
|
||||||
makeargs[0] = "-f" + getMakefileCVSPath().toOSString(); //$NON-NLS-1$
|
makeargs[0] = "-f" + getMakefileCVSPath().toOSString(); //$NON-NLS-1$
|
||||||
rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd,
|
rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd,
|
||||||
getProjectLocation().append(buildDir),
|
getProjectLocation().append(buildDir), makeargs,
|
||||||
makeargs,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[] { buildDir }), //$NON-NLS-1$
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[]{buildDir}), //$NON-NLS-1$
|
|
||||||
errMsg, console, consoleStart);
|
errMsg, console, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
|
@ -596,7 +577,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
.equals(configureLauncher.getClass().getName())) {
|
.equals(configureLauncher.getClass().getName())) {
|
||||||
rc = runScript(configureLauncher, configurePath, buildLocation, configArgs,
|
rc = runScript(configureLauncher, configurePath, buildLocation, configArgs,
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$
|
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$
|
||||||
new String[] { buildDir }), errMsg, console, configureEnvs, false);
|
new String[] { buildDir }),
|
||||||
|
errMsg, console, configureEnvs, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
|
@ -614,19 +596,17 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
IPath reconfCmdPath = new Path(reconfCmd);
|
IPath reconfCmdPath = new Path(reconfCmd);
|
||||||
reconfArgs[0] = "-i"; //$NON-NLS-1$
|
reconfArgs[0] = "-i"; //$NON-NLS-1$
|
||||||
rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath,
|
rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath,
|
||||||
getSourcePath(),
|
getSourcePath(), reconfArgs,
|
||||||
reconfArgs,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[] { buildDir }), //$NON-NLS-1$
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$
|
|
||||||
errMsg, console, null, consoleStart);
|
errMsg, console, null, consoleStart);
|
||||||
consoleStart = false;
|
consoleStart = false;
|
||||||
// Check if configure generated and if yes, run it.
|
// Check if configure generated and if yes, run it.
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
refresh();
|
refresh();
|
||||||
if (configurePath.toFile().exists()) {
|
if (configurePath.toFile().exists()) {
|
||||||
rc = runScript(configureLauncher, configurePath,
|
rc = runScript(configureLauncher, configurePath, buildLocation, configArgs,
|
||||||
buildLocation,
|
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$
|
||||||
configArgs,
|
new String[] { buildDir }),
|
||||||
AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[]{buildDir}), //$NON-NLS-1$
|
|
||||||
errMsg, console, configureEnvs, false);
|
errMsg, console, configureEnvs, false);
|
||||||
if (rc != IStatus.ERROR) {
|
if (rc != IStatus.ERROR) {
|
||||||
File makefileFile = buildLocation.append(MAKEFILE).toFile();
|
File makefileFile = buildLocation.append(MAKEFILE).toFile();
|
||||||
|
@ -649,15 +629,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
rc = IStatus.ERROR;
|
rc = IStatus.ERROR;
|
||||||
} finally {
|
} finally {
|
||||||
// getGenerationProblems().clear();
|
// getGenerationProblems().clear();
|
||||||
status = new MultiStatus(AutotoolsPlugin
|
status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), rc, errMsg, null);
|
||||||
.getUniqueIdentifier(), rc, errMsg, null);
|
|
||||||
if (rc != IStatus.OK)
|
if (rc != IStatus.OK)
|
||||||
status.add(new Status (
|
status.add(new Status(rc, AutotoolsPlugin.getUniqueIdentifier(), 0, errMsg, null));
|
||||||
rc,
|
|
||||||
AutotoolsPlugin.getUniqueIdentifier(),
|
|
||||||
0,
|
|
||||||
errMsg,
|
|
||||||
null));
|
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -681,7 +655,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
Matcher m1 = p1.matcher(command);
|
Matcher m1 = p1.matcher(command);
|
||||||
if (m1.matches()) {
|
if (m1.matches()) {
|
||||||
command = command.replaceFirst("\\w+[=]\\\".*?\\\"","").trim();
|
command = command.replaceFirst("\\w+[=]\\\".*?\\\"", "").trim();
|
||||||
String s = m1.group(1).trim();
|
String s = m1.group(1).trim();
|
||||||
envVars.add(s.replaceAll("\\\"", ""));
|
envVars.add(s.replaceAll("\\\"", ""));
|
||||||
} else {
|
} else {
|
||||||
|
@ -698,7 +672,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
} else {
|
} else {
|
||||||
Matcher m4 = p4.matcher(command);
|
Matcher m4 = p4.matcher(command);
|
||||||
if (m4.matches()) {
|
if (m4.matches()) {
|
||||||
command = command.replaceFirst("\\w+[=]\\\".*?\\\"","").trim();
|
command = command.replaceFirst("\\w+[=]\\\".*?\\\"", "").trim();
|
||||||
String s = m4.group(1).trim();
|
String s = m4.group(1).trim();
|
||||||
envVars.add(s.replaceAll("\\\"", ""));
|
envVars.add(s.replaceAll("\\\"", ""));
|
||||||
} else {
|
} else {
|
||||||
|
@ -740,7 +714,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
Matcher m1 = p1.matcher(str);
|
Matcher m1 = p1.matcher(str);
|
||||||
if (m1.matches()) {
|
if (m1.matches()) {
|
||||||
str = str.replaceFirst("\\w+[=]\\\".*?\\\"","").trim();
|
str = str.replaceFirst("\\w+[=]\\\".*?\\\"", "").trim();
|
||||||
String s = m1.group(1).trim();
|
String s = m1.group(1).trim();
|
||||||
envVars.add(s.replaceAll("\\\"", ""));
|
envVars.add(s.replaceAll("\\\"", ""));
|
||||||
} else {
|
} else {
|
||||||
|
@ -767,11 +741,11 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
return project.getLocation();
|
return project.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath getBuildPath(){
|
private IPath getBuildPath() {
|
||||||
return new Path(this.buildDir);
|
return new Path(this.buildDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath getSourcePath(){
|
private IPath getSourcePath() {
|
||||||
IPath sourcePath;
|
IPath sourcePath;
|
||||||
if (srcDir.isEmpty())
|
if (srcDir.isEmpty())
|
||||||
sourcePath = getProjectLocation();
|
sourcePath = getProjectLocation();
|
||||||
|
@ -851,8 +825,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
|
|
||||||
// Run a command or executable (e.g. make).
|
// Run a command or executable (e.g. make).
|
||||||
private int runCommand(ICommandLauncher commandLauncher, IPath commandPath, IPath runPath, String[] args,
|
private int runCommand(ICommandLauncher commandLauncher, IPath commandPath, IPath runPath, String[] args,
|
||||||
String jobDescription, String errMsg,
|
String jobDescription, String errMsg, IConsole console, boolean consoleStart)
|
||||||
IConsole console, boolean consoleStart) throws CoreException, NullPointerException, IOException {
|
throws CoreException, NullPointerException, IOException {
|
||||||
|
|
||||||
int rc = IStatus.OK;
|
int rc = IStatus.OK;
|
||||||
|
|
||||||
|
@ -864,14 +838,11 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
|
|
||||||
for (int i = 0; i < configTargets.length; ++i) {
|
for (int i = 0; i < configTargets.length; ++i) {
|
||||||
// try to resolve the build macros in any argument
|
// try to resolve the build macros in any argument
|
||||||
try{
|
try {
|
||||||
String resolved =
|
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
|
||||||
ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
|
configTargets[i], "", //$NON-NLS-1$
|
||||||
configTargets[i],
|
|
||||||
"", //$NON-NLS-1$
|
|
||||||
" ", //$NON-NLS-1$
|
" ", //$NON-NLS-1$
|
||||||
IBuildMacroProvider.CONTEXT_CONFIGURATION,
|
IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);
|
||||||
cfg);
|
|
||||||
configTargets[i] = resolved;
|
configTargets[i] = resolved;
|
||||||
} catch (BuildMacroException e) {
|
} catch (BuildMacroException e) {
|
||||||
}
|
}
|
||||||
|
@ -880,9 +851,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
String[] msgs = new String[2];
|
String[] msgs = new String[2];
|
||||||
msgs[0] = commandPath.toString();
|
msgs[0] = commandPath.toString();
|
||||||
msgs[1] = project.getName();
|
msgs[1] = project.getName();
|
||||||
monitor.subTask(AutotoolsPlugin.getFormattedString(
|
monitor.subTask(AutotoolsPlugin.getFormattedString("MakeGenerator.make.message", msgs)); //$NON-NLS-1$
|
||||||
"MakeGenerator.make.message", msgs)); //$NON-NLS-1$
|
|
||||||
|
|
||||||
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
|
@ -908,14 +877,13 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
ICommandLauncher launcher = new RemoteCommandLauncher(commandLauncher);
|
ICommandLauncher launcher = new RemoteCommandLauncher(commandLauncher);
|
||||||
launcher.setProject(project);
|
launcher.setProject(project);
|
||||||
// Set the environment
|
// Set the environment
|
||||||
IEnvironmentVariable variables[] =
|
IEnvironmentVariable variables[] = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc,
|
||||||
CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true);
|
true);
|
||||||
String[] env = null;
|
String[] env = null;
|
||||||
ArrayList<String> envList = new ArrayList<>();
|
ArrayList<String> envList = new ArrayList<>();
|
||||||
if (variables != null) {
|
if (variables != null) {
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (int i = 0; i < variables.length; i++) {
|
||||||
envList.add(variables[i].getName()
|
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
|
||||||
+ "=" + variables[i].getValue()); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
env = envList.toArray(new String[envList.size()]);
|
env = envList.toArray(new String[envList.size()]);
|
||||||
}
|
}
|
||||||
|
@ -1038,24 +1006,19 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
// Fix Bug 423192 - use environment variables when checking the Win OS Type using
|
// Fix Bug 423192 - use environment variables when checking the Win OS Type using
|
||||||
// a shell command as the path to sh may be specified there
|
// a shell command as the path to sh may be specified there
|
||||||
IEnvironmentVariable variables[] =
|
IEnvironmentVariable variables[] = CCorePlugin.getDefault().getBuildEnvironmentManager()
|
||||||
CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true);
|
.getVariables(cdesc, true);
|
||||||
String[] env = new String[0];
|
String[] env = new String[0];
|
||||||
ArrayList<String> envList = new ArrayList<>();
|
ArrayList<String> envList = new ArrayList<>();
|
||||||
if (variables != null) {
|
if (variables != null) {
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (int i = 0; i < variables.length; i++) {
|
||||||
envList.add(variables[i].getName()
|
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
|
||||||
+ "=" + variables[i].getValue()); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
env = envList.toArray(new String[envList.size()]);
|
env = envList.toArray(new String[envList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
launcher.execute(
|
launcher.execute(new Path(SHELL_COMMAND), new String[] { "-c", "echo $OSTYPE" }, //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new Path(SHELL_COMMAND), //$NON-NLS-1$
|
env, buildLocation, SubMonitor.convert(monitor));
|
||||||
new String[] { "-c", "echo $OSTYPE" }, //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
env,
|
|
||||||
buildLocation,
|
|
||||||
SubMonitor.convert(monitor));
|
|
||||||
if (launcher.waitAndRead(out, out) == ICommandLauncher.OK)
|
if (launcher.waitAndRead(out, out) == ICommandLauncher.OK)
|
||||||
winOSType = out.toString().trim();
|
winOSType = out.toString().trim();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -1118,8 +1081,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
|
|
||||||
// Run an autotools script (e.g. configure, autogen.sh, config.status).
|
// Run an autotools script (e.g. configure, autogen.sh, config.status).
|
||||||
private int runScript(ICommandLauncher commandLauncher, IPath commandPath, IPath runPath, String[] args,
|
private int runScript(ICommandLauncher commandLauncher, IPath commandPath, IPath runPath, String[] args,
|
||||||
String jobDescription, String errMsg,
|
String jobDescription, String errMsg, IConsole console, List<String> additionalEnvs, boolean consoleStart)
|
||||||
IConsole console, List<String> additionalEnvs, boolean consoleStart)
|
|
||||||
throws CoreException, NullPointerException, IOException {
|
throws CoreException, NullPointerException, IOException {
|
||||||
|
|
||||||
int rc = IStatus.OK;
|
int rc = IStatus.OK;
|
||||||
|
@ -1134,15 +1096,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
if (args == null)
|
if (args == null)
|
||||||
configTargets = new String[1];
|
configTargets = new String[1];
|
||||||
else {
|
else {
|
||||||
configTargets = new String[args.length+1];
|
configTargets = new String[args.length + 1];
|
||||||
System.arraycopy(args, 0, configTargets, 1, args.length);
|
System.arraycopy(args, 0, configTargets, 1, args.length);
|
||||||
}
|
}
|
||||||
configTargets[0] = getPathString(commandPath);
|
configTargets[0] = getPathString(commandPath);
|
||||||
|
|
||||||
// Fix for bug #343879
|
// Fix for bug #343879
|
||||||
String osName = getOSName();
|
String osName = getOSName();
|
||||||
if (osName.equals(Platform.OS_WIN32)
|
if (osName.equals(Platform.OS_WIN32) || osName.equals(Platform.OS_MACOSX))
|
||||||
|| osName.equals(Platform.OS_MACOSX))
|
|
||||||
removePWD = true;
|
removePWD = true;
|
||||||
|
|
||||||
// Fix for bug #343731 and bug #371277
|
// Fix for bug #343731 and bug #371277
|
||||||
|
@ -1161,14 +1122,11 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
|
|
||||||
for (int i = 0; i < configTargets.length; ++i) {
|
for (int i = 0; i < configTargets.length; ++i) {
|
||||||
// try to resolve the build macros in any argument
|
// try to resolve the build macros in any argument
|
||||||
try{
|
try {
|
||||||
String resolved =
|
String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
|
||||||
ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
|
configTargets[i], "", //$NON-NLS-1$
|
||||||
configTargets[i],
|
|
||||||
"", //$NON-NLS-1$
|
|
||||||
" ", //$NON-NLS-1$
|
" ", //$NON-NLS-1$
|
||||||
IBuildMacroProvider.CONTEXT_CONFIGURATION,
|
IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg);
|
||||||
cfg);
|
|
||||||
// strip any env-var settings from options
|
// strip any env-var settings from options
|
||||||
// fix for bug #356278
|
// fix for bug #356278
|
||||||
if (resolved.length() > 0 && resolved.charAt(0) != '-')
|
if (resolved.length() > 0 && resolved.charAt(0) != '-')
|
||||||
|
@ -1181,9 +1139,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
String[] msgs = new String[2];
|
String[] msgs = new String[2];
|
||||||
msgs[0] = commandPath.toString();
|
msgs[0] = commandPath.toString();
|
||||||
msgs[1] = project.getName();
|
msgs[1] = project.getName();
|
||||||
monitor.subTask(AutotoolsPlugin.getFormattedString(
|
monitor.subTask(AutotoolsPlugin.getFormattedString("MakeGenerator.make.message", msgs)); //$NON-NLS-1$
|
||||||
"MakeGenerator.make.message", msgs)); //$NON-NLS-1$
|
|
||||||
|
|
||||||
|
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
|
@ -1205,13 +1161,12 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
// Display command-line environment variables that have been stripped by us
|
// Display command-line environment variables that have been stripped by us
|
||||||
// because launch showCommand won't do this.
|
// because launch showCommand won't do this.
|
||||||
if (additionalEnvs != null && additionalEnvs.size() > 0) {
|
if (additionalEnvs != null && additionalEnvs.size() > 0) {
|
||||||
buf.append(AutotoolsPlugin
|
buf.append(AutotoolsPlugin.getResourceString("MakeGenerator.commandline.envvars"));
|
||||||
.getResourceString("MakeGenerator.commandline.envvars"));
|
|
||||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
buf.append("\t");
|
buf.append("\t");
|
||||||
for (int i = 0; i < additionalEnvs.size(); ++i) {
|
for (int i = 0; i < additionalEnvs.size(); ++i) {
|
||||||
String envvar = additionalEnvs.get(i);
|
String envvar = additionalEnvs.get(i);
|
||||||
buf.append(envvar.replaceFirst("(\\w+=)(.*)"," $1\"$2\""));
|
buf.append(envvar.replaceFirst("(\\w+=)(.*)", " $1\"$2\""));
|
||||||
}
|
}
|
||||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -1223,8 +1178,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
ICommandLauncher launcher = new RemoteCommandLauncher(commandLauncher);
|
ICommandLauncher launcher = new RemoteCommandLauncher(commandLauncher);
|
||||||
launcher.setProject(project);
|
launcher.setProject(project);
|
||||||
// Set the environment
|
// Set the environment
|
||||||
IEnvironmentVariable variables[] =
|
IEnvironmentVariable variables[] = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc,
|
||||||
CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true);
|
true);
|
||||||
String[] env = null;
|
String[] env = null;
|
||||||
ArrayList<String> envList = new ArrayList<>();
|
ArrayList<String> envList = new ArrayList<>();
|
||||||
if (variables != null) {
|
if (variables != null) {
|
||||||
|
@ -1240,11 +1195,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
// configure to try and link a file to itself (e.g. projects with a GnuMakefile) and
|
// configure to try and link a file to itself (e.g. projects with a GnuMakefile) and
|
||||||
// obliterate the contents. Thus, we remove the trailing separator to be safe.
|
// obliterate the contents. Thus, we remove the trailing separator to be safe.
|
||||||
if (variables[i].getName().equals("PWD")) { //$NON-NLS-1$
|
if (variables[i].getName().equals("PWD")) { //$NON-NLS-1$
|
||||||
if (value.charAt(value.length()-1) == IPath.SEPARATOR)
|
if (value.charAt(value.length() - 1) == IPath.SEPARATOR)
|
||||||
value = value.substring(0, value.length() - 1);
|
value = value.substring(0, value.length() - 1);
|
||||||
}
|
}
|
||||||
envList.add(variables[i].getName()
|
envList.add(variables[i].getName() + "=" + value); //$NON-NLS-1$
|
||||||
+ "=" + value); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (additionalEnvs != null)
|
if (additionalEnvs != null)
|
||||||
|
@ -1369,10 +1323,11 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
targetElem.setAttribute(TARGET_ATTR_ID, target.getTargetBuilderID());
|
targetElem.setAttribute(TARGET_ATTR_ID, target.getTargetBuilderID());
|
||||||
targetElem.setAttribute(TARGET_ATTR_PATH, target.getContainer().getProjectRelativePath().toString());
|
targetElem.setAttribute(TARGET_ATTR_PATH, target.getContainer().getProjectRelativePath().toString());
|
||||||
ICStorageElement elem = targetElem.createChild(TARGET_COMMAND);
|
ICStorageElement elem = targetElem.createChild(TARGET_COMMAND);
|
||||||
elem.setValue(target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, builder.getBuildCommand().toOSString()));
|
elem.setValue(
|
||||||
|
target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, builder.getBuildCommand().toOSString()));
|
||||||
|
|
||||||
String targetAttr = target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
|
String targetAttr = target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
|
||||||
if ( targetAttr != null) {
|
if (targetAttr != null) {
|
||||||
elem = targetElem.createChild(TARGET_ARGUMENTS);
|
elem = targetElem.createChild(TARGET_ARGUMENTS);
|
||||||
elem.setValue(targetAttr);
|
elem.setValue(targetAttr);
|
||||||
}
|
}
|
||||||
|
@ -1421,8 +1376,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
protected static class MakeTargetComparator implements Comparator<Object> {
|
protected static class MakeTargetComparator implements Comparator<Object> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Object a, Object b) {
|
public int compare(Object a, Object b) {
|
||||||
IMakeTarget make1 = (IMakeTarget)a;
|
IMakeTarget make1 = (IMakeTarget) a;
|
||||||
IMakeTarget make2 = (IMakeTarget)b;
|
IMakeTarget make2 = (IMakeTarget) b;
|
||||||
return make1.getName().compareToIgnoreCase(make2.getName());
|
return make1.getName().compareToIgnoreCase(make2.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1446,8 +1401,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
String statusMsg = AutotoolsPlugin.getResourceString("MakeGenerator.refresh.MakeTargets"); //$NON-NLS-1$
|
String statusMsg = AutotoolsPlugin.getResourceString("MakeGenerator.refresh.MakeTargets"); //$NON-NLS-1$
|
||||||
monitor.subTask(statusMsg);
|
monitor.subTask(statusMsg);
|
||||||
|
|
||||||
IMakeTargetManager makeTargetManager =
|
IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager();
|
||||||
MakeCorePlugin.getDefault().getTargetManager();
|
|
||||||
|
|
||||||
IMakefile makefile = MakeCorePlugin.createMakefile(makefileFile.toURI(), false, null);
|
IMakefile makefile = MakeCorePlugin.createMakefile(makefileFile.toURI(), false, null);
|
||||||
ITargetRule[] targets = makefile.getTargetRules();
|
ITargetRule[] targets = makefile.getTargetRules();
|
||||||
|
@ -1473,9 +1427,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
// create and thus avoid an extraneous event notification on a change to
|
// create and thus avoid an extraneous event notification on a change to
|
||||||
// the MakeTarget. The dummy target should have an invalid name for
|
// the MakeTarget. The dummy target should have an invalid name for
|
||||||
// a normal make target.
|
// a normal make target.
|
||||||
IMakeTarget dummyTarget = makeTargetManager.createTarget(
|
IMakeTarget dummyTarget = makeTargetManager.createTarget(project, "\ndummyTarget\n", targetBuildID); //$NON-NLS-1$
|
||||||
project, "\ndummyTarget\n", targetBuildID); //$NON-NLS-1$
|
makeTargetManager.setTargets(project, new IMakeTarget[] { dummyTarget });
|
||||||
makeTargetManager.setTargets(project, new IMakeTarget[]{dummyTarget});
|
|
||||||
|
|
||||||
for (int i = 0; i < targets.length; i++) {
|
for (int i = 0; i < targets.length; i++) {
|
||||||
target = targets[i].getTarget();
|
target = targets[i].getTarget();
|
||||||
|
@ -1487,8 +1440,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
// existing MakeTarget will cause events to occur on every
|
// existing MakeTarget will cause events to occur on every
|
||||||
// modification whereas a new MakeTarget not yet added will
|
// modification whereas a new MakeTarget not yet added will
|
||||||
// not cause this delay.
|
// not cause this delay.
|
||||||
IMakeTarget makeTarget = makeTargetManager.createTarget(
|
IMakeTarget makeTarget = makeTargetManager.createTarget(project, targetName, targetBuildID);
|
||||||
project, targetName, targetBuildID);
|
|
||||||
makeTarget.setContainer(project);
|
makeTarget.setContainer(project);
|
||||||
makeTarget.setStopOnError(isStopOnError);
|
makeTarget.setStopOnError(isStopOnError);
|
||||||
makeTarget.setRunAllBuilders(false);
|
makeTarget.setRunAllBuilders(false);
|
||||||
|
@ -1497,12 +1449,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, defaultBuildCommand);
|
makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, defaultBuildCommand);
|
||||||
|
|
||||||
makeTarget.setBuildAttribute(GENERATED_TARGET, "true"); //$NON-NLS-1$
|
makeTarget.setBuildAttribute(GENERATED_TARGET, "true"); //$NON-NLS-1$
|
||||||
makeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET,
|
makeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, targetName);
|
||||||
targetName);
|
|
||||||
|
|
||||||
//TODO: should this be raw build directory in macro form?
|
//TODO: should this be raw build directory in macro form?
|
||||||
makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION,
|
makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, buildDir);
|
||||||
buildDir);
|
|
||||||
makeTargets.put(makeTarget.getName(), makeTarget);
|
makeTargets.put(makeTarget.getName(), makeTarget);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// Duplicate target. Ignore.
|
// Duplicate target. Ignore.
|
||||||
|
@ -1539,8 +1489,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
return !(targetName.endsWith("-am") //$NON-NLS-1$
|
return !(targetName.endsWith("-am") //$NON-NLS-1$
|
||||||
|| targetName.endsWith("PROGRAMS") //$NON-NLS-1$
|
|| targetName.endsWith("PROGRAMS") //$NON-NLS-1$
|
||||||
|| targetName.endsWith("-generic") //$NON-NLS-1$
|
|| targetName.endsWith("-generic") //$NON-NLS-1$
|
||||||
|| (targetName.indexOf('$') >= 0)
|
|| (targetName.indexOf('$') >= 0) || (targetName.charAt(0) == '.')
|
||||||
|| (targetName.charAt(0) == '.')
|
|
||||||
|| targetName.equals(targetName.toUpperCase()));
|
|| targetName.equals(targetName.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1563,9 +1512,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c == ' ' && !inComment) {
|
if (c == ' ' && !inComment) {
|
||||||
if (buffer.length() > 0){
|
if (buffer.length() > 0) {
|
||||||
String str = buffer.toString().trim();
|
String str = buffer.toString().trim();
|
||||||
if(str.length() > 0){
|
if (str.length() > 0) {
|
||||||
aList.add(str);
|
aList.add(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1575,9 +1524,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
|
||||||
buffer.append(c);
|
buffer.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buffer.length() > 0){
|
if (buffer.length() > 0) {
|
||||||
String str = buffer.toString().trim();
|
String str = buffer.toString().trim();
|
||||||
if(str.length() > 0){
|
if (str.length() > 0) {
|
||||||
aList.add(str);
|
aList.add(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,12 @@ import org.eclipse.core.runtime.IPath;
|
||||||
*/
|
*/
|
||||||
public class AutotoolsProblemMarkerInfo {
|
public class AutotoolsProblemMarkerInfo {
|
||||||
|
|
||||||
public static enum Type{
|
public static enum Type {
|
||||||
PACKAGE,
|
PACKAGE, HEADER, PROG,
|
||||||
HEADER,
|
|
||||||
PROG,
|
|
||||||
/**
|
/**
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
LIB,
|
LIB, FILE, GENERIC
|
||||||
FILE,
|
|
||||||
GENERIC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProblemMarkerInfo marker;
|
private ProblemMarkerInfo marker;
|
||||||
|
@ -42,18 +38,19 @@ public class AutotoolsProblemMarkerInfo {
|
||||||
this(file, -1, description, severity, null, null, name, type);
|
this(file, -1, description, severity, null, null, name, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName, Type type) {
|
public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity,
|
||||||
|
String variableName, Type type) {
|
||||||
this(file, lineNumber, description, severity, variableName, null, null, type);
|
this(file, lineNumber, description, severity, variableName, null, null, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName,
|
public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity,
|
||||||
IPath externalPath, String libraryInfo, Type type) {
|
String variableName, IPath externalPath, String libraryInfo, Type type) {
|
||||||
this.marker = new ProblemMarkerInfo(file, lineNumber, description, severity, variableName, externalPath);
|
this.marker = new ProblemMarkerInfo(file, lineNumber, description, severity, variableName, externalPath);
|
||||||
|
|
||||||
marker.setAttribute(IAutotoolsMarker.MARKER_PROBLEM_TYPE, type.name());
|
marker.setAttribute(IAutotoolsMarker.MARKER_PROBLEM_TYPE, type.name());
|
||||||
marker.setAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, libraryInfo);
|
marker.setAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, libraryInfo);
|
||||||
|
|
||||||
marker.setType (IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER);
|
marker.setType(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProblemMarkerInfo getMarker() {
|
public ProblemMarkerInfo getMarker() {
|
||||||
|
@ -64,7 +61,7 @@ public class AutotoolsProblemMarkerInfo {
|
||||||
return marker.getAttribute(IAutotoolsMarker.MARKER_PROBLEM_TYPE);
|
return marker.getAttribute(IAutotoolsMarker.MARKER_PROBLEM_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLibraryInfo(){
|
public String getLibraryInfo() {
|
||||||
return marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO);
|
return marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,17 +16,18 @@ package org.eclipse.cdt.internal.autotools.core;
|
||||||
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
|
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
|
|
||||||
public class AutotoolsPropertyConstants {
|
public class AutotoolsPropertyConstants {
|
||||||
|
|
||||||
static final String PREFIX = AutotoolsPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
|
static final String PREFIX = AutotoolsPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$
|
||||||
static final String PREFIX_COMPAT = "org.eclipse.linuxtools.cdt.autotools."; //$NON-NLS-1$
|
static final String PREFIX_COMPAT = "org.eclipse.linuxtools.cdt.autotools."; //$NON-NLS-1$
|
||||||
public static final String AUTOMAKE_VERSION_STRING = "AutoconfEditorAutomakeVersion"; //$NON-NLS-1$
|
public static final String AUTOMAKE_VERSION_STRING = "AutoconfEditorAutomakeVersion"; //$NON-NLS-1$
|
||||||
public static final QualifiedName AUTOMAKE_VERSION = new QualifiedName(PREFIX, AUTOMAKE_VERSION_STRING);
|
public static final QualifiedName AUTOMAKE_VERSION = new QualifiedName(PREFIX, AUTOMAKE_VERSION_STRING);
|
||||||
public static final QualifiedName AUTOMAKE_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT, AUTOMAKE_VERSION_STRING);
|
public static final QualifiedName AUTOMAKE_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT,
|
||||||
|
AUTOMAKE_VERSION_STRING);
|
||||||
public static final String AUTOCONF_VERSION_STRING = "AutoconfEditorAutoconfVersion"; //$NON-NLS-1$
|
public static final String AUTOCONF_VERSION_STRING = "AutoconfEditorAutoconfVersion"; //$NON-NLS-1$
|
||||||
public static final QualifiedName AUTOCONF_VERSION = new QualifiedName(PREFIX, AUTOCONF_VERSION_STRING);
|
public static final QualifiedName AUTOCONF_VERSION = new QualifiedName(PREFIX, AUTOCONF_VERSION_STRING);
|
||||||
public static final QualifiedName AUTOCONF_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT, AUTOCONF_VERSION_STRING);
|
public static final QualifiedName AUTOCONF_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT,
|
||||||
|
AUTOCONF_VERSION_STRING);
|
||||||
public static final String AUTOCONF_MACRO_VERSIONING = "AutoconfEditorMacroVersioning"; //$NON-NLS-1$
|
public static final String AUTOCONF_MACRO_VERSIONING = "AutoconfEditorMacroVersioning"; //$NON-NLS-1$
|
||||||
public static final QualifiedName AUTOCONF_TOOL = new QualifiedName(PREFIX, "AutoconfToolPath"); //$NON-NLS-1$
|
public static final QualifiedName AUTOCONF_TOOL = new QualifiedName(PREFIX, "AutoconfToolPath"); //$NON-NLS-1$
|
||||||
public static final QualifiedName AUTOMAKE_TOOL = new QualifiedName(PREFIX, "AutomakeToolPath"); //$NON-NLS-1$
|
public static final QualifiedName AUTOMAKE_TOOL = new QualifiedName(PREFIX, "AutomakeToolPath"); //$NON-NLS-1$
|
||||||
|
@ -50,7 +51,7 @@ public class AutotoolsPropertyConstants {
|
||||||
public static final String AC_VERSION_2_68 = fACVersions[4];
|
public static final String AC_VERSION_2_68 = fACVersions[4];
|
||||||
public static final String LATEST_AC_VERSION = fACVersions[fACVersions.length - 1];
|
public static final String LATEST_AC_VERSION = fACVersions[fACVersions.length - 1];
|
||||||
|
|
||||||
public static final String[] fAMVersions = {"1.4-p6", "1.9.5", "1.9.6", "1.11.1"}; //$NON-NLS-1$
|
public static final String[] fAMVersions = { "1.4-p6", "1.9.5", "1.9.6", "1.11.1" }; //$NON-NLS-1$
|
||||||
public static final String LATEST_AM_VERSION = fAMVersions[fAMVersions.length - 1];
|
public static final String LATEST_AM_VERSION = fAMVersions[fAMVersions.length - 1];
|
||||||
|
|
||||||
public static final String CLEAN_MAKE_TARGET_DEFAULT = "distclean"; //$NON-NLS-1$
|
public static final String CLEAN_MAKE_TARGET_DEFAULT = "distclean"; //$NON-NLS-1$
|
||||||
|
|
|
@ -36,21 +36,18 @@ import org.eclipse.core.runtime.Path;
|
||||||
// which is similar to the CDT one.
|
// which is similar to the CDT one.
|
||||||
public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
public static final String ID = AutotoolsPlugin.PLUGIN_ID + ".errorParser"; //$NON-NLS-1$
|
public static final String ID = AutotoolsPlugin.PLUGIN_ID + ".errorParser"; //$NON-NLS-1$
|
||||||
private Pattern pkgconfigError =
|
private Pattern pkgconfigError = Pattern
|
||||||
Pattern.compile(".*?(configure:\\s+error:\\s+Package requirements\\s+\\((.*?)\\)\\s+were not met).*"); //$NON-NLS-1$
|
.compile(".*?(configure:\\s+error:\\s+Package requirements\\s+\\((.*?)\\)\\s+were not met).*"); //$NON-NLS-1$
|
||||||
private Pattern genconfigError =
|
private Pattern genconfigError = Pattern.compile(".*?configure:\\s+error:\\s+(.*)"); //$NON-NLS-1$
|
||||||
Pattern.compile(".*?configure:\\s+error:\\s+(.*)"); //$NON-NLS-1$
|
private Pattern checkingFail = Pattern.compile("checking for (.*)\\.\\.\\. no"); //$NON-NLS-1$
|
||||||
private Pattern checkingFail =
|
|
||||||
Pattern.compile("checking for (.*)\\.\\.\\. no"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
private Pattern changingConfigDirectory =
|
private Pattern changingConfigDirectory = Pattern.compile("Configuring in (.*)"); //$NON-NLS-1$
|
||||||
Pattern.compile("Configuring in (.*)"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
private IPath buildDir;
|
private IPath buildDir;
|
||||||
private IPath sourcePath;
|
private IPath sourcePath;
|
||||||
private IProject project;
|
private IProject project;
|
||||||
|
|
||||||
public ErrorParser(){
|
public ErrorParser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErrorParser(IPath sourcePath, IPath buildPath) {
|
public ErrorParser(IPath sourcePath, IPath buildPath) {
|
||||||
|
@ -59,8 +56,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processLine(String line,
|
public boolean processLine(String line, org.eclipse.cdt.core.ErrorParserManager eoParser) {
|
||||||
org.eclipse.cdt.core.ErrorParserManager eoParser) {
|
|
||||||
|
|
||||||
if (this.project == null)
|
if (this.project == null)
|
||||||
this.project = eoParser.getProject();
|
this.project = eoParser.getProject();
|
||||||
|
@ -72,7 +68,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
this.sourcePath = eoParser.getProject().getLocation();
|
this.sourcePath = eoParser.getProject().getLocation();
|
||||||
|
|
||||||
AutotoolsProblemMarkerInfo marker = processLine(line);
|
AutotoolsProblemMarkerInfo marker = processLine(line);
|
||||||
if ( marker != null){
|
if (marker != null) {
|
||||||
// Check to see if addProblemMarker exists.
|
// Check to see if addProblemMarker exists.
|
||||||
try {
|
try {
|
||||||
Method method = eoParser.getClass().getMethod("addProblemMarker", ProblemMarkerInfo.class);
|
Method method = eoParser.getClass().getMethod("addProblemMarker", ProblemMarkerInfo.class);
|
||||||
|
@ -94,7 +90,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
this.project = eoParser.getProject();
|
this.project = eoParser.getProject();
|
||||||
|
|
||||||
AutotoolsProblemMarkerInfo marker = processLine(line);
|
AutotoolsProblemMarkerInfo marker = processLine(line);
|
||||||
if ( marker != null){
|
if (marker != null) {
|
||||||
eoParser.addProblemMarker(marker);
|
eoParser.addProblemMarker(marker);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +101,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
Matcher m;
|
Matcher m;
|
||||||
|
|
||||||
m = changingConfigDirectory.matcher(line);
|
m = changingConfigDirectory.matcher(line);
|
||||||
if(m.matches()){
|
if (m.matches()) {
|
||||||
// set configuration directory.
|
// set configuration directory.
|
||||||
this.buildDir = this.buildDir.append(m.group(1));
|
this.buildDir = this.buildDir.append(m.group(1));
|
||||||
this.sourcePath = this.sourcePath.append(m.group(1));
|
this.sourcePath = this.sourcePath.append(m.group(1));
|
||||||
|
@ -114,7 +110,8 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
|
|
||||||
m = pkgconfigError.matcher(line);
|
m = pkgconfigError.matcher(line);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
return new AutotoolsProblemMarkerInfo(getProject(), -1, m.group(1), SEVERITY_ERROR_BUILD, null, null, m.group(2), AutotoolsProblemMarkerInfo.Type.PACKAGE);
|
return new AutotoolsProblemMarkerInfo(getProject(), -1, m.group(1), SEVERITY_ERROR_BUILD, null, null,
|
||||||
|
m.group(2), AutotoolsProblemMarkerInfo.Type.PACKAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
m = genconfigError.matcher(line);
|
m = genconfigError.matcher(line);
|
||||||
|
@ -129,7 +126,8 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
// Find the log file containing this check
|
// Find the log file containing this check
|
||||||
AutotoolsProblemMarkerInfo.Type type = getCheckType(m.group(1));
|
AutotoolsProblemMarkerInfo.Type type = getCheckType(m.group(1));
|
||||||
if (type != null)
|
if (type != null)
|
||||||
return new AutotoolsProblemMarkerInfo(getProject(), "Missing " + type + " " + m.group(1), SEVERITY_INFO, m.group(1), type);
|
return new AutotoolsProblemMarkerInfo(getProject(), "Missing " + type + " " + m.group(1), SEVERITY_INFO,
|
||||||
|
m.group(1), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -201,8 +199,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser {
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
return -1;
|
return -1;
|
||||||
try (LineNumberReader reader = new LineNumberReader(new FileReader(file))) {
|
try (LineNumberReader reader = new LineNumberReader(new FileReader(file))) {
|
||||||
Pattern errorPattern =
|
Pattern errorPattern = Pattern.compile("configure:(\\d+): checking for " + name); //$NON-NLS-1$
|
||||||
Pattern.compile("configure:(\\d+): checking for " + name); //$NON-NLS-1$
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
Matcher m = errorPattern.matcher(line);
|
Matcher m = errorPattern.matcher(line);
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
public static final char ERROR_PARSER_DELIMITER = ';';
|
public static final char ERROR_PARSER_DELIMITER = ';';
|
||||||
|
|
||||||
private int nOpens;
|
private int nOpens;
|
||||||
private int lineCounter=0;
|
private int lineCounter = 0;
|
||||||
|
|
||||||
private final IProject fProject;
|
private final IProject fProject;
|
||||||
private final MarkerGenerator fMarkerGenerator;
|
private final MarkerGenerator fMarkerGenerator;
|
||||||
|
@ -74,7 +74,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
private OutputStream outputStream;
|
private OutputStream outputStream;
|
||||||
private final StringBuilder currentLine = new StringBuilder();
|
private final StringBuilder currentLine = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -85,7 +84,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
this(project, project.getLocationURI(), markerGenerator);
|
this(project, project.getLocationURI(), markerGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URI based constructor.
|
* URI based constructor.
|
||||||
*
|
*
|
||||||
|
@ -194,7 +192,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
return fDirectoryStack.size();
|
return fDirectoryStack.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the input and tries to generate error or warning markers
|
* Parses the input and tries to generate error or warning markers
|
||||||
*/
|
*/
|
||||||
|
@ -202,7 +199,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
String lineTrimmed = line.trim();
|
String lineTrimmed = line.trim();
|
||||||
lineCounter++;
|
lineCounter++;
|
||||||
|
|
||||||
ProblemMarkerInfo marker=null;
|
ProblemMarkerInfo marker = null;
|
||||||
|
|
||||||
for (ErrorParser parser : fErrorParsers.values()) {
|
for (ErrorParser parser : fErrorParsers.values()) {
|
||||||
ErrorParser curr = parser;
|
ErrorParser curr = parser;
|
||||||
|
@ -217,7 +214,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
}
|
}
|
||||||
// standard behavior (pre 5.1) is to trim the line
|
// standard behavior (pre 5.1) is to trim the line
|
||||||
String lineToParse = lineTrimmed;
|
String lineToParse = lineTrimmed;
|
||||||
if ((types & IErrorParser2.KEEP_UNTRIMMED) !=0 ) {
|
if ((types & IErrorParser2.KEEP_UNTRIMMED) != 0) {
|
||||||
// untrimmed lines
|
// untrimmed lines
|
||||||
lineToParse = line;
|
lineToParse = line;
|
||||||
}
|
}
|
||||||
|
@ -228,11 +225,11 @@ public class ErrorParserManager extends OutputStream {
|
||||||
// It should not stop parsing of the rest of output.
|
// It should not stop parsing of the rest of output.
|
||||||
try {
|
try {
|
||||||
consume = curr.processLine(lineToParse, this);
|
consume = curr.processLine(lineToParse, this);
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
AutotoolsPlugin.log(e);
|
AutotoolsPlugin.log(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (fErrors.size() > 0) {
|
if (fErrors.size() > 0) {
|
||||||
if (marker==null)
|
if (marker == null)
|
||||||
marker = fErrors.get(0);
|
marker = fErrors.get(0);
|
||||||
fErrors.clear();
|
fErrors.clear();
|
||||||
}
|
}
|
||||||
|
@ -256,7 +253,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
try {
|
try {
|
||||||
if (marker != null) {
|
if (marker != null) {
|
||||||
if (outputStream instanceof IErrorMarkeredOutputStream) {
|
if (outputStream instanceof IErrorMarkeredOutputStream) {
|
||||||
IErrorMarkeredOutputStream mos = (IErrorMarkeredOutputStream)outputStream;
|
IErrorMarkeredOutputStream mos = (IErrorMarkeredOutputStream) outputStream;
|
||||||
mos.write(l, marker);
|
mos.write(l, marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +272,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
return lineCounter;
|
return lineCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add marker to the list of error markers.
|
* Add marker to the list of error markers.
|
||||||
*
|
*
|
||||||
|
@ -304,10 +300,10 @@ public class ErrorParserManager extends OutputStream {
|
||||||
* @param varName - variable name.
|
* @param varName - variable name.
|
||||||
* @param externalPath - external path pointing to a file outside the workspace.
|
* @param externalPath - external path pointing to a file outside the workspace.
|
||||||
*/
|
*/
|
||||||
public void generateExternalMarker(IResource file, int lineNumber, String desc, int severity,
|
public void generateExternalMarker(IResource file, int lineNumber, String desc, int severity, String varName,
|
||||||
String varName, IPath externalPath, String libraryInfo, AutotoolsProblemMarkerInfo.Type type) {
|
IPath externalPath, String libraryInfo, AutotoolsProblemMarkerInfo.Type type) {
|
||||||
AutotoolsProblemMarkerInfo problemMarkerInfo =
|
AutotoolsProblemMarkerInfo problemMarkerInfo = new AutotoolsProblemMarkerInfo(file, lineNumber, desc, severity,
|
||||||
new AutotoolsProblemMarkerInfo(file, lineNumber, desc, severity, varName, externalPath, libraryInfo, type);
|
varName, externalPath, libraryInfo, type);
|
||||||
addProblemMarker(problemMarkerInfo);
|
addProblemMarker(problemMarkerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +312,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
*
|
*
|
||||||
* @param problemMarkerInfo - The marker to be added
|
* @param problemMarkerInfo - The marker to be added
|
||||||
*/
|
*/
|
||||||
public void addProblemMarker(AutotoolsProblemMarkerInfo problemMarkerInfo){
|
public void addProblemMarker(AutotoolsProblemMarkerInfo problemMarkerInfo) {
|
||||||
fErrors.add(problemMarkerInfo.getMarker());
|
fErrors.add(problemMarkerInfo.getMarker());
|
||||||
fMarkerGenerator.addMarker(problemMarkerInfo);
|
fMarkerGenerator.addMarker(problemMarkerInfo);
|
||||||
}
|
}
|
||||||
|
@ -402,7 +398,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
String line = buffer.substring(0, i);
|
String line = buffer.substring(0, i);
|
||||||
// get rid of any trailing '\r'
|
// get rid of any trailing '\r'
|
||||||
if (line.endsWith("\r")) //$NON-NLS-1$
|
if (line.endsWith("\r")) //$NON-NLS-1$
|
||||||
line=line.substring(0,line.length()-1);
|
line = line.substring(0, line.length() - 1);
|
||||||
processLine(line);
|
processLine(line);
|
||||||
previousLine = line;
|
previousLine = line;
|
||||||
buffer = buffer.substring(i + 1); // skip the \n and advance
|
buffer = buffer.substring(i + 1); // skip the \n and advance
|
||||||
|
@ -418,7 +414,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a location {@link IPath} to an {@link URI}. Contrary to
|
* Converts a location {@link IPath} to an {@link URI}. Contrary to
|
||||||
* {@link URIUtil#toURI(IPath)} this method does not assume that the path belongs
|
* {@link URIUtil#toURI(IPath)} this method does not assume that the path belongs
|
||||||
|
@ -432,7 +427,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
private URI toURI(IPath path) {
|
private URI toURI(IPath path) {
|
||||||
// try {
|
// try {
|
||||||
URI baseURI = getWorkingDirectoryURI();
|
URI baseURI = getWorkingDirectoryURI();
|
||||||
String uriString = path.toString();
|
String uriString = path.toString();
|
||||||
|
|
||||||
|
@ -443,17 +438,15 @@ public class ErrorParserManager extends OutputStream {
|
||||||
return EFSExtensionManager.getDefault().createNewURIFromPath(baseURI, uriString);
|
return EFSExtensionManager.getDefault().createNewURIFromPath(baseURI, uriString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ids - array of error parser IDs
|
* @param ids - array of error parser IDs
|
||||||
* @return error parser IDs delimited with error parser delimiter ";"
|
* @return error parser IDs delimited with error parser delimiter ";"
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
public static String toDelimitedString(String[] ids) {
|
public static String toDelimitedString(String[] ids) {
|
||||||
String result=""; //$NON-NLS-1$
|
String result = ""; //$NON-NLS-1$
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
if (result.length()==0) {
|
if (result.length() == 0) {
|
||||||
result = id;
|
result = id;
|
||||||
} else {
|
} else {
|
||||||
result += ERROR_PARSER_DELIMITER + id;
|
result += ERROR_PARSER_DELIMITER + id;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class MakeMessages {
|
public class MakeMessages {
|
||||||
|
|
||||||
private static final String RESOURCE_BUNDLE= MakeMessages.class.getName();
|
private static final String RESOURCE_BUNDLE = MakeMessages.class.getName();
|
||||||
private static ResourceBundle fgResourceBundle;
|
private static ResourceBundle fgResourceBundle;
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -69,8 +69,7 @@ public abstract class MarkerGenerator {
|
||||||
if (errorVar != null) {
|
if (errorVar != null) {
|
||||||
marker.setAttribute(IAutotoolsMarker.MARKER_VARIABLE, errorVar);
|
marker.setAttribute(IAutotoolsMarker.MARKER_VARIABLE, errorVar);
|
||||||
}
|
}
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch (CoreException e) {
|
|
||||||
AutotoolsPlugin.log(e.getStatus());
|
AutotoolsPlugin.log(e.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,12 +95,13 @@ public abstract class MarkerGenerator {
|
||||||
ProblemMarkerInfo info = autotoolsMarker.getMarker();
|
ProblemMarkerInfo info = autotoolsMarker.getMarker();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IResource markerResource = info.file ;
|
IResource markerResource = info.file;
|
||||||
if (markerResource==null) {
|
if (markerResource == null) {
|
||||||
markerResource = getProject();
|
markerResource = getProject();
|
||||||
}
|
}
|
||||||
IMarker[] cur = markerResource.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true, IResource.DEPTH_ONE);
|
IMarker[] cur = markerResource.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true,
|
||||||
// IMarker[] cur = markerResource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE);
|
IResource.DEPTH_ONE);
|
||||||
|
// IMarker[] cur = markerResource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE);
|
||||||
/*
|
/*
|
||||||
* Try to find matching markers and don't put in duplicates
|
* Try to find matching markers and don't put in duplicates
|
||||||
*/
|
*/
|
||||||
|
@ -110,14 +110,15 @@ public abstract class MarkerGenerator {
|
||||||
int line = ((Integer) cur[i].getAttribute(IMarker.LOCATION)).intValue();
|
int line = ((Integer) cur[i].getAttribute(IMarker.LOCATION)).intValue();
|
||||||
int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue();
|
int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue();
|
||||||
String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE);
|
String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE);
|
||||||
if (line == info.lineNumber && sev == mapMarkerSeverity(info.severity) && mesg.equals(info.description)) {
|
if (line == info.lineNumber && sev == mapMarkerSeverity(info.severity)
|
||||||
|
&& mesg.equals(info.description)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMarker marker = markerResource.createMarker(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER);
|
IMarker marker = markerResource.createMarker(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER);
|
||||||
// IMarker marker = markerResource.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
|
// IMarker marker = markerResource.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
|
||||||
marker.setAttribute(IMarker.LOCATION, info.lineNumber);
|
marker.setAttribute(IMarker.LOCATION, info.lineNumber);
|
||||||
marker.setAttribute(IMarker.MESSAGE, info.description);
|
marker.setAttribute(IMarker.MESSAGE, info.description);
|
||||||
marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(info.severity));
|
marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(info.severity));
|
||||||
|
@ -133,27 +134,25 @@ public abstract class MarkerGenerator {
|
||||||
|
|
||||||
// Add all other client defined attributes.
|
// Add all other client defined attributes.
|
||||||
Map<String, String> attributes = info.getAttributes();
|
Map<String, String> attributes = info.getAttributes();
|
||||||
if (attributes != null){
|
if (attributes != null) {
|
||||||
for (Entry<String, String> entry : attributes.entrySet()) {
|
for (Entry<String, String> entry : attributes.entrySet()) {
|
||||||
marker.setAttribute(entry.getKey(), entry.getValue());
|
marker.setAttribute(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (CoreException e) {
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
AutotoolsPlugin.log(e.getStatus());
|
AutotoolsPlugin.log(e.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int mapMarkerSeverity(int severity) {
|
private int mapMarkerSeverity(int severity) {
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case SEVERITY_ERROR_BUILD :
|
case SEVERITY_ERROR_BUILD:
|
||||||
case SEVERITY_ERROR_RESOURCE :
|
case SEVERITY_ERROR_RESOURCE:
|
||||||
return IMarker.SEVERITY_ERROR;
|
return IMarker.SEVERITY_ERROR;
|
||||||
case SEVERITY_INFO :
|
case SEVERITY_INFO:
|
||||||
return IMarker.SEVERITY_INFO;
|
return IMarker.SEVERITY_INFO;
|
||||||
case SEVERITY_WARNING :
|
case SEVERITY_WARNING:
|
||||||
return IMarker.SEVERITY_WARNING;
|
return IMarker.SEVERITY_WARNING;
|
||||||
}
|
}
|
||||||
return IMarker.SEVERITY_ERROR;
|
return IMarker.SEVERITY_ERROR;
|
||||||
|
@ -175,7 +174,7 @@ public abstract class MarkerGenerator {
|
||||||
IMarker[] markers;
|
IMarker[] markers;
|
||||||
try {
|
try {
|
||||||
markers = project.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
|
markers = project.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
|
||||||
// markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
|
// markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// Handled just about every case in the sanity check
|
// Handled just about every case in the sanity check
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,11 +21,11 @@ public class MarkerResolutionGenerator implements IMarkerResolutionGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMarkerResolution[] getResolutions(IMarker marker) {
|
public IMarkerResolution[] getResolutions(IMarker marker) {
|
||||||
// System.out.println("in marker resolution, library info is " + marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, ""));
|
// System.out.println("in marker resolution, library info is " + marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, ""));
|
||||||
// String libraryInfo = marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, null);
|
// String libraryInfo = marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, null);
|
||||||
// if (libraryInfo != null) {
|
// if (libraryInfo != null) {
|
||||||
// return new IMarkerResolution[] {new PkgconfigErrorResolution(libraryInfo)};
|
// return new IMarkerResolution[] {new PkgconfigErrorResolution(libraryInfo)};
|
||||||
// };
|
// };
|
||||||
return new IMarkerResolution[0];
|
return new IMarkerResolution[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
|
||||||
protected StringBuffer fBuffer;
|
protected StringBuffer fBuffer;
|
||||||
|
|
||||||
public ConsoleOutputStream() {
|
public ConsoleOutputStream() {
|
||||||
fBuffer= new StringBuffer();
|
fBuffer = new StringBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String readBuffer() {
|
public synchronized String readBuffer() {
|
||||||
|
@ -71,7 +71,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return AutotoolsPlugin.getFormattedString(PKG_UPDATE_MSG, new String[] {pkgName});
|
return AutotoolsPlugin.getFormattedString(PKG_UPDATE_MSG, new String[] { pkgName });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,23 +85,20 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
|
||||||
// Note, that we won't have any pkgconfig path settings from the configure call
|
// Note, that we won't have any pkgconfig path settings from the configure call
|
||||||
// so we can't handle the situation where the user doesn't have pkgconfig files
|
// so we can't handle the situation where the user doesn't have pkgconfig files
|
||||||
// stored in the usual place.
|
// stored in the usual place.
|
||||||
IPath pkgconfigPath =
|
IPath pkgconfigPath = new Path("/usr/lib/pkgconfig").append(pkgName + ".pc"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new Path("/usr/lib/pkgconfig").append(pkgName+".pc"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// Get a launcher for the config command
|
// Get a launcher for the config command
|
||||||
RemoteCommandLauncher launcher = new RemoteCommandLauncher();
|
RemoteCommandLauncher launcher = new RemoteCommandLauncher();
|
||||||
IPath commandPath = new Path("rpm"); //$NON-NLS-1$
|
IPath commandPath = new Path("rpm"); //$NON-NLS-1$
|
||||||
String[] commandArgs =
|
String[] commandArgs = new String[] { "-q", //$NON-NLS-1$
|
||||||
new String[] {"-q", //$NON-NLS-1$
|
|
||||||
"--queryformat", //$NON-NLS-1$
|
"--queryformat", //$NON-NLS-1$
|
||||||
"%{NAME}", //$NON-NLS-1$
|
"%{NAME}", //$NON-NLS-1$
|
||||||
"--whatprovides", //$NON-NLS-1$
|
"--whatprovides", //$NON-NLS-1$
|
||||||
pkgconfigPath.toOSString()};
|
pkgconfigPath.toOSString() };
|
||||||
try {
|
try {
|
||||||
// Use CDT launcher to run rpm to query the package that provides
|
// Use CDT launcher to run rpm to query the package that provides
|
||||||
// the pkgconfig .pc file for the package in question.
|
// the pkgconfig .pc file for the package in question.
|
||||||
ConsoleOutputStream output = new ConsoleOutputStream();
|
ConsoleOutputStream output = new ConsoleOutputStream();
|
||||||
Process proc = launcher.execute(commandPath, commandArgs, null,
|
Process proc = launcher.execute(commandPath, commandArgs, null, new Path("."), new NullProgressMonitor());
|
||||||
new Path("."), new NullProgressMonitor());
|
|
||||||
if (proc != null) {
|
if (proc != null) {
|
||||||
try {
|
try {
|
||||||
// Close the input of the process since we will never write to
|
// Close the input of the process since we will never write to
|
||||||
|
@ -109,8 +106,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
|
||||||
proc.getOutputStream().close();
|
proc.getOutputStream().close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
if (launcher.waitAndRead(output, output, new NullProgressMonitor())
|
if (launcher.waitAndRead(output, output, new NullProgressMonitor()) != ICommandLauncher.OK) {
|
||||||
!= ICommandLauncher.OK) {
|
|
||||||
AutotoolsPlugin.logErrorMessage(launcher.getErrorMessage());
|
AutotoolsPlugin.logErrorMessage(launcher.getErrorMessage());
|
||||||
} else {
|
} else {
|
||||||
String result = output.readBuffer();
|
String result = output.readBuffer();
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
|
||||||
public class AutotoolsConfiguration implements IAConfiguration {
|
public class AutotoolsConfiguration implements IAConfiguration {
|
||||||
|
|
||||||
public static class Option {
|
public static class Option {
|
||||||
|
@ -125,20 +124,22 @@ public class AutotoolsConfiguration implements IAConfiguration {
|
||||||
new Option(AutotoolsOptionConstants.CATEGORY_FILENAMES, IConfigureOption.CATEGORY),
|
new Option(AutotoolsOptionConstants.CATEGORY_FILENAMES, IConfigureOption.CATEGORY),
|
||||||
new Option(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX, "program_prefix", IConfigureOption.STRING), //$NON-NLS-1$
|
new Option(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX, "program_prefix", IConfigureOption.STRING), //$NON-NLS-1$
|
||||||
new Option(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX, "program_suffix", IConfigureOption.STRING), //$NON-NLS-1$
|
new Option(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX, "program_suffix", IConfigureOption.STRING), //$NON-NLS-1$
|
||||||
new Option(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME, "program_transform_name", IConfigureOption.STRING), //$NON-NLS-1$
|
new Option(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME, "program_transform_name", //$NON-NLS-1$
|
||||||
|
IConfigureOption.STRING),
|
||||||
new Option(AutotoolsOptionConstants.CATEGORY_ENVVAR, IConfigureOption.CATEGORY),
|
new Option(AutotoolsOptionConstants.CATEGORY_ENVVAR, IConfigureOption.CATEGORY),
|
||||||
new Option(AutotoolsOptionConstants.OPT_ENVVAR, IConfigureOption.ENVVAR),
|
new Option(AutotoolsOptionConstants.OPT_ENVVAR, IConfigureOption.ENVVAR),
|
||||||
new Option(AutotoolsOptionConstants.CATEGORY_FEATURES, IConfigureOption.CATEGORY),
|
new Option(AutotoolsOptionConstants.CATEGORY_FEATURES, IConfigureOption.CATEGORY),
|
||||||
new Option(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE, "enable_maintainer_mode", IConfigureOption.BIN), //$NON-NLS-1$
|
new Option(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE, "enable_maintainer_mode", //$NON-NLS-1$
|
||||||
new Option(AutotoolsOptionConstants.FLAG_CFLAGS, "cflags", AutotoolsOptionConstants.FLAG_CFLAGS_FLAGS, IConfigureOption.FLAG), //$NON-NLS-1$
|
IConfigureOption.BIN),
|
||||||
|
new Option(AutotoolsOptionConstants.FLAG_CFLAGS, "cflags", AutotoolsOptionConstants.FLAG_CFLAGS_FLAGS, //$NON-NLS-1$
|
||||||
|
IConfigureOption.FLAG),
|
||||||
new Option(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG, "cflags_debug", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$
|
new Option(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG, "cflags_debug", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new Option(AutotoolsOptionConstants.OPT_CFLAGS_GPROF, "cflags_gprof", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$
|
new Option(AutotoolsOptionConstants.OPT_CFLAGS_GPROF, "cflags_gprof", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new Option(AutotoolsOptionConstants.OPT_CFLAGS_GCOV, "cflags_gcov", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$
|
new Option(AutotoolsOptionConstants.OPT_CFLAGS_GCOV, "cflags_gcov", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new Option(AutotoolsOptionConstants.OPT_USER, IConfigureOption.MULTIARG),
|
new Option(AutotoolsOptionConstants.OPT_USER, IConfigureOption.MULTIARG),
|
||||||
new Option(AutotoolsOptionConstants.TOOL_AUTOGEN, "autogen", "autogen.sh", IConfigureOption.TOOL), //$NON-NLS-1$
|
new Option(AutotoolsOptionConstants.TOOL_AUTOGEN, "autogen", "autogen.sh", IConfigureOption.TOOL), //$NON-NLS-1$
|
||||||
new Option(AutotoolsOptionConstants.CATEGORY_OPTIONS, IConfigureOption.CATEGORY),
|
new Option(AutotoolsOptionConstants.CATEGORY_OPTIONS, IConfigureOption.CATEGORY),
|
||||||
new Option(AutotoolsOptionConstants.OPT_AUTOGENOPTS, IConfigureOption.MULTIARG),
|
new Option(AutotoolsOptionConstants.OPT_AUTOGENOPTS, IConfigureOption.MULTIARG), };
|
||||||
};
|
|
||||||
|
|
||||||
private static Option[] toolList;
|
private static Option[] toolList;
|
||||||
|
|
||||||
|
@ -244,9 +245,8 @@ public class AutotoolsConfiguration implements IAConfiguration {
|
||||||
configOptions.put(opt.name, f);
|
configOptions.put(opt.name, f);
|
||||||
break;
|
break;
|
||||||
case IConfigureOption.FLAGVALUE:
|
case IConfigureOption.FLAGVALUE:
|
||||||
FlagValueConfigureOption fv
|
FlagValueConfigureOption fv = new FlagValueConfigureOption(opt.name, opt.transformedName, this,
|
||||||
= new FlagValueConfigureOption(opt.name, opt.transformedName,
|
ConfigureMessages.getParameter(opt.transformedName));
|
||||||
this, ConfigureMessages.getParameter(opt.transformedName));
|
|
||||||
if (defaultValue != null)
|
if (defaultValue != null)
|
||||||
fv.setValue(defaultValue);
|
fv.setValue(defaultValue);
|
||||||
lastFlag.addChild(opt.name);
|
lastFlag.addChild(opt.name);
|
||||||
|
@ -276,8 +276,7 @@ public class AutotoolsConfiguration implements IAConfiguration {
|
||||||
for (int j = i + 1; j < configOpts.length; ++j) {
|
for (int j = i + 1; j < configOpts.length; ++j) {
|
||||||
Option o = configOpts[j];
|
Option o = configOpts[j];
|
||||||
int type = o.getType();
|
int type = o.getType();
|
||||||
if (type != IConfigureOption.CATEGORY &&
|
if (type != IConfigureOption.CATEGORY && type != IConfigureOption.TOOL)
|
||||||
type != IConfigureOption.TOOL)
|
|
||||||
options.add(o);
|
options.add(o);
|
||||||
else
|
else
|
||||||
return options.toArray(new Option[options.size()]);
|
return options.toArray(new Option[options.size()]);
|
||||||
|
|
|
@ -131,7 +131,6 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized boolean isConfigurationAlreadySaved(IProject project, ICConfigurationDescription cfgd) {
|
public synchronized boolean isConfigurationAlreadySaved(IProject project, ICConfigurationDescription cfgd) {
|
||||||
Map<String, IAConfiguration> cfgs = getSavedConfigs(project);
|
Map<String, IAConfiguration> cfgs = getSavedConfigs(project);
|
||||||
if (cfgs != null)
|
if (cfgs != null)
|
||||||
|
@ -189,7 +188,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
saveConfigs(project);
|
saveConfigs(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs, ICConfigurationDescription[] cfgds) {
|
public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs,
|
||||||
|
ICConfigurationDescription[] cfgds) {
|
||||||
String projectName = project.getName();
|
String projectName = project.getName();
|
||||||
configs.put(projectName, cfgs);
|
configs.put(projectName, cfgs);
|
||||||
saveConfigs(project, cfgds);
|
saveConfigs(project, cfgds);
|
||||||
|
@ -223,8 +223,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
cfgId = cfgIdNode.getNodeValue();
|
cfgId = cfgIdNode.getNodeValue();
|
||||||
else if (nameNode != null) {
|
else if (nameNode != null) {
|
||||||
String cfgName = nameNode.getNodeValue();
|
String cfgName = nameNode.getNodeValue();
|
||||||
ICConfigurationDescription cfgd =
|
ICConfigurationDescription cfgd = CoreModel.getDefault().getProjectDescription(project)
|
||||||
CoreModel.getDefault().getProjectDescription(project).getConfigurationByName(cfgName);
|
.getConfigurationByName(cfgName);
|
||||||
if (cfgd != null)
|
if (cfgd != null)
|
||||||
cfgId = cfgd.getId();
|
cfgId = cfgd.getId();
|
||||||
else
|
else
|
||||||
|
@ -276,7 +276,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized IAConfiguration getTmpConfiguration(IProject p, ICConfigurationDescription cfgd) {
|
public synchronized IAConfiguration getTmpConfiguration(IProject p, ICConfigurationDescription cfgd) {
|
||||||
Map <String, IAConfiguration> list = getTmpConfigs(p);
|
Map<String, IAConfiguration> list = getTmpConfigs(p);
|
||||||
IAConfiguration acfg = list.get(cfgd.getId());
|
IAConfiguration acfg = list.get(cfgd.getId());
|
||||||
if (acfg != null) {
|
if (acfg != null) {
|
||||||
return acfg;
|
return acfg;
|
||||||
|
@ -298,7 +298,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
public synchronized boolean cloneCfg(IProject p, String oldId, ICConfigurationDescription cfgd) {
|
public synchronized boolean cloneCfg(IProject p, String oldId, ICConfigurationDescription cfgd) {
|
||||||
if (isConfigurationAlreadySaved(p, cfgd))
|
if (isConfigurationAlreadySaved(p, cfgd))
|
||||||
return true;
|
return true;
|
||||||
Map <String, IAConfiguration> tmpList = getTmpConfigs(p);
|
Map<String, IAConfiguration> tmpList = getTmpConfigs(p);
|
||||||
String newId = cfgd.getId();
|
String newId = cfgd.getId();
|
||||||
// Don't bother if the new configuration is already on the tmp list
|
// Don't bother if the new configuration is already on the tmp list
|
||||||
IAConfiguration cfg = tmpList.get(newId);
|
IAConfiguration cfg = tmpList.get(newId);
|
||||||
|
@ -307,7 +307,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
// Otherwise, try and find the old id to copy the configuration from
|
// Otherwise, try and find the old id to copy the configuration from
|
||||||
// or punt if not found
|
// or punt if not found
|
||||||
IAConfiguration oldCfg = null;
|
IAConfiguration oldCfg = null;
|
||||||
Map <String, IAConfiguration> savedList = getSavedConfigs(p);
|
Map<String, IAConfiguration> savedList = getSavedConfigs(p);
|
||||||
if (savedList != null)
|
if (savedList != null)
|
||||||
oldCfg = savedList.get(oldId);
|
oldCfg = savedList.get(oldId);
|
||||||
if (oldCfg != null) {
|
if (oldCfg != null) {
|
||||||
|
@ -325,7 +325,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, IAConfiguration> getTmpConfigs(IProject p) {
|
private Map<String, IAConfiguration> getTmpConfigs(IProject p) {
|
||||||
Map <String, IAConfiguration> tmpList = tmpConfigs.get(p.getName());
|
Map<String, IAConfiguration> tmpList = tmpConfigs.get(p.getName());
|
||||||
if (tmpList == null) {
|
if (tmpList == null) {
|
||||||
tmpList = new HashMap<>();
|
tmpList = new HashMap<>();
|
||||||
tmpConfigs.put(p.getName(), tmpList);
|
tmpConfigs.put(p.getName(), tmpList);
|
||||||
|
@ -339,7 +339,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
|
|
||||||
public synchronized void saveConfigs(IProject project) {
|
public synchronized void saveConfigs(IProject project) {
|
||||||
synchronized (project) {
|
synchronized (project) {
|
||||||
ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project).getConfigurations();
|
ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project)
|
||||||
|
.getConfigurations();
|
||||||
saveConfigs(project, cfgds);
|
saveConfigs(project, cfgds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,8 +354,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
for (int j = 0; j < tools.length; ++j) {
|
for (int j = 0; j < tools.length; ++j) {
|
||||||
ITool tool = tools[j];
|
ITool tool = tools[j];
|
||||||
if (tool.getName().equals("configure")) { //$NON-NLS-1$
|
if (tool.getName().equals("configure")) { //$NON-NLS-1$
|
||||||
IOption option =
|
IOption option = tool
|
||||||
tool.getOptionBySuperClassId("org.eclipse.linuxtools.cdt.autotools.core.option.configure.name"); //$NON-NLS-1$
|
.getOptionBySuperClassId("org.eclipse.linuxtools.cdt.autotools.core.option.configure.name"); //$NON-NLS-1$
|
||||||
IHoldsOptions h = tool;
|
IHoldsOptions h = tool;
|
||||||
try {
|
try {
|
||||||
IOption optionToSet = h.getOptionToSet(option, false);
|
IOption optionToSet = h.getOptionToSet(option, false);
|
||||||
|
@ -445,11 +446,11 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IResource res = root.findMember(projectName, false);
|
IResource res = root.findMember(projectName, false);
|
||||||
if (res == null || res.getType() != IResource.PROJECT) {
|
if (res == null || res.getType() != IResource.PROJECT) {
|
||||||
AutotoolsPlugin.logErrorMessage(ConfigureMessages.getFormattedString(CFG_CANT_SAVE,
|
AutotoolsPlugin.logErrorMessage(
|
||||||
new String[]{projectName}));
|
ConfigureMessages.getFormattedString(CFG_CANT_SAVE, new String[] { projectName }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IProject project = (IProject)res;
|
IProject project = (IProject) res;
|
||||||
IPath output = project.getLocation().append(CFG_FILE_NAME);
|
IPath output = project.getLocation().append(CFG_FILE_NAME);
|
||||||
File f = output.toFile();
|
File f = output.toFile();
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
|
@ -496,7 +497,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
Option option = optionList[j];
|
Option option = optionList[j];
|
||||||
IConfigureOption opt = cfg.getOption(option.getName());
|
IConfigureOption opt = cfg.getOption(option.getName());
|
||||||
if (!opt.isCategory())
|
if (!opt.isCategory())
|
||||||
p.println("<option id=\"" + option.getName() + "\" value=\"" + opt.getValue() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
p.println("<option id=\"" + option.getName() + "\" value=\"" + opt.getValue() //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
+ "\"/>"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
p.println("</configuration>"); //$NON-NLS-1$
|
p.println("</configuration>"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -553,7 +555,6 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
private IConfigureOption option;
|
private IConfigureOption option;
|
||||||
private final static String UNMODIFIABLE_CONFIG_OPTION = "CfgOptions.Unmodifiable.Option"; //$NON-NLS-1$
|
private final static String UNMODIFIABLE_CONFIG_OPTION = "CfgOptions.Unmodifiable.Option"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
public AutotoolsOption(IConfigureOption option) {
|
public AutotoolsOption(IConfigureOption option) {
|
||||||
this.option = option;
|
this.option = option;
|
||||||
}
|
}
|
||||||
|
@ -610,8 +611,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
/**
|
/**
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions(IProject project,
|
public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions(IProject project, String cfgId)
|
||||||
String cfgId) throws CoreException {
|
throws CoreException {
|
||||||
|
|
||||||
// Verify project is valid Autotools project
|
// Verify project is valid Autotools project
|
||||||
if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
|
if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
|
||||||
|
@ -620,8 +621,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify configuration id is valid
|
// Verify configuration id is valid
|
||||||
ICConfigurationDescription cfgd =
|
ICConfigurationDescription cfgd = CoreModel.getDefault().getProjectDescription(project)
|
||||||
CoreModel.getDefault().getProjectDescription(project).getConfigurationById(cfgId);
|
.getConfigurationById(cfgId);
|
||||||
IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
|
IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
|
||||||
if (icfg == null) {
|
if (icfg == null) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID,
|
||||||
|
@ -637,8 +638,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator(); i.hasNext();) {
|
for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator(); i.hasNext();) {
|
||||||
Map.Entry<String, IConfigureOption> entry = i.next();
|
Map.Entry<String, IConfigureOption> entry = i.next();
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
IAutotoolsOption configOption =
|
IAutotoolsOption configOption = new AutotoolsOption(
|
||||||
new AutotoolsOption(entry.getValue().copy((AutotoolsConfiguration)dummyCfg));
|
entry.getValue().copy((AutotoolsConfiguration) dummyCfg));
|
||||||
options.put(name, configOption);
|
options.put(name, configOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +650,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener {
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public synchronized void updateAutotoolCfgOptions(IProject project, String cfgId,
|
public synchronized void updateAutotoolCfgOptions(IProject project, String cfgId,
|
||||||
Map<String,IAutotoolsOption> options) throws CoreException {
|
Map<String, IAutotoolsOption> options) throws CoreException {
|
||||||
|
|
||||||
// Verify project is valid Autotools project
|
// Verify project is valid Autotools project
|
||||||
if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
|
if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
|
||||||
|
|
|
@ -28,8 +28,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler
|
public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler implements IOptionApplicability {
|
||||||
implements IOptionApplicability {
|
|
||||||
|
|
||||||
public static final String DEFAULT_BUILD_DIR = "build"; //$NON-NLS-1$
|
public static final String DEFAULT_BUILD_DIR = "build"; //$NON-NLS-1$
|
||||||
public static final String CONFIGURE_TOOL_ID = "org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure"; //$NON-NLS-1$
|
public static final String CONFIGURE_TOOL_ID = "org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure"; //$NON-NLS-1$
|
||||||
|
@ -41,25 +40,21 @@ public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler
|
||||||
|
|
||||||
//FIXME: Use holder to set option value, not the "option" parameter
|
//FIXME: Use holder to set option value, not the "option" parameter
|
||||||
@Override
|
@Override
|
||||||
public boolean handleValue(IBuildObject buildObject,
|
public boolean handleValue(IBuildObject buildObject, IHoldsOptions holder, IOption option, String extraArgument,
|
||||||
IHoldsOptions holder,
|
int event) {
|
||||||
IOption option,
|
|
||||||
String extraArgument, int event)
|
|
||||||
{
|
|
||||||
// Get the current value of the build dir option.
|
// Get the current value of the build dir option.
|
||||||
String value = (String)option.getValue();
|
String value = (String) option.getValue();
|
||||||
|
|
||||||
if (buildObject instanceof IConfiguration &&
|
if (buildObject instanceof IConfiguration && (event == IManagedOptionValueHandler.EVENT_OPEN)) {
|
||||||
(event == IManagedOptionValueHandler.EVENT_OPEN)) {
|
// SortedSet<Integer> nums = new TreeSet<Integer>();
|
||||||
// SortedSet<Integer> nums = new TreeSet<Integer>();
|
IConfiguration configuration = (IConfiguration) buildObject;
|
||||||
IConfiguration configuration = (IConfiguration)buildObject;
|
|
||||||
ICConfigurationDescription cfgd = ManagedBuildManager.getDescriptionForConfiguration(configuration);
|
ICConfigurationDescription cfgd = ManagedBuildManager.getDescriptionForConfiguration(configuration);
|
||||||
if (option.getName().equals("Name") && cfgd != null) {
|
if (option.getName().equals("Name") && cfgd != null) {
|
||||||
String cfgId = cfgd.getId();
|
String cfgId = cfgd.getId();
|
||||||
if (!value.isEmpty() && !value.equals(cfgId)) {
|
if (!value.isEmpty() && !value.equals(cfgId)) {
|
||||||
// we have a cloned configuration and we know that the
|
// we have a cloned configuration and we know that the
|
||||||
// clonee's name is the value of the option
|
// clonee's name is the value of the option
|
||||||
IProject project = (IProject)configuration.getManagedProject().getOwner();
|
IProject project = (IProject) configuration.getManagedProject().getOwner();
|
||||||
String autoName = null;
|
String autoName = null;
|
||||||
String autoNameTemplate = null;
|
String autoNameTemplate = null;
|
||||||
// Check if we are supposed to automatically name the build directory for any
|
// Check if we are supposed to automatically name the build directory for any
|
||||||
|
@ -106,22 +101,18 @@ public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler
|
||||||
// IOptionApplicability methods
|
// IOptionApplicability methods
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOptionEnabled(IBuildObject configuration,
|
public boolean isOptionEnabled(IBuildObject configuration, IHoldsOptions holder, IOption option) {
|
||||||
IHoldsOptions holder, IOption option) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOptionUsedInCommandLine(IBuildObject configuration,
|
public boolean isOptionUsedInCommandLine(IBuildObject configuration, IHoldsOptions holder, IOption option) {
|
||||||
IHoldsOptions holder, IOption option) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOptionVisible(IBuildObject configuration,
|
public boolean isOptionVisible(IBuildObject configuration, IHoldsOptions holder, IOption option) {
|
||||||
IHoldsOptions holder, IOption option) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@ import java.util.ResourceBundle;
|
||||||
public class ConfigureMessages {
|
public class ConfigureMessages {
|
||||||
private static final String BUNDLE_NAME = ConfigureMessages.class.getName();
|
private static final String BUNDLE_NAME = ConfigureMessages.class.getName();
|
||||||
|
|
||||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
|
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
|
||||||
.getBundle(BUNDLE_NAME);
|
|
||||||
|
|
||||||
private ConfigureMessages() {
|
private ConfigureMessages() {
|
||||||
}
|
}
|
||||||
|
@ -37,6 +36,7 @@ public class ConfigureMessages {
|
||||||
public static String getParameter(String name) {
|
public static String getParameter(String name) {
|
||||||
return getString("Option.configure." + name + ".parm"); //$NON-NLS-1$ //$NON-NLS-2$
|
return getString("Option.configure." + name + ".parm"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string from the resource bundle,
|
* Returns the string from the resource bundle,
|
||||||
* or 'key' if not found.
|
* or 'key' if not found.
|
||||||
|
@ -61,7 +61,7 @@ public class ConfigureMessages {
|
||||||
* @return the resource bundle message
|
* @return the resource bundle message
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(String key, String[] args) {
|
public static String getFormattedString(String key, String[] args) {
|
||||||
return MessageFormat.format(getString(key), (Object[])args);
|
return MessageFormat.format(getString(key), (Object[]) args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
|
||||||
IConfigureOption o = cfg.getOption(fvname);
|
IConfigureOption o = cfg.getOption(fvname);
|
||||||
if (o.isParmSet()) {
|
if (o.isParmSet()) {
|
||||||
if (o instanceof IFlagConfigureValueOption) {
|
if (o instanceof IFlagConfigureValueOption) {
|
||||||
parm.append(separator).append(((IFlagConfigureValueOption)o).getFlags());
|
parm.append(separator).append(((IFlagConfigureValueOption) o).getFlags());
|
||||||
separator = " "; //$NON-NLS-1$
|
separator = " "; //$NON-NLS-1$
|
||||||
haveParm = true;
|
haveParm = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,12 @@ public class FlagValueConfigureOption extends BinConfigureOption implements IFla
|
||||||
|
|
||||||
private String flags;
|
private String flags;
|
||||||
|
|
||||||
public FlagValueConfigureOption(String name, String msgName, AutotoolsConfiguration cfg,
|
public FlagValueConfigureOption(String name, String msgName, AutotoolsConfiguration cfg, String flags) {
|
||||||
String flags) {
|
|
||||||
super(name, msgName, cfg);
|
super(name, msgName, cfg);
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlagValueConfigureOption(String name, AutotoolsConfiguration cfg, String value,
|
private FlagValueConfigureOption(String name, AutotoolsConfiguration cfg, String value, String flags) {
|
||||||
String flags) {
|
|
||||||
super(name, cfg);
|
super(name, cfg);
|
||||||
this.setValue(value);
|
this.setValue(value);
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
|
|
|
@ -27,8 +27,7 @@ public class InternalConfigureOption extends AbstractConfigurationOption {
|
||||||
this.value = ""; //$NON-NLS-1$
|
this.value = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private InternalConfigureOption(String name, AutotoolsConfiguration cfg,
|
private InternalConfigureOption(String name, AutotoolsConfiguration cfg, String value) {
|
||||||
String value) {
|
|
||||||
super(name, cfg);
|
super(name, cfg);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.autotools.core.configure;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class MultiArgConfigureOption extends AbstractConfigurationOption {
|
public class MultiArgConfigureOption extends AbstractConfigurationOption {
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
@ -33,8 +32,7 @@ public class MultiArgConfigureOption extends AbstractConfigurationOption {
|
||||||
this.value = ""; //$NON-NLS-1$
|
this.value = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private MultiArgConfigureOption(String name, AutotoolsConfiguration cfg,
|
private MultiArgConfigureOption(String name, AutotoolsConfiguration cfg, String value) {
|
||||||
String value) {
|
|
||||||
super(name, cfg);
|
super(name, cfg);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.autotools.core.configure;
|
package org.eclipse.cdt.internal.autotools.core.configure;
|
||||||
|
|
||||||
|
|
||||||
public class StringConfigureOption extends AbstractConfigurationOption {
|
public class StringConfigureOption extends AbstractConfigurationOption {
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
@ -28,8 +27,7 @@ public class StringConfigureOption extends AbstractConfigurationOption {
|
||||||
this.value = ""; //$NON-NLS-1$
|
this.value = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringConfigureOption(String name, AutotoolsConfiguration cfg,
|
private StringConfigureOption(String name, AutotoolsConfiguration cfg, String value) {
|
||||||
String value) {
|
|
||||||
super(name, cfg);
|
super(name, cfg);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Project in the workspace.
|
* Creates a new Project in the workspace.
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +53,8 @@ public class NewAutotoolsProject extends ProcessRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
|
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor)
|
||||||
|
throws ProcessFailureException {
|
||||||
String projectName = args[0].getSimpleValue();
|
String projectName = args[0].getSimpleValue();
|
||||||
String location = args[1].getSimpleValue();
|
String location = args[1].getSimpleValue();
|
||||||
String artifactExtension = args[2].getSimpleValue();
|
String artifactExtension = args[2].getSimpleValue();
|
||||||
|
@ -134,7 +134,8 @@ public class NewAutotoolsProject extends ProcessRunner {
|
||||||
if (!option.isExtensionElement()) {
|
if (!option.isExtensionElement()) {
|
||||||
option.setValue(val);
|
option.setValue(val);
|
||||||
} else {
|
} else {
|
||||||
IOption newOption = config.getToolChain().createOption(option, option.getId() + "." + ManagedBuildManager.getRandomNumber(), option.getName(), false); //$NON-NLS-1$
|
IOption newOption = config.getToolChain().createOption(option,
|
||||||
|
option.getId() + "." + ManagedBuildManager.getRandomNumber(), option.getName(), false); //$NON-NLS-1$
|
||||||
newOption.setValue(val);
|
newOption.setValue(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class SetAutotoolsStringOptionValue extends ProcessRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
|
ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue();
|
||||||
for(int i=0; i<resourcePathObjects.length; i++) {
|
for (int i = 0; i < resourcePathObjects.length; i++) {
|
||||||
ProcessArgument[] resourcePathObject = resourcePathObjects[i];
|
ProcessArgument[] resourcePathObject = resourcePathObjects[i];
|
||||||
String id = resourcePathObject[0].getSimpleValue();
|
String id = resourcePathObject[0].getSimpleValue();
|
||||||
String value = resourcePathObject[1].getSimpleValue();
|
String value = resourcePathObject[1].getSimpleValue();
|
||||||
|
@ -62,11 +62,10 @@ public class SetAutotoolsStringOptionValue extends ProcessRunner {
|
||||||
private void setOptionValue(IProject projectHandle, String id, String value) {
|
private void setOptionValue(IProject projectHandle, String id, String value) {
|
||||||
|
|
||||||
AutotoolsConfigurationManager.getInstance().syncConfigurations(projectHandle);
|
AutotoolsConfigurationManager.getInstance().syncConfigurations(projectHandle);
|
||||||
ICConfigurationDescription[] cfgds =
|
ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(projectHandle)
|
||||||
CoreModel.getDefault().getProjectDescription(projectHandle).getConfigurations();
|
.getConfigurations();
|
||||||
if (cfgds != null && cfgds.length >= 1) {
|
if (cfgds != null && cfgds.length >= 1) {
|
||||||
IAConfiguration iaConfig =
|
IAConfiguration iaConfig = AutotoolsConfigurationManager.getInstance().getConfiguration(projectHandle,
|
||||||
AutotoolsConfigurationManager.getInstance().getConfiguration(projectHandle,
|
|
||||||
cfgds[0].getId());
|
cfgds[0].getId());
|
||||||
iaConfig.setOption(id, value);
|
iaConfig.setOption(id, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,8 @@ import org.junit.runners.Suite;
|
||||||
|
|
||||||
/** On Windows requires either Cygwin or MinGW to be in PATH */
|
/** On Windows requires either Cygwin or MinGW to be in PATH */
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({ AutotoolsProjectTest0.class, AutotoolsProjectNatureTest.class, AutotoolsProjectTest1.class,
|
||||||
AutotoolsProjectTest0.class,
|
AutotoolsProjectTest2.class, AutotoolsVirtualFolderTest.class, AutotoolsEnvironmentVarTest.class,
|
||||||
AutotoolsProjectNatureTest.class,
|
LibtoolGCCBuildCommandParserTest.class, UpdateConfigureTest.class, EditorTests.class })
|
||||||
AutotoolsProjectTest1.class,
|
|
||||||
AutotoolsProjectTest2.class,
|
|
||||||
AutotoolsVirtualFolderTest.class,
|
|
||||||
AutotoolsEnvironmentVarTest.class,
|
|
||||||
LibtoolGCCBuildCommandParserTest.class,
|
|
||||||
UpdateConfigureTest.class,
|
|
||||||
EditorTests.class
|
|
||||||
})
|
|
||||||
public class AutomatedIntegrationSuite {
|
public class AutomatedIntegrationSuite {
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,4 +88,3 @@ public class AutotoolsEnvironmentVarTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,11 @@ public class AutotoolsProjectNatureTest {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
fail("could not perform basic project workspace setup");
|
fail("could not perform basic project workspace setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAutotoolsProjectNature() throws Exception {
|
public void testAutotoolsProjectNature() throws Exception {
|
||||||
IProject testProject = ProjectTools.createProject("testProject");
|
IProject testProject = ProjectTools.createProject("testProject");
|
||||||
if(testProject == null) {
|
if (testProject == null) {
|
||||||
fail("Unable to create test project");
|
fail("Unable to create test project");
|
||||||
}
|
}
|
||||||
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID));
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.junit.Test;
|
||||||
public class AutotoolsProjectTest0 {
|
public class AutotoolsProjectTest0 {
|
||||||
|
|
||||||
private IProject testProject;
|
private IProject testProject;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
|
@ -72,6 +73,7 @@ public class AutotoolsProjectTest0 {
|
||||||
x = new org.eclipse.core.runtime.Path("sample/Makefile");
|
x = new org.eclipse.core.runtime.Path("sample/Makefile");
|
||||||
assertTrue(testProject.exists(x));
|
assertTrue(testProject.exists(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.junit.Test;
|
||||||
public class AutotoolsProjectTest1 {
|
public class AutotoolsProjectTest1 {
|
||||||
|
|
||||||
private IProject testProject;
|
private IProject testProject;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
|
@ -75,6 +76,7 @@ public class AutotoolsProjectTest1 {
|
||||||
x = new org.eclipse.core.runtime.Path("sample/Makefile");
|
x = new org.eclipse.core.runtime.Path("sample/Makefile");
|
||||||
assertTrue(testProject.exists(x));
|
assertTrue(testProject.exists(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.junit.Test;
|
||||||
public class AutotoolsProjectTest2 {
|
public class AutotoolsProjectTest2 {
|
||||||
|
|
||||||
private IProject testProject;
|
private IProject testProject;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
|
@ -89,6 +90,7 @@ public class AutotoolsProjectTest2 {
|
||||||
x = new org.eclipse.core.runtime.Path("sample/Makefile");
|
x = new org.eclipse.core.runtime.Path("sample/Makefile");
|
||||||
assertTrue(testProject.exists(x));
|
assertTrue(testProject.exists(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
testProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
|
|
|
@ -60,7 +60,6 @@ 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;
|
import org.osgi.framework.FrameworkUtil;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class ProjectTools {
|
public class ProjectTools {
|
||||||
|
|
||||||
|
@ -155,8 +154,7 @@ public class ProjectTools {
|
||||||
else // otherwise, just append to project location
|
else // otherwise, just append to project location
|
||||||
args[1] = project.getLocation().append(filePath).toOSString();
|
args[1] = project.getLocation().append(filePath).toOSString();
|
||||||
try {
|
try {
|
||||||
Process proc = launcher.execute(commandPath, args, new String[0],
|
Process proc = launcher.execute(commandPath, args, new String[0], runPath, new NullProgressMonitor());
|
||||||
runPath, new NullProgressMonitor());
|
|
||||||
if (proc != null) {
|
if (proc != null) {
|
||||||
try {
|
try {
|
||||||
// Close the input of the process since we will never write to
|
// Close the input of the process since we will never write to
|
||||||
|
@ -198,7 +196,8 @@ 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$
|
||||||
return projectType.getConfigurations();
|
return projectType.getConfigurations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +216,8 @@ public class ProjectTools {
|
||||||
try {
|
try {
|
||||||
testProject.create(monitor);
|
testProject.create(monitor);
|
||||||
testProject.open(monitor);
|
testProject.open(monitor);
|
||||||
IProject newProject = CCorePlugin.getDefault().createCDTProject(description, testProject, SubMonitor.convert(monitor,25));
|
IProject newProject = CCorePlugin.getDefault().createCDTProject(description, testProject,
|
||||||
|
SubMonitor.convert(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);
|
||||||
|
@ -242,10 +242,12 @@ public class ProjectTools {
|
||||||
cfg.setConfigToolDirectory(dir);
|
cfg.setConfigToolDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
|
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor)
|
||||||
ZipFileStructureProvider structureProvider= new ZipFileStructureProvider(srcZipFile);
|
throws InvocationTargetException {
|
||||||
|
ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
|
||||||
try {
|
try {
|
||||||
ImportOperation op= new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
|
ImportOperation op = new ImportOperation(destPath, structureProvider.getRoot(), structureProvider,
|
||||||
|
new ImportOverwriteQuery());
|
||||||
op.run(monitor);
|
op.run(monitor);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// should not happen
|
// should not happen
|
||||||
|
@ -264,10 +266,9 @@ public class ProjectTools {
|
||||||
// running aclocal, autoconf, and automake
|
// running aclocal, autoconf, and automake
|
||||||
launcher.showCommand(true);
|
launcher.showCommand(true);
|
||||||
IPath commandPath = new Path("sh");
|
IPath commandPath = new Path("sh");
|
||||||
String[] cmdargs = new String[]{"genfiles.sh"};
|
String[] cmdargs = new String[] { "genfiles.sh" };
|
||||||
try {
|
try {
|
||||||
Process proc = launcher.execute(commandPath, cmdargs, new String[0],
|
Process proc = launcher.execute(commandPath, cmdargs, new String[0], runPath, new NullProgressMonitor());
|
||||||
runPath, new NullProgressMonitor());
|
|
||||||
if (proc != null) {
|
if (proc != null) {
|
||||||
try {
|
try {
|
||||||
// Close the input of the process since we will never write to
|
// Close the input of the process since we will never write to
|
||||||
|
@ -276,8 +277,8 @@ public class ProjectTools {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (launcher.waitAndRead(stdout, stderr, SubMonitor.convert(
|
if (launcher.waitAndRead(stdout, stderr,
|
||||||
monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -289,7 +290,8 @@ public class ProjectTools {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void importFilesFromZipAndGenerate(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
|
private static void importFilesFromZipAndGenerate(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor)
|
||||||
|
throws InvocationTargetException {
|
||||||
importFilesFromZip(srcZipFile, destPath, monitor);
|
importFilesFromZip(srcZipFile, destPath, monitor);
|
||||||
if (!generateFiles(destPath))
|
if (!generateFiles(destPath))
|
||||||
throw new InvocationTargetException(new Exception("Unsuccessful test file generation"));
|
throw new InvocationTargetException(new Exception("Unsuccessful test file generation"));
|
||||||
|
@ -310,16 +312,16 @@ 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 {
|
||||||
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) {
|
||||||
container= project;
|
container = project;
|
||||||
} else {
|
} else {
|
||||||
IFolder folder= project.getFolder(containerName);
|
IFolder folder = project.getFolder(containerName);
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
createFolder(folder, false, true, null);
|
createFolder(folder, false, true, null);
|
||||||
}
|
}
|
||||||
container= folder;
|
container = folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
|
@ -338,9 +340,10 @@ 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, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
public static IContainer addSourceContainerWithImport(IProject project, String containerName, File zipFile,
|
||||||
try (ZipFile file= new ZipFile(zipFile)){
|
boolean generate) throws InvocationTargetException, CoreException, IOException {
|
||||||
IContainer root= addSourceContainer(project, containerName);
|
try (ZipFile file = new ZipFile(zipFile)) {
|
||||||
|
IContainer root = addSourceContainer(project, containerName);
|
||||||
if (generate)
|
if (generate)
|
||||||
importFilesFromZipAndGenerate(file, root.getFullPath(), null);
|
importFilesFromZipAndGenerate(file, root.getFullPath(), null);
|
||||||
else
|
else
|
||||||
|
@ -361,8 +364,10 @@ 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, Path zipFilePath, boolean generate) throws InvocationTargetException, CoreException, IOException {
|
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath,
|
||||||
File zipFile = new File(FileLocator.toFileURL(FileLocator.find(FrameworkUtil.getBundle(ProjectTools.class), zipFilePath, null)).getFile());
|
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);
|
return addSourceContainerWithImport(project, containerName, zipFile, generate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +382,8 @@ 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, Path zipFilePath) throws InvocationTargetException, CoreException, IOException {
|
public static IContainer addSourceContainerWithImport(IProject project, String containerName, Path zipFilePath)
|
||||||
|
throws InvocationTargetException, CoreException, IOException {
|
||||||
return addSourceContainerWithImport(project, containerName, zipFilePath, false);
|
return addSourceContainerWithImport(project, containerName, zipFilePath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,7 +411,8 @@ public class ProjectTools {
|
||||||
* @return
|
* @return
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public static IFolder createLinkedFolder(IProject project, String folderName, final URI linkTarget) throws Exception {
|
public static IFolder createLinkedFolder(IProject project, String folderName, final URI linkTarget)
|
||||||
|
throws Exception {
|
||||||
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() {
|
||||||
|
@ -439,11 +446,12 @@ public class ProjectTools {
|
||||||
* <code> org.eclipse.ui.dialogs.ContainerGenerator</code> is too heavy
|
* <code> org.eclipse.ui.dialogs.ContainerGenerator</code> is too heavy
|
||||||
* (creates a runnable)
|
* (creates a runnable)
|
||||||
*/
|
*/
|
||||||
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
|
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor)
|
||||||
|
throws CoreException {
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
IContainer parent= folder.getParent();
|
IContainer parent = folder.getParent();
|
||||||
if (parent instanceof IFolder) {
|
if (parent instanceof IFolder) {
|
||||||
createFolder((IFolder)parent, force, local, null);
|
createFolder((IFolder) parent, force, local, null);
|
||||||
}
|
}
|
||||||
folder.create(force, local, monitor);
|
folder.create(force, local, monitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.xml.sax.SAXException;
|
||||||
public class UpdateConfigureTest {
|
public class UpdateConfigureTest {
|
||||||
|
|
||||||
private IProject testProject;
|
private IProject testProject;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
if (!ProjectTools.setup())
|
if (!ProjectTools.setup())
|
||||||
|
@ -80,10 +81,12 @@ public class UpdateConfigureTest {
|
||||||
ProjectTools.setConfigDir(testProject, "src");
|
ProjectTools.setConfigDir(testProject, "src");
|
||||||
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
||||||
assertTrue(ProjectTools.build());
|
assertTrue(ProjectTools.build());
|
||||||
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration();
|
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject)
|
||||||
|
.getActiveConfiguration();
|
||||||
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
|
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
|
||||||
assertTrue(cfg.getName().equals("Build (GNU)"));
|
assertTrue(cfg.getName().equals("Build (GNU)"));
|
||||||
Map<String, IAutotoolsOption> opts = AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(testProject, cfg.getId());
|
Map<String, IAutotoolsOption> opts = AutotoolsConfigurationManager.getInstance()
|
||||||
|
.getAutotoolsCfgOptions(testProject, cfg.getId());
|
||||||
|
|
||||||
IAutotoolsOption k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
|
IAutotoolsOption k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
|
||||||
k.setValue("true");
|
k.setValue("true");
|
||||||
|
@ -168,10 +171,12 @@ public class UpdateConfigureTest {
|
||||||
ProjectTools.setConfigDir(testProject, "src");
|
ProjectTools.setConfigDir(testProject, "src");
|
||||||
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
ProjectTools.markExecutable(testProject, "src/autogen.sh");
|
||||||
assertTrue(ProjectTools.build());
|
assertTrue(ProjectTools.build());
|
||||||
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration();
|
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject)
|
||||||
|
.getActiveConfiguration();
|
||||||
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
|
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
|
||||||
assertTrue(cfg.getName().equals("Build (GNU)"));
|
assertTrue(cfg.getName().equals("Build (GNU)"));
|
||||||
Map<String, IAutotoolsOption> opts = AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(testProject, cfg.getId());
|
Map<String, IAutotoolsOption> opts = AutotoolsConfigurationManager.getInstance()
|
||||||
|
.getAutotoolsCfgOptions(testProject, cfg.getId());
|
||||||
IAutotoolsOption configdir = opts.get(AutotoolsOptionConstants.OPT_CONFIGDIR);
|
IAutotoolsOption configdir = opts.get(AutotoolsOptionConstants.OPT_CONFIGDIR);
|
||||||
assertEquals(configdir.getType(), IAutotoolsOption.INTERNAL);
|
assertEquals(configdir.getType(), IAutotoolsOption.INTERNAL);
|
||||||
assertTrue(configdir.getValue().equals("src"));
|
assertTrue(configdir.getValue().equals("src"));
|
||||||
|
@ -399,7 +404,6 @@ public class UpdateConfigureTest {
|
||||||
assertEquals(k.getValue(), ""); //$NON-NLS-1$
|
assertEquals(k.getValue(), ""); //$NON-NLS-1$
|
||||||
k.setValue("target");
|
k.setValue("target");
|
||||||
|
|
||||||
|
|
||||||
k = opts.get(AutotoolsOptionConstants.OPT_USER);
|
k = opts.get(AutotoolsOptionConstants.OPT_USER);
|
||||||
assertTrue(k.canUpdate());
|
assertTrue(k.canUpdate());
|
||||||
assertEquals(k.getType(), IAutotoolsOption.MULTIARG);
|
assertEquals(k.getType(), IAutotoolsOption.MULTIARG);
|
||||||
|
@ -415,7 +419,8 @@ public class UpdateConfigureTest {
|
||||||
// Verify last option changed has changed in our copy, but not
|
// Verify last option changed has changed in our copy, but not
|
||||||
// in the actual options
|
// in the actual options
|
||||||
assertEquals(k.getValue(), "true");
|
assertEquals(k.getValue(), "true");
|
||||||
Map<String, IAutotoolsOption> opts2 = AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(testProject, cfg.getId());
|
Map<String, IAutotoolsOption> opts2 = AutotoolsConfigurationManager.getInstance()
|
||||||
|
.getAutotoolsCfgOptions(testProject, cfg.getId());
|
||||||
IAutotoolsOption k2 = opts2.get(AutotoolsOptionConstants.OPT_VERSION);
|
IAutotoolsOption k2 = opts2.get(AutotoolsOptionConstants.OPT_VERSION);
|
||||||
assertEquals(k2.getValue(), "false");
|
assertEquals(k2.getValue(), "false");
|
||||||
|
|
||||||
|
@ -552,7 +557,7 @@ public class UpdateConfigureTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException|ParserConfigurationException|SAXException e) {
|
} catch (IOException | ParserConfigurationException | SAXException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,22 +40,14 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class AutomakeColourizationTests {
|
public class AutomakeColourizationTests {
|
||||||
|
|
||||||
private ProjectTools tools;
|
private ProjectTools tools;
|
||||||
private IProject project;
|
private IProject project;
|
||||||
private IFile makefileAmFile;
|
private IFile makefileAmFile;
|
||||||
|
|
||||||
static String makefileAmContents =
|
static String makefileAmContents = "# This is a comment" + "\n" + "if CONDITION" + "\n" + "MACRO = case1" + "\n"
|
||||||
"# This is a comment" + "\n" +
|
+ "else" + "\n" + "MACRO = case2" + "\n" + "$(MACRO)" + "\n" + "${MACRO}" + "\n" + "";
|
||||||
"if CONDITION" + "\n" +
|
|
||||||
"MACRO = case1" + "\n" +
|
|
||||||
"else" + "\n" +
|
|
||||||
"MACRO = case2" + "\n" +
|
|
||||||
"$(MACRO)" + "\n" +
|
|
||||||
"${MACRO}" + "\n" +
|
|
||||||
"";
|
|
||||||
private IWorkbench workbench;
|
private IWorkbench workbench;
|
||||||
private AutomakefileCodeScanner codeScanner;
|
private AutomakefileCodeScanner codeScanner;
|
||||||
|
|
||||||
|
@ -67,7 +59,7 @@ public class AutomakeColourizationTests {
|
||||||
|
|
||||||
project = ProjectTools.createProject("testProjectACT");
|
project = ProjectTools.createProject("testProjectACT");
|
||||||
|
|
||||||
if(project == null) {
|
if (project == null) {
|
||||||
fail("Unable to create test project");
|
fail("Unable to create test project");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +92,7 @@ public class AutomakeColourizationTests {
|
||||||
IToken getNextToken() {
|
IToken getNextToken() {
|
||||||
return codeScanner.nextToken();
|
return codeScanner.nextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAutomakeEditorColourization() {
|
public void testAutomakeEditorColourization() {
|
||||||
// # This is a comment
|
// # This is a comment
|
||||||
|
@ -222,6 +215,7 @@ public class AutomakeColourizationTests {
|
||||||
attribute = (TextAttribute) token.getData();
|
attribute = (TextAttribute) token.getData();
|
||||||
assertEquals(ColorManager.MAKE_MACRO_REF_RGB, attribute.getForeground().getRGB());
|
assertEquals(ColorManager.MAKE_MACRO_REF_RGB, attribute.getForeground().getRGB());
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
project.delete(true, false, ProjectTools.getMonitor());
|
project.delete(true, false, ProjectTools.getMonitor());
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.ui.PlatformUI;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class AutomakeEditorTests {
|
public class AutomakeEditorTests {
|
||||||
|
|
||||||
private ProjectTools tools;
|
private ProjectTools tools;
|
||||||
|
@ -45,7 +44,7 @@ public class AutomakeEditorTests {
|
||||||
public void testAutomakeEditorAssociation() throws Exception {
|
public void testAutomakeEditorAssociation() throws Exception {
|
||||||
project = ProjectTools.createProject("testProjectAET");
|
project = ProjectTools.createProject("testProjectAET");
|
||||||
|
|
||||||
if(project == null) {
|
if (project == null) {
|
||||||
fail("Unable to create test project");
|
fail("Unable to create test project");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
public class AutomakeTextHoverTest {
|
public class AutomakeTextHoverTest {
|
||||||
|
|
||||||
private ProjectTools tools;
|
private ProjectTools tools;
|
||||||
|
@ -56,8 +55,7 @@ public class AutomakeTextHoverTest {
|
||||||
// 32 is after the M in MACRO
|
// 32 is after the M in MACRO
|
||||||
"\t" + "echo $(MACRO)" + "\n" +
|
"\t" + "echo $(MACRO)" + "\n" +
|
||||||
// 38 (before the tab)
|
// 38 (before the tab)
|
||||||
"\t" + "echo $@" + "\n" +
|
"\t" + "echo $@" + "\n" + "\n" +
|
||||||
"\n" +
|
|
||||||
// 48
|
// 48
|
||||||
"target2: target1" + "\n" +
|
"target2: target1" + "\n" +
|
||||||
// 65 (before the tab)
|
// 65 (before the tab)
|
||||||
|
@ -65,13 +63,11 @@ public class AutomakeTextHoverTest {
|
||||||
// 80 (before the tab)
|
// 80 (before the tab)
|
||||||
"\t" + "echo $@" + "\n" +
|
"\t" + "echo $@" + "\n" +
|
||||||
// 89 (before the tab)
|
// 89 (before the tab)
|
||||||
"\t" + "echo $<" + "\n" +
|
"\t" + "echo $<" + "\n" + "\n" +
|
||||||
"\n" +
|
|
||||||
// 99
|
// 99
|
||||||
"target3: target1 target2" + "\n" +
|
"target3: target1 target2" + "\n" +
|
||||||
// 124 (before the tab)
|
// 124 (before the tab)
|
||||||
"\t" + "echo $?" + "\n" +
|
"\t" + "echo $?" + "\n" + "";
|
||||||
"";
|
|
||||||
private IWorkbench workbench;
|
private IWorkbench workbench;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -82,7 +78,7 @@ public class AutomakeTextHoverTest {
|
||||||
|
|
||||||
project = ProjectTools.createProject("testProjectATHT");
|
project = ProjectTools.createProject("testProjectATHT");
|
||||||
|
|
||||||
if(project == null) {
|
if (project == null) {
|
||||||
fail("Unable to create test project");
|
fail("Unable to create test project");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +127,7 @@ public class AutomakeTextHoverTest {
|
||||||
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetHoverInfoTargetName2() {
|
public void testGetHoverInfoTargetName2() {
|
||||||
// hover between the $ and the @ in target2
|
// hover between the $ and the @ in target2
|
||||||
|
@ -149,6 +146,7 @@ public class AutomakeTextHoverTest {
|
||||||
assertEquals("target2", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
assertEquals("target2", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetHoverInfoForTargetDependency() {
|
public void testGetHoverInfoForTargetDependency() {
|
||||||
// hover between the $ and the < in target2
|
// hover between the $ and the < in target2
|
||||||
|
@ -167,6 +165,7 @@ public class AutomakeTextHoverTest {
|
||||||
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
assertEquals("target1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetHoverInfoForTargetDependencies() {
|
public void testGetHoverInfoForTargetDependencies() {
|
||||||
// hover between the $ and the ? in target3
|
// hover between the $ and the ? in target3
|
||||||
|
@ -186,6 +185,7 @@ public class AutomakeTextHoverTest {
|
||||||
textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetHoverForMacro1() {
|
public void testGetHoverForMacro1() {
|
||||||
Display.getDefault().syncExec(() -> {
|
Display.getDefault().syncExec(() -> {
|
||||||
|
@ -204,6 +204,7 @@ public class AutomakeTextHoverTest {
|
||||||
assertEquals("case1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
assertEquals("case1", textHover.getHoverInfo(automakeEditor.getAutomakeSourceViewer(), hoverRegion));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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
|
||||||
|
|
|
@ -17,10 +17,6 @@ import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({ AutomakeColourizationTests.class, AutomakeTextHoverTest.class, AutomakeEditorTests.class })
|
||||||
AutomakeColourizationTests.class,
|
|
||||||
AutomakeTextHoverTest.class,
|
|
||||||
AutomakeEditorTests.class
|
|
||||||
})
|
|
||||||
public class EditorTests {
|
public class EditorTests {
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,7 @@ public abstract class AbstractTest {
|
||||||
SWTBotShell shell = bot.shell("Preferences");
|
SWTBotShell shell = bot.shell("Preferences");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
bot.text().setText("Workspace");
|
bot.text().setText("Workspace");
|
||||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General",
|
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Workspace"));
|
||||||
"Workspace"));
|
|
||||||
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
|
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
|
||||||
if (buildAuto != null && buildAuto.isChecked()) {
|
if (buildAuto != null && buildAuto.isChecked()) {
|
||||||
buildAuto.click();
|
buildAuto.click();
|
||||||
|
@ -135,10 +134,8 @@ public abstract class AbstractTest {
|
||||||
// Ensure that the C/C++ perspective is chosen automatically
|
// Ensure that the C/C++ perspective is chosen automatically
|
||||||
// and doesn't require user intervention
|
// and doesn't require user intervention
|
||||||
bot.text().setText("Perspectives");
|
bot.text().setText("Perspectives");
|
||||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General",
|
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Perspectives"));
|
||||||
"Perspectives"));
|
clickRadioButtonInGroup("Always open", "Open the associated perspective when creating a new project");
|
||||||
clickRadioButtonInGroup("Always open",
|
|
||||||
"Open the associated perspective when creating a new project");
|
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
|
|
||||||
AbstractTest.projectName = projectName;
|
AbstractTest.projectName = projectName;
|
||||||
|
@ -146,18 +143,15 @@ public abstract class AbstractTest {
|
||||||
shell = bot.shell("New Project");
|
shell = bot.shell("New Project");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
bot.text().setText("C Project");
|
bot.text().setText("C Project");
|
||||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "C/C++",
|
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "C/C++", "C Project"));
|
||||||
"C Project"));
|
|
||||||
bot.button("Next >").click();
|
bot.button("Next >").click();
|
||||||
|
|
||||||
bot.textWithLabel("Project name:").setText(projectName);
|
bot.textWithLabel("Project name:").setText(projectName);
|
||||||
bot.tree().expandNode("GNU Autotools")
|
bot.tree().expandNode("GNU Autotools").select("Hello World ANSI C Autotools Project");
|
||||||
.select("Hello World ANSI C Autotools Project");
|
|
||||||
bot.button("Finish").click();
|
bot.button("Finish").click();
|
||||||
bot.waitUntil(Conditions.shellCloses(shell));
|
bot.waitUntil(Conditions.shellCloses(shell));
|
||||||
|
|
||||||
IProjectNature nature = checkProject().getNature(
|
IProjectNature nature = checkProject().getNature("org.eclipse.cdt.autotools.core.autotoolsNatureV2");
|
||||||
"org.eclipse.cdt.autotools.core.autotoolsNatureV2");
|
|
||||||
assertNotNull(nature);
|
assertNotNull(nature);
|
||||||
|
|
||||||
projectExplorer = bot.viewByTitle("Project Explorer");
|
projectExplorer = bot.viewByTitle("Project Explorer");
|
||||||
|
@ -186,8 +180,7 @@ public abstract class AbstractTest {
|
||||||
* @param node
|
* @param node
|
||||||
* The text of the node to select.
|
* The text of the node to select.
|
||||||
*/
|
*/
|
||||||
public NodeAvailableAndSelect(SWTBotTree tree, String parent,
|
public NodeAvailableAndSelect(SWTBotTree tree, String parent, String node) {
|
||||||
String node) {
|
|
||||||
this.tree = tree;
|
this.tree = tree;
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
@ -215,10 +208,8 @@ public abstract class AbstractTest {
|
||||||
*/
|
*/
|
||||||
public static void enterProjectFolder() {
|
public static void enterProjectFolder() {
|
||||||
projectExplorer.setFocus();
|
projectExplorer.setFocus();
|
||||||
projectExplorer.bot().tree().select(projectName).contextMenu("Go Into")
|
projectExplorer.bot().tree().select(projectName).contextMenu("Go Into").click();
|
||||||
.click();
|
bot.waitUntil(waitForWidget(WidgetMatcherFactory.withText(projectName), projectExplorer.getWidget()));
|
||||||
bot.waitUntil(waitForWidget(WidgetMatcherFactory.withText(projectName),
|
|
||||||
projectExplorer.getWidget()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,8 +224,7 @@ public abstract class AbstractTest {
|
||||||
// If the "Forward" button is not found, already at the top level.
|
// If the "Forward" button is not found, already at the top level.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SWTBotToolbarButton backButton = projectExplorer
|
SWTBotToolbarButton backButton = projectExplorer.toolbarPushButton("Back to Workspace");
|
||||||
.toolbarPushButton("Back to Workspace");
|
|
||||||
if (backButton.isEnabled()) {
|
if (backButton.isEnabled()) {
|
||||||
backButton.click();
|
backButton.click();
|
||||||
bot.waitUntil(widgetIsEnabled(forwardButton));
|
bot.waitUntil(widgetIsEnabled(forwardButton));
|
||||||
|
@ -247,8 +237,7 @@ public abstract class AbstractTest {
|
||||||
* other radio button in the group that is already selected. Workaround for
|
* other radio button in the group that is already selected. Workaround for
|
||||||
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=344484
|
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=344484
|
||||||
*/
|
*/
|
||||||
public static void clickRadioButtonInGroup(String mnemonicText,
|
public static void clickRadioButtonInGroup(String mnemonicText, final String inGroup) {
|
||||||
final String inGroup) {
|
|
||||||
UIThreadRunnable.syncExec(() -> {
|
UIThreadRunnable.syncExec(() -> {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Matcher<Button> matcher = allOf(inGroup(inGroup), widgetOfType(Button.class),
|
Matcher<Button> matcher = allOf(inGroup(inGroup), widgetOfType(Button.class),
|
||||||
|
@ -270,13 +259,11 @@ public abstract class AbstractTest {
|
||||||
bot.radioInGroup(mnemonicText, inGroup).click();
|
bot.radioInGroup(mnemonicText, inGroup).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clickContextMenu(AbstractSWTBot<? extends Control> bot,
|
public static void clickContextMenu(AbstractSWTBot<? extends Control> bot, String... texts) {
|
||||||
String... texts) {
|
|
||||||
new SWTBotMenu(ContextMenuHelper.contextMenu(bot, texts)).click();
|
new SWTBotMenu(ContextMenuHelper.contextMenu(bot, texts)).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clickVolatileContextMenu(
|
public static void clickVolatileContextMenu(AbstractSWTBot<? extends Control> bot, String... texts) {
|
||||||
AbstractSWTBot<? extends Control> bot, String... texts) {
|
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
final int maxTries = 2;
|
final int maxTries = 2;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -292,8 +279,7 @@ public abstract class AbstractTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clickProjectContextMenu(String... texts) {
|
public static void clickProjectContextMenu(String... texts) {
|
||||||
clickVolatileContextMenu(bot.viewByTitle("Project Explorer").bot()
|
clickVolatileContextMenu(bot.viewByTitle("Project Explorer").bot().tree().select(projectName), texts);
|
||||||
.tree().select(projectName), texts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,15 +300,12 @@ public abstract class AbstractTest {
|
||||||
menu.click();
|
menu.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SWTBotShell openProperties(String parentCategory,
|
public static SWTBotShell openProperties(String parentCategory, String category) {
|
||||||
String category) {
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Properties");
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
|
||||||
"Properties");
|
|
||||||
SWTBotShell shell = bot.shell("Properties for " + projectName);
|
SWTBotShell shell = bot.shell("Properties for " + projectName);
|
||||||
shell.activate();
|
shell.activate();
|
||||||
bot.text().setText(category);
|
bot.text().setText(category);
|
||||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), parentCategory,
|
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), parentCategory, category));
|
||||||
category));
|
|
||||||
shell.activate();
|
shell.activate();
|
||||||
return shell;
|
return shell;
|
||||||
}
|
}
|
||||||
|
@ -340,10 +323,8 @@ public abstract class AbstractTest {
|
||||||
public static SWTBotView viewConsole(String consoleType) {
|
public static SWTBotView viewConsole(String consoleType) {
|
||||||
SWTBotView view = bot.viewByPartName("Console");
|
SWTBotView view = bot.viewByPartName("Console");
|
||||||
view.setFocus();
|
view.setFocus();
|
||||||
SWTBotToolbarDropDownButton b = view
|
SWTBotToolbarDropDownButton b = view.toolbarDropDownButton("Display Selected Console");
|
||||||
.toolbarDropDownButton("Display Selected Console");
|
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*" + consoleType + ".*");
|
||||||
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*" + consoleType
|
|
||||||
+ ".*");
|
|
||||||
focusMainShell();
|
focusMainShell();
|
||||||
b.menuItem(withRegex).click();
|
b.menuItem(withRegex).click();
|
||||||
try {
|
try {
|
||||||
|
@ -379,8 +360,7 @@ public abstract class AbstractTest {
|
||||||
for (final SWTBotShell shell : shells) {
|
for (final SWTBotShell shell : shells) {
|
||||||
if (!shell.equals(mainShell)) {
|
if (!shell.equals(mainShell)) {
|
||||||
String shellTitle = shell.getText();
|
String shellTitle = shell.getText();
|
||||||
if (shellTitle.length() > 0
|
if (shellTitle.length() > 0 && !shellTitle.startsWith("Quick Access")) {
|
||||||
&& !shellTitle.startsWith("Quick Access")) {
|
|
||||||
UIThreadRunnable.syncExec(() -> {
|
UIThreadRunnable.syncExec(() -> {
|
||||||
if (shell.widget.getParent() != null && !shell.isOpen()) {
|
if (shell.widget.getParent() != null && !shell.isOpen()) {
|
||||||
shell.close();
|
shell.close();
|
||||||
|
|
|
@ -25,15 +25,14 @@ import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* TestToolActions.class,
|
* TestToolActions.class,
|
||||||
* TestEnvironmentVars.class,
|
* TestEnvironmentVars.class,
|
||||||
* TestMakeTargets.class,
|
* TestMakeTargets.class,
|
||||||
* SetConfigurationParameter.class,
|
* SetConfigurationParameter.class,
|
||||||
*/
|
*/
|
||||||
AutoconfTests.class
|
AutoconfTests.class })
|
||||||
})
|
|
||||||
|
|
||||||
public class AutomatedIntegrationSuite {
|
public class AutomatedIntegrationSuite {
|
||||||
// needed for this class to compile
|
// needed for this class to compile
|
||||||
|
@ -41,9 +40,7 @@ public class AutomatedIntegrationSuite {
|
||||||
public static void beforeClassMethod() {
|
public static void beforeClassMethod() {
|
||||||
// Verify that the necessary binaries are available, and if they are not,
|
// Verify that the necessary binaries are available, and if they are not,
|
||||||
// the tests will be ignored.
|
// the tests will be ignored.
|
||||||
String[] testBinaryCommands = { "libtool --version",
|
String[] testBinaryCommands = { "libtool --version", "autoconf --version", "automake --version" };
|
||||||
"autoconf --version",
|
|
||||||
"automake --version" };
|
|
||||||
try {
|
try {
|
||||||
for (String cmd : testBinaryCommands) {
|
for (String cmd : testBinaryCommands) {
|
||||||
Process process = ProcessFactory.getFactory().exec(cmd);
|
Process process = ProcessFactory.getFactory().exec(cmd);
|
||||||
|
|
|
@ -62,8 +62,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
// Set the configure parameters to be --enable-jeff via user-defined
|
// Set the configure parameters to be --enable-jeff via user-defined
|
||||||
// options
|
// options
|
||||||
SWTBotShell shell = openProperties("Autotools", "Configure Settings");
|
SWTBotShell shell = openProperties("Autotools", "Configure Settings");
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||||
text.typeText("--enable-jeff");
|
text.typeText("--enable-jeff");
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
|
@ -71,8 +70,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
|
|
||||||
// Create new build configurations that will be used throughout tests
|
// Create new build configurations that will be used throughout tests
|
||||||
projectExplorer.bot().tree().select(projectName);
|
projectExplorer.bot().tree().select(projectName);
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage...");
|
||||||
"Build Configurations", "Manage...");
|
|
||||||
shell = bot.shell(projectName + ": Manage Configurations");
|
shell = bot.shell(projectName + ": Manage Configurations");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
bot.button("New...").click();
|
bot.button("New...").click();
|
||||||
|
@ -80,8 +78,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
shell.activate();
|
shell.activate();
|
||||||
SWTBotText t = bot.textWithLabel("Name:");
|
SWTBotText t = bot.textWithLabel("Name:");
|
||||||
t.setText("debug");
|
t.setText("debug");
|
||||||
AbstractTest.clickRadioButtonInGroup("Existing configuration",
|
AbstractTest.clickRadioButtonInGroup("Existing configuration", "Copy settings from");
|
||||||
"Copy settings from");
|
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
shell = bot.shell(projectName + ": Manage Configurations");
|
shell = bot.shell(projectName + ": Manage Configurations");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
|
@ -90,8 +87,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
shell.activate();
|
shell.activate();
|
||||||
t = bot.textWithLabel("Name:");
|
t = bot.textWithLabel("Name:");
|
||||||
t.setText("default");
|
t.setText("default");
|
||||||
AbstractTest.clickRadioButtonInGroup("Default configuration",
|
AbstractTest.clickRadioButtonInGroup("Default configuration", "Copy settings from");
|
||||||
"Copy settings from");
|
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
shell = bot.shell(projectName + ": Manage Configurations");
|
shell = bot.shell(projectName + ": Manage Configurations");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
|
@ -145,8 +141,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
@Test
|
@Test
|
||||||
public void t2canBuildWithConfigParm() throws Exception {
|
public void t2canBuildWithConfigParm() throws Exception {
|
||||||
projectExplorer.bot().tree().select(projectName);
|
projectExplorer.bot().tree().select(projectName);
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project");
|
||||||
"Build Project");
|
|
||||||
|
|
||||||
// Wait until the project is built
|
// Wait until the project is built
|
||||||
SWTBotShell shell = bot.shell("Build Project");
|
SWTBotShell shell = bot.shell("Build Project");
|
||||||
|
@ -192,8 +187,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
|
|
||||||
String output = viewConsole("Configure").bot().styledText().getText();
|
String output = viewConsole("Configure").bot().styledText().getText();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(
|
Pattern p = Pattern.compile(".*WARNING:.*unrecognized.*--enable-jeff.*", Pattern.DOTALL);
|
||||||
".*WARNING:.*unrecognized.*--enable-jeff.*", Pattern.DOTALL);
|
|
||||||
Matcher m = p.matcher(output);
|
Matcher m = p.matcher(output);
|
||||||
assertTrue(m.matches());
|
assertTrue(m.matches());
|
||||||
|
|
||||||
|
@ -201,8 +195,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
// Verifies fix for bug: #308261
|
// Verifies fix for bug: #308261
|
||||||
long oldDate = f.lastModified();
|
long oldDate = f.lastModified();
|
||||||
projectExplorer.bot().tree().select(projectName);
|
projectExplorer.bot().tree().select(projectName);
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project");
|
||||||
"Build Project");
|
|
||||||
path = project.getLocation();
|
path = project.getLocation();
|
||||||
// We need to wait until the a.out file is created so
|
// We need to wait until the a.out file is created so
|
||||||
// sleep a bit and look for it...give up after 120 seconds
|
// sleep a bit and look for it...give up after 120 seconds
|
||||||
|
@ -225,8 +218,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
@Test
|
@Test
|
||||||
public void t3newConfigCopiesParms() throws Exception {
|
public void t3newConfigCopiesParms() throws Exception {
|
||||||
projectExplorer.bot().tree().select(projectName);
|
projectExplorer.bot().tree().select(projectName);
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage...");
|
||||||
"Build Configurations", "Manage...");
|
|
||||||
SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
|
SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
shell = bot.shell(projectName + ": Manage Configurations");
|
shell = bot.shell(projectName + ": Manage Configurations");
|
||||||
|
@ -248,8 +240,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue(configs.getText().contains("debug"));
|
assertTrue(configs.getText().contains("debug"));
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||||
String val = text.getText();
|
String val = text.getText();
|
||||||
assertEquals("--enable-jeff", val);
|
assertEquals("--enable-jeff", val);
|
||||||
|
@ -266,16 +257,14 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||||
configs.setSelection("default");
|
configs.setSelection("default");
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
text = bot.textWithLabel("Additional command-line options");
|
text = bot.textWithLabel("Additional command-line options");
|
||||||
val = text.getText();
|
val = text.getText();
|
||||||
assertEquals("", val);
|
assertEquals("", val);
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
// Build the project again and verify we get a build-debug directory
|
// Build the project again and verify we get a build-debug directory
|
||||||
projectExplorer.bot().tree().select(projectName);
|
projectExplorer.bot().tree().select(projectName);
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project");
|
||||||
"Build Project");
|
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||||
assertNotNull(workspace);
|
assertNotNull(workspace);
|
||||||
IWorkspaceRoot root = workspace.getRoot();
|
IWorkspaceRoot root = workspace.getRoot();
|
||||||
|
@ -362,8 +351,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
}
|
}
|
||||||
assertEquals(2, foundUser);
|
assertEquals(2, foundUser);
|
||||||
|
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage...");
|
||||||
"Build Configurations", "Manage...");
|
|
||||||
shell = bot.shell(projectName + ": Manage Configurations");
|
shell = bot.shell(projectName + ": Manage Configurations");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
table = bot.table();
|
table = bot.table();
|
||||||
|
@ -392,15 +380,13 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
SWTBotShell shell = bot.shell("Properties for " + projectName);
|
SWTBotShell shell = bot.shell("Properties for " + projectName);
|
||||||
shell.activate();
|
shell.activate();
|
||||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||||
String setting = text.getText();
|
String setting = text.getText();
|
||||||
assertEquals("--enable-jeff", setting);
|
assertEquals("--enable-jeff", setting);
|
||||||
configs.setFocus();
|
configs.setFocus();
|
||||||
configs.setSelection("debug");
|
configs.setSelection("debug");
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
text = bot.textWithLabel("Additional command-line options");
|
text = bot.textWithLabel("Additional command-line options");
|
||||||
setting = text.getText();
|
setting = text.getText();
|
||||||
assertEquals("", setting);
|
assertEquals("", setting);
|
||||||
|
@ -412,16 +398,14 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||||
configs.setSelection("debug");
|
configs.setSelection("debug");
|
||||||
assertTrue(configs.getText().contains("debug"));
|
assertTrue(configs.getText().contains("debug"));
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
text = bot.textWithLabel("Additional command-line options");
|
text = bot.textWithLabel("Additional command-line options");
|
||||||
setting = text.getText();
|
setting = text.getText();
|
||||||
assertEquals("--enable-jeff", setting);
|
assertEquals("--enable-jeff", setting);
|
||||||
configs.setFocus();
|
configs.setFocus();
|
||||||
configs.setSelection("default");
|
configs.setSelection("default");
|
||||||
assertTrue(configs.getText().contains("default"));
|
assertTrue(configs.getText().contains("default"));
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
text = bot.textWithLabel("Additional command-line options");
|
text = bot.textWithLabel("Additional command-line options");
|
||||||
setting = text.getText();
|
setting = text.getText();
|
||||||
assertEquals("", setting);
|
assertEquals("", setting);
|
||||||
|
@ -455,16 +439,14 @@ public class SetConfigurationParameter extends AbstractTest {
|
||||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||||
assertTrue(configs.getText().contains("release"));
|
assertTrue(configs.getText().contains("release"));
|
||||||
assertTrue(configs.getText().contains("Active"));
|
assertTrue(configs.getText().contains("Active"));
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||||
String setting = text.getText();
|
String setting = text.getText();
|
||||||
assertEquals("--enable-jeff", setting);
|
assertEquals("--enable-jeff", setting);
|
||||||
configs.setFocus();
|
configs.setFocus();
|
||||||
configs.setSelection("debug");
|
configs.setSelection("debug");
|
||||||
assertTrue(configs.getText().contains("debug"));
|
assertTrue(configs.getText().contains("debug"));
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
text = bot.textWithLabel("Additional command-line options");
|
text = bot.textWithLabel("Additional command-line options");
|
||||||
setting = text.getText();
|
setting = text.getText();
|
||||||
assertEquals("", setting);
|
assertEquals("", setting);
|
||||||
|
|
|
@ -45,15 +45,13 @@ public class TestEnvironmentVars extends AbstractTest {
|
||||||
SWTBotShell shell = openProperties("Autotools", "Configure Settings");
|
SWTBotShell shell = openProperties("Autotools", "Configure Settings");
|
||||||
// Set the configure parameters to be --enable-jeff via user-defined
|
// Set the configure parameters to be --enable-jeff via user-defined
|
||||||
// options
|
// options
|
||||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||||
.select("Advanced");
|
|
||||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||||
text.typeText("${some_var}");
|
text.typeText("${some_var}");
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||||
|
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Reconfigure Project");
|
||||||
"Reconfigure Project");
|
|
||||||
IPath path = checkProject().getLocation();
|
IPath path = checkProject().getLocation();
|
||||||
File f = null;
|
File f = null;
|
||||||
// We need to wait until the config.status file is created so
|
// We need to wait until the config.status file is created so
|
||||||
|
@ -96,8 +94,7 @@ public class TestEnvironmentVars extends AbstractTest {
|
||||||
shell.activate();
|
shell.activate();
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
bot.waitUntil(Conditions.shellCloses(shell));
|
bot.waitUntil(Conditions.shellCloses(shell));
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Reconfigure Project");
|
||||||
"Reconfigure Project");
|
|
||||||
|
|
||||||
IPath path = checkProject().getLocation();
|
IPath path = checkProject().getLocation();
|
||||||
File f = null;
|
File f = null;
|
||||||
|
@ -148,20 +145,16 @@ public class TestEnvironmentVars extends AbstractTest {
|
||||||
bot.textWithLabel("Command").setText("");
|
bot.textWithLabel("Command").setText("");
|
||||||
// Choose three different forms, some using quotes to allow blanks in
|
// Choose three different forms, some using quotes to allow blanks in
|
||||||
// them
|
// them
|
||||||
bot.textWithLabel("Command")
|
bot.textWithLabel("Command").typeText(
|
||||||
.typeText(
|
|
||||||
"some_var1=\"a boat\" some_var2='a train' some_var3=car fake_configure some_var4=\"a wagon\" some_var5='a plane' some_var6=skates");
|
"some_var1=\"a boat\" some_var2='a train' some_var3=car fake_configure some_var4=\"a wagon\" some_var5='a plane' some_var6=skates");
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
// Reconfigure the project and make sure the env variables are seen in
|
// Reconfigure the project and make sure the env variables are seen in
|
||||||
// the script
|
// the script
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Reconfigure Project");
|
||||||
"Reconfigure Project");
|
|
||||||
focusMainShell();
|
focusMainShell();
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
Pattern p = Pattern.compile(
|
Pattern p = Pattern.compile(".*a boat.*a train.*car.*a wagon.*a plane.*skates.*", Pattern.DOTALL);
|
||||||
".*a boat.*a train.*car.*a wagon.*a plane.*skates.*",
|
|
||||||
Pattern.DOTALL);
|
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,7 @@ public class TestMakeTargets extends AbstractTest {
|
||||||
assertTrue(f.exists());
|
assertTrue(f.exists());
|
||||||
|
|
||||||
projectExplorer.bot().tree().getTreeItem(projectName).select();
|
projectExplorer.bot().tree().getTreeItem(projectName).select();
|
||||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Targets", "Build...");
|
||||||
"Build Targets", "Build...");
|
|
||||||
shell = bot.shell("Build Targets");
|
shell = bot.shell("Build Targets");
|
||||||
shell.activate();
|
shell.activate();
|
||||||
bot.table().getTableItem("info").select();
|
bot.table().getTableItem("info").select();
|
||||||
|
@ -79,8 +78,7 @@ public class TestMakeTargets extends AbstractTest {
|
||||||
bot.button("Build").click();
|
bot.button("Build").click();
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
p = Pattern.compile(".*make check.*Making check in src.*",
|
p = Pattern.compile(".*make check.*Making check in src.*", Pattern.DOTALL);
|
||||||
Pattern.DOTALL);
|
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking aclocal in.*" + projectName
|
Pattern p = Pattern.compile(".*Invoking aclocal in.*" + projectName + ".*aclocal --help.*Usage: aclocal.*",
|
||||||
+ ".*aclocal --help.*Usage: aclocal.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
// Verify we still don't have an aclocal.m4 file yet
|
// Verify we still don't have an aclocal.m4 file yet
|
||||||
f = new File(path.toOSString());
|
f = new File(path.toOSString());
|
||||||
|
@ -85,8 +85,7 @@ public class TestToolActions extends AbstractTest {
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
p = Pattern.compile(".*Invoking aclocal in.*" + projectName
|
p = Pattern.compile(".*Invoking aclocal in.*" + projectName + ".*aclocal.*", Pattern.DOTALL);
|
||||||
+ ".*aclocal.*", Pattern.DOTALL);
|
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
// We need to wait until the aclocal.m4 file is created so
|
// We need to wait until the aclocal.m4 file is created so
|
||||||
// sleep a bit and look for it...give up after 20 seconds
|
// sleep a bit and look for it...give up after 20 seconds
|
||||||
|
@ -115,8 +114,7 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking autoconf in.*" + projectName
|
Pattern p = Pattern.compile(".*Invoking autoconf in.*" + projectName + ".*autoconf.*", Pattern.DOTALL);
|
||||||
+ ".*autoconf.*", Pattern.DOTALL);
|
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
// We need to wait until the configure file is created so
|
// We need to wait until the configure file is created so
|
||||||
// sleep a bit and look for it...give up after 20 seconds
|
// sleep a bit and look for it...give up after 20 seconds
|
||||||
|
@ -134,13 +132,11 @@ public class TestToolActions extends AbstractTest {
|
||||||
// explorer menu directly from the configure.ac file.
|
// explorer menu directly from the configure.ac file.
|
||||||
assertTrue(f.delete());
|
assertTrue(f.delete());
|
||||||
enterProjectFolder();
|
enterProjectFolder();
|
||||||
clickVolatileContextMenu(
|
clickVolatileContextMenu(projectExplorer.bot().tree().select("configure.ac"), "Invoke Autotools",
|
||||||
projectExplorer.bot().tree().select("configure.ac"),
|
"Invoke Autoconf");
|
||||||
"Invoke Autotools", "Invoke Autoconf");
|
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
p = Pattern.compile(".*Invoking autoconf in.*" + projectName
|
p = Pattern.compile(".*Invoking autoconf in.*" + projectName + ".*autoconf.*", Pattern.DOTALL);
|
||||||
+ ".*autoconf.*", Pattern.DOTALL);
|
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
// We need to wait until the configure file is created so
|
// We need to wait until the configure file is created so
|
||||||
// sleep a bit and look for it...give up after 20 seconds
|
// sleep a bit and look for it...give up after 20 seconds
|
||||||
|
@ -181,8 +177,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking automake in.*" + projectName
|
Pattern p = Pattern.compile(".*Invoking automake in.*" + projectName + ".*automake --help.*Usage:.*",
|
||||||
+ ".*automake --help.*Usage:.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
// Verify we still don't have Makefile.in files yet
|
// Verify we still don't have Makefile.in files yet
|
||||||
f = new File(path.toOSString());
|
f = new File(path.toOSString());
|
||||||
|
@ -201,8 +197,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
bot.button("OK").click();
|
bot.button("OK").click();
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
p = Pattern.compile(".*Invoking automake in.*" + projectName
|
p = Pattern.compile(
|
||||||
+ ".*automake --add-missing Makefile src/Makefile.*",
|
".*Invoking automake in.*" + projectName + ".*automake --add-missing Makefile src/Makefile.*",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
// We need to wait until the Makefile.in files are created so
|
// We need to wait until the Makefile.in files are created so
|
||||||
|
@ -234,8 +230,9 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking libtoolize in.*" + projectName
|
Pattern p = Pattern.compile(
|
||||||
+ ".*libtoolize --help.*Usage: .*libtoolize.*", Pattern.DOTALL);
|
".*Invoking libtoolize in.*" + projectName + ".*libtoolize --help.*Usage: .*libtoolize.*",
|
||||||
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +247,9 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking autoheader in.*" + projectName
|
Pattern p = Pattern.compile(
|
||||||
+ ".*autoheader --help.*Usage:.*autoheader.*", Pattern.DOTALL);
|
".*Invoking autoheader in.*" + projectName + ".*autoheader --help.*Usage:.*autoheader.*",
|
||||||
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,8 +286,9 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking autoreconf in.*" + projectName
|
Pattern p = Pattern.compile(
|
||||||
+ ".*autoreconf --help.*Usage: .*autoreconf.*", Pattern.DOTALL);
|
".*Invoking autoreconf in.*" + projectName + ".*autoreconf --help.*Usage: .*autoreconf.*",
|
||||||
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
clickProjectContextMenu("Invoke Autotools", "Invoke Autoreconf");
|
clickProjectContextMenu("Invoke Autotools", "Invoke Autoreconf");
|
||||||
shell = bot.shell("Autoreconf Options");
|
shell = bot.shell("Autoreconf Options");
|
||||||
|
@ -434,8 +433,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
SWTBotView consoleView = viewConsole("Autotools");
|
SWTBotView consoleView = viewConsole("Autotools");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
Pattern p = Pattern.compile(".*Invoking aclocal in.*" + projectName
|
Pattern p = Pattern.compile(".*Invoking aclocal in.*" + projectName + ".*automake --help.*Usage:.*automake.*",
|
||||||
+ ".*automake --help.*Usage:.*automake.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
|
|
||||||
clickProjectContextMenu("Invoke Autotools", "Invoke Automake");
|
clickProjectContextMenu("Invoke Autotools", "Invoke Automake");
|
||||||
|
@ -446,8 +445,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
p = Pattern.compile(".*Invoking automake in.*" + projectName
|
p = Pattern.compile(".*Invoking automake in.*" + projectName + ".*autoconf --help.*Usage:.*autoconf.*",
|
||||||
+ ".*autoconf --help.*Usage:.*autoconf.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
|
|
||||||
clickProjectContextMenu("Invoke Autotools", "Invoke Autoheader");
|
clickProjectContextMenu("Invoke Autotools", "Invoke Autoheader");
|
||||||
|
@ -458,8 +457,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
p = Pattern.compile(".*Invoking autoheader in.*" + projectName
|
p = Pattern.compile(".*Invoking autoheader in.*" + projectName + ".*autoreconf --help.*Usage:.*autoreconf.*",
|
||||||
+ ".*autoreconf --help.*Usage:.*autoreconf.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
|
|
||||||
clickProjectContextMenu("Invoke Autotools", "Invoke Autoreconf");
|
clickProjectContextMenu("Invoke Autotools", "Invoke Autoreconf");
|
||||||
|
@ -470,8 +469,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
p = Pattern.compile(".*Invoking autoreconf in.*" + projectName
|
p = Pattern.compile(".*Invoking autoreconf in.*" + projectName + ".*libtoolize --help.*Usage:.*libtoolize.*",
|
||||||
+ ".*libtoolize --help.*Usage:.*libtoolize.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
|
|
||||||
clickProjectContextMenu("Invoke Autotools", "Invoke Libtoolize");
|
clickProjectContextMenu("Invoke Autotools", "Invoke Libtoolize");
|
||||||
|
@ -482,8 +481,8 @@ public class TestToolActions extends AbstractTest {
|
||||||
consoleView = bot.viewByPartName("Console");
|
consoleView = bot.viewByPartName("Console");
|
||||||
consoleView.setFocus();
|
consoleView.setFocus();
|
||||||
// Verify we got some help output to the console
|
// Verify we got some help output to the console
|
||||||
p = Pattern.compile(".*Invoking libtoolize in.*" + projectName
|
p = Pattern.compile(".*Invoking libtoolize in.*" + projectName + ".*aclocal --help.*Usage:.*aclocal.*",
|
||||||
+ ".*aclocal --help.*Usage:.*aclocal.*", Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,7 @@ import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({ TestMacroParser.class, TestTokenizer.class, TestShellParser.class })
|
||||||
TestMacroParser.class,
|
|
||||||
TestTokenizer.class,
|
|
||||||
TestShellParser.class
|
|
||||||
})
|
|
||||||
public class AutoconfTests {
|
public class AutoconfTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,22 +125,21 @@ public abstract class BaseParserTest {
|
||||||
if (!allowErrors) {
|
if (!allowErrors) {
|
||||||
if (!errors.isEmpty())
|
if (!errors.isEmpty())
|
||||||
fail("got errors" + errors.get(0));
|
fail("got errors" + errors.get(0));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
assertFalse(errors.isEmpty());
|
assertFalse(errors.isEmpty());
|
||||||
|
|
||||||
return root2;
|
return root2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkError(String msgKey) {
|
protected void checkError(String msgKey) {
|
||||||
for (ParseException exc: errors) {
|
for (ParseException exc : errors) {
|
||||||
if (exc.getMessage().contains(msgKey))
|
if (exc.getMessage().contains(msgKey))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String any = "";
|
String any = "";
|
||||||
if (!errors.isEmpty())
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkError(String msgKey, int line) {
|
protected void checkError(String msgKey, int line) {
|
||||||
|
@ -160,7 +159,8 @@ public abstract class BaseParserTest {
|
||||||
if (possible == null)
|
if (possible == null)
|
||||||
fail("did not find any error: " + msgKey);
|
fail("did not find any error: " + msgKey);
|
||||||
else
|
else
|
||||||
fail("did not find error: " + msgKey + " on line: " + line +", but found one at " + possible.getLineNumber());
|
fail("did not find error: " + msgKey + " on line: " + line + ", but found one at "
|
||||||
|
+ possible.getLineNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,8 +176,7 @@ public abstract class BaseParserTest {
|
||||||
validateSourceElement(element);
|
validateSourceElement(element);
|
||||||
AutoconfElement[] kids = element.getChildren();
|
AutoconfElement[] kids = element.getChildren();
|
||||||
for (int i = 0; i < kids.length; i++) {
|
for (int i = 0; i < kids.length; i++) {
|
||||||
if (kids[i].getStartOffset() < element.getStartOffset()
|
if (kids[i].getStartOffset() < element.getStartOffset() || kids[i].getEndOffset() > element.getEndOffset())
|
||||||
|| kids[i].getEndOffset() > element.getEndOffset())
|
|
||||||
fail(describeElement(kids[i]) + " not inside parent " + describeElement(element));
|
fail(describeElement(kids[i]) + " not inside parent " + describeElement(element));
|
||||||
validateSourceTree(kids[i]);
|
validateSourceTree(kids[i]);
|
||||||
}
|
}
|
||||||
|
@ -226,15 +225,15 @@ public abstract class BaseParserTest {
|
||||||
assertEquals(elements.length, assertTreeStructure(tree, elements, 0));
|
assertEquals(elements.length, assertTreeStructure(tree, elements, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int assertTreeStructure(AutoconfElement tree, String[] elements,
|
private int assertTreeStructure(AutoconfElement tree, String[] elements, int elementIdx) {
|
||||||
int elementIdx) {
|
|
||||||
AutoconfElement[] kids = tree.getChildren();
|
AutoconfElement[] kids = tree.getChildren();
|
||||||
for (int j = 0; j < kids.length; j++) {
|
for (int j = 0; j < kids.length; j++) {
|
||||||
if (elementIdx >= elements.length || elements[elementIdx] == null) {
|
if (elementIdx >= elements.length || elements[elementIdx] == null) {
|
||||||
fail("extra children in " + tree + " at " + kids[j]);
|
fail("extra children in " + tree + " at " + kids[j]);
|
||||||
}
|
}
|
||||||
if (!kids[j].getName().equals(elements[elementIdx]))
|
if (!kids[j].getName().equals(elements[elementIdx]))
|
||||||
fail("did not match " + elements[elementIdx] + ", instead got " + kids[j].getClass().getSimpleName() + "=" + kids[j].getName());
|
fail("did not match " + elements[elementIdx] + ", instead got " + kids[j].getClass().getSimpleName()
|
||||||
|
+ "=" + kids[j].getName());
|
||||||
|
|
||||||
elementIdx++;
|
elementIdx++;
|
||||||
if (kids[j].getChildren().length > 0) {
|
if (kids[j].getChildren().length > 0) {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfMacroElement;
|
||||||
import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfParser;
|
import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfParser;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test parsing with macros
|
* Test parsing with macros
|
||||||
* @author eswartz
|
* @author eswartz
|
||||||
|
@ -41,9 +40,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testComments() {
|
public void testComments() {
|
||||||
//
|
//
|
||||||
String text =
|
String text = "dnl first line\n" + "dnl second line\n";
|
||||||
"dnl first line\n" +
|
|
||||||
"dnl second line\n";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
Object[] kids = root.getChildren();
|
Object[] kids = root.getChildren();
|
||||||
// these are stripped
|
// these are stripped
|
||||||
|
@ -54,9 +51,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing1() {
|
public void testMacroParsing1() {
|
||||||
//
|
//
|
||||||
String text =
|
String text = "AC_REQUIRE([AM_SANITY_CHECK])\n" + "";
|
||||||
"AC_REQUIRE([AM_SANITY_CHECK])\n" +
|
|
||||||
"";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
assertTreeStructure(root, new String[] { "AC_REQUIRE", "AM_SANITY_CHECK", null });
|
assertTreeStructure(root, new String[] { "AC_REQUIRE", "AM_SANITY_CHECK", null });
|
||||||
|
|
||||||
|
@ -71,7 +66,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
assertEquals(1, args.length);
|
assertEquals(1, args.length);
|
||||||
assertTrue(args[0] instanceof AutoconfMacroArgumentElement);
|
assertTrue(args[0] instanceof AutoconfMacroArgumentElement);
|
||||||
|
|
||||||
assertEquals("AM_SANITY_CHECK", ((AutoconfMacroArgumentElement)args[0]).getName());
|
assertEquals("AM_SANITY_CHECK", ((AutoconfMacroArgumentElement) args[0]).getName());
|
||||||
assertEquals("AM_SANITY_CHECK", macro.getParameter(0));
|
assertEquals("AM_SANITY_CHECK", macro.getParameter(0));
|
||||||
|
|
||||||
// keep quotes in source
|
// keep quotes in source
|
||||||
|
@ -82,9 +77,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing2() {
|
public void testMacroParsing2() {
|
||||||
//
|
//
|
||||||
String text =
|
String text = "AC_TWO_ARGS(first,second)\n" + "";
|
||||||
"AC_TWO_ARGS(first,second)\n" +
|
|
||||||
"";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
assertTreeStructure(root, new String[] { "AC_TWO_ARGS", "first", "second", null });
|
assertTreeStructure(root, new String[] { "AC_TWO_ARGS", "first", "second", null });
|
||||||
|
|
||||||
|
@ -98,9 +91,9 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
AutoconfElement[] args = macro.getChildren();
|
AutoconfElement[] args = macro.getChildren();
|
||||||
assertEquals(2, args.length);
|
assertEquals(2, args.length);
|
||||||
assertTrue(args[0] instanceof AutoconfMacroArgumentElement);
|
assertTrue(args[0] instanceof AutoconfMacroArgumentElement);
|
||||||
assertEquals("first", ((AutoconfMacroArgumentElement)args[0]).getName());
|
assertEquals("first", ((AutoconfMacroArgumentElement) args[0]).getName());
|
||||||
assertTrue(args[1] instanceof AutoconfMacroArgumentElement);
|
assertTrue(args[1] instanceof AutoconfMacroArgumentElement);
|
||||||
assertEquals("second", ((AutoconfMacroArgumentElement)args[1]).getName());
|
assertEquals("second", ((AutoconfMacroArgumentElement) args[1]).getName());
|
||||||
assertEquals("first", macro.getParameter(0));
|
assertEquals("first", macro.getParameter(0));
|
||||||
assertEquals("second", macro.getParameter(1));
|
assertEquals("second", macro.getParameter(1));
|
||||||
|
|
||||||
|
@ -112,9 +105,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing3() {
|
public void testMacroParsing3() {
|
||||||
//
|
//
|
||||||
String text =
|
String text = "AC_ONE_ARG( [quoted( arg ), second] )\n" + "";
|
||||||
"AC_ONE_ARG( [quoted( arg ), second] )\n" +
|
|
||||||
"";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
assertTreeStructure(root, new String[] { "AC_ONE_ARG", "quoted( arg ), second", null });
|
assertTreeStructure(root, new String[] { "AC_ONE_ARG", "quoted( arg ), second", null });
|
||||||
|
|
||||||
|
@ -130,7 +121,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
assertTrue(args[0] instanceof AutoconfMacroArgumentElement);
|
assertTrue(args[0] instanceof AutoconfMacroArgumentElement);
|
||||||
|
|
||||||
// spaces removed from outermost arguments, but not inner
|
// spaces removed from outermost arguments, but not inner
|
||||||
assertEquals("quoted( arg ), second", ((AutoconfMacroArgumentElement)args[0]).getName());
|
assertEquals("quoted( arg ), second", ((AutoconfMacroArgumentElement) args[0]).getName());
|
||||||
assertEquals("quoted( arg ), second", macro.getParameter(0));
|
assertEquals("quoted( arg ), second", macro.getParameter(0));
|
||||||
|
|
||||||
assertEqualSource("[quoted( arg ), second]", args[0]);
|
assertEqualSource("[quoted( arg ), second]", args[0]);
|
||||||
|
@ -140,11 +131,8 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing4() {
|
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" +
|
+ " [AM_AUTOMAKE_VERSION([1.4-p6])])\r\n" + "\r\n" + "";
|
||||||
" [AM_AUTOMAKE_VERSION([1.4-p6])])\r\n" +
|
|
||||||
"\r\n" +
|
|
||||||
"";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
AutoconfElement[] kids = root.getChildren();
|
AutoconfElement[] kids = root.getChildren();
|
||||||
assertEquals(1, kids.length);
|
assertEquals(1, kids.length);
|
||||||
|
@ -166,30 +154,15 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
public void testMacroParsing5() {
|
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 = "AC_MSG_CHECKING(for working $2)\n"
|
||||||
"AC_MSG_CHECKING(for working $2)\n" +
|
+ "# Run test in a subshell; some versions of sh will print an error if\n"
|
||||||
"# Run test in a subshell; some versions of sh will print an error if\n" +
|
+ "# an executable is not found, even if stderr is redirected.\n"
|
||||||
"# an executable is not found, even if stderr is redirected.\n" +
|
+ "# Redirect stdin to placate older versions of autoconf. Sigh.\n"
|
||||||
"# Redirect stdin to placate older versions of autoconf. Sigh.\n" +
|
+ "if ($2 --version) < /dev/null > /dev/null 2>&1; then\n" + " $1=$2\n" + " AC_MSG_RESULT(found)\n"
|
||||||
"if ($2 --version) < /dev/null > /dev/null 2>&1; then\n" +
|
+ "else\n" + " $1=\"$3/missing $2\"\n" + " AC_MSG_RESULT(missing)\n" + "fi\n" + "AC_SUBST($1)";
|
||||||
" $1=$2\n" +
|
String text = "AC_DEFUN([AM_MISSING_PROG],\n" + "[" + arg2 + "])\n" + "";
|
||||||
" AC_MSG_RESULT(found)\n" +
|
|
||||||
"else\n" +
|
|
||||||
" $1=\"$3/missing $2\"\n" +
|
|
||||||
" AC_MSG_RESULT(missing)\n" +
|
|
||||||
"fi\n" +
|
|
||||||
"AC_SUBST($1)";
|
|
||||||
String text =
|
|
||||||
"AC_DEFUN([AM_MISSING_PROG],\n" +
|
|
||||||
"[" + arg2 + "])\n" +
|
|
||||||
"";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
assertTreeStructure(root, new String[] {
|
assertTreeStructure(root, new String[] { "AC_DEFUN", "AM_MISSING_PROG", arg2, null, });
|
||||||
"AC_DEFUN",
|
|
||||||
"AM_MISSING_PROG",
|
|
||||||
arg2,
|
|
||||||
null,
|
|
||||||
});
|
|
||||||
AutoconfElement[] kids = root.getChildren();
|
AutoconfElement[] kids = root.getChildren();
|
||||||
assertEquals(1, kids.length);
|
assertEquals(1, kids.length);
|
||||||
assertTrue(kids[0] instanceof AutoconfMacroElement);
|
assertTrue(kids[0] instanceof AutoconfMacroElement);
|
||||||
|
@ -210,9 +183,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMacroParsing6() {
|
public void testMacroParsing6() {
|
||||||
// empty arguments
|
// empty arguments
|
||||||
String text =
|
String text = "AC_DEFUN( ,\n" + ")\n";
|
||||||
"AC_DEFUN( ,\n" +
|
|
||||||
")\n";
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
AutoconfElement[] kids = root.getChildren();
|
AutoconfElement[] kids = root.getChildren();
|
||||||
assertEquals(1, kids.length);
|
assertEquals(1, kids.length);
|
||||||
|
@ -232,32 +203,27 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithErrorUnmatchedLeftParen() {
|
public void testWithErrorUnmatchedLeftParen() {
|
||||||
String text =
|
String text = "AC_BAD_MACRO(\n";
|
||||||
"AC_BAD_MACRO(\n";
|
|
||||||
|
|
||||||
AutoconfElement root = parse(text, true);
|
AutoconfElement root = parse(text, true);
|
||||||
assertEquals(1, root.getChildren().length);
|
assertEquals(1, root.getChildren().length);
|
||||||
assertTrue(root.getChildren()[0] instanceof AutoconfMacroElement);
|
assertTrue(root.getChildren()[0] instanceof AutoconfMacroElement);
|
||||||
checkError(AutoconfEditorMessages.getString(AutoconfParser.UNMATCHED_LEFT_PARENTHESIS));
|
checkError(AutoconfEditorMessages.getString(AutoconfParser.UNMATCHED_LEFT_PARENTHESIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithErrorUnmatchedRightParen() {
|
public void testWithErrorUnmatchedRightParen() {
|
||||||
String text =
|
String text = "AC_BAD_MACRO())\n";
|
||||||
"AC_BAD_MACRO())\n";
|
|
||||||
|
|
||||||
AutoconfElement root = parse(text, true);
|
AutoconfElement root = parse(text, true);
|
||||||
assertEquals(1, root.getChildren().length);
|
assertEquals(1, root.getChildren().length);
|
||||||
assertTrue(root.getChildren()[0] instanceof AutoconfMacroElement);
|
assertTrue(root.getChildren()[0] instanceof AutoconfMacroElement);
|
||||||
checkError(AutoconfEditorMessages.getString(AutoconfParser.UNMATCHED_RIGHT_PARENTHESIS));
|
checkError(AutoconfEditorMessages.getString(AutoconfParser.UNMATCHED_RIGHT_PARENTHESIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoFalseUnmatchedRightParen() {
|
public void testNoFalseUnmatchedRightParen() {
|
||||||
String text =
|
String text = "AC_BAD_MACRO()\n" + "(\n" + "cd foo;\n" + "if test -f myfile; then exit 1; fi\n" + ")\n";
|
||||||
"AC_BAD_MACRO()\n" +
|
|
||||||
"(\n"+
|
|
||||||
"cd foo;\n"+
|
|
||||||
"if test -f myfile; then exit 1; fi\n"+
|
|
||||||
")\n";
|
|
||||||
|
|
||||||
// nothing but the macro and 'if' is detected as meaningful
|
// nothing but the macro and 'if' is detected as meaningful
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
|
@ -268,8 +234,7 @@ public class TestMacroParser extends BaseParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNestedMacro() {
|
public void testNestedMacro() {
|
||||||
String text =
|
String text = "AC_1(AC_2())\n";
|
||||||
"AC_1(AC_2())\n";
|
|
||||||
|
|
||||||
AutoconfElement root = parse(text);
|
AutoconfElement root = parse(text);
|
||||||
assertEquals(1, root.getChildren().length);
|
assertEquals(1, root.getChildren().length);
|
||||||
|
|
|
@ -32,31 +32,18 @@ public class TestShellParser extends BaseParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHERE() {
|
public void testHERE() {
|
||||||
String HERE_TEXT =
|
String HERE_TEXT = "\n" + "while true; do \n" + "AM_INIT_AUTOMAKE([confusion], [$2], EOF)\n" + "done\n";
|
||||||
"\n"+
|
String text = "cat <<EOF" + HERE_TEXT + "EOF\n" + "blah";
|
||||||
"while true; do \n"+
|
|
||||||
"AM_INIT_AUTOMAKE([confusion], [$2], EOF)\n"+
|
|
||||||
"done\n";
|
|
||||||
String text = "cat <<EOF"+
|
|
||||||
HERE_TEXT +
|
|
||||||
"EOF\n" +
|
|
||||||
"blah";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
|
|
||||||
// only see a macro call, not a loop
|
// only see a macro call, not a loop
|
||||||
assertTreeStructure(tree, new String[] { "AM_INIT_AUTOMAKE", "confusion", "$2", "EOF", null });
|
assertTreeStructure(tree, new String[] { "AM_INIT_AUTOMAKE", "confusion", "$2", "EOF", null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHERE2() {
|
public void testHERE2() {
|
||||||
String HERE_TEXT =
|
String HERE_TEXT = "\n" + "while true; do \n" + "AM_INIT_AUTOMAKE([confusion], [$2], EOF)\n" + "done\n";
|
||||||
"\n"+
|
String text = "cat <<-EOF" + HERE_TEXT + "EOF\n" + "blah";
|
||||||
"while true; do \n"+
|
|
||||||
"AM_INIT_AUTOMAKE([confusion], [$2], EOF)\n"+
|
|
||||||
"done\n";
|
|
||||||
String text = "cat <<-EOF"+
|
|
||||||
HERE_TEXT +
|
|
||||||
"EOF\n" +
|
|
||||||
"blah";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
|
|
||||||
// only see a macro call, not a loop
|
// only see a macro call, not a loop
|
||||||
|
@ -65,209 +52,156 @@ public class TestShellParser extends BaseParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIf0() {
|
public void testIf0() {
|
||||||
String text = "# comment\n"+
|
String text = "# comment\n" + "\tif true; then\n" + "\t\tfoo;\n" + "\tfi\n";
|
||||||
"\tif true; then\n" +
|
|
||||||
"\t\tfoo;\n"+
|
|
||||||
"\tfi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] { "if" });
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIf1() {
|
public void testIf1() {
|
||||||
String text = "# comment\n"+
|
String text = "# comment\n" + "\tif true; then\n" + "\t\tAC_SOMETHING();\n" + "\tfi\n";
|
||||||
"\tif true; then\n" +
|
|
||||||
"\t\tAC_SOMETHING();\n"+
|
|
||||||
"\tfi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] { "if", "AC_SOMETHING", "", null, null });
|
assertTreeStructure(tree, new String[] { "if", "AC_SOMETHING", "", null, null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfElse0() {
|
public void testIfElse0() {
|
||||||
String text = "# comment\n"+
|
String text = "# comment\n" + "\tif true; then\n" + "\t\tfoo;\n" + "\telse\n" + "\t\tbar;\n" + "\tfi\n";
|
||||||
"\tif true; then\n" +
|
|
||||||
"\t\tfoo;\n"+
|
|
||||||
"\telse\n"+
|
|
||||||
"\t\tbar;\n"+
|
|
||||||
"\tfi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] { "if", "else", null });
|
assertTreeStructure(tree, new String[] { "if", "else", null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfElse1() {
|
public void testIfElse1() {
|
||||||
String text = "# comment\n"+
|
String text = "# comment\n" + "\tif true; then\n" + "\t\tAC_ONE(...);\n" + "\telse\n"
|
||||||
"\tif true; then\n" +
|
+ "\t\tAC_TWO(AC_THREE());\n" + "\tfi\n";
|
||||||
"\t\tAC_ONE(...);\n"+
|
|
||||||
"\telse\n"+
|
|
||||||
"\t\tAC_TWO(AC_THREE());\n"+
|
|
||||||
"\tfi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree, new String[] { "if", "AC_ONE", "...", null, "else", "AC_TWO", "AC_THREE", "AC_THREE",
|
||||||
"if",
|
"", null, null, null, null, null });
|
||||||
"AC_ONE",
|
|
||||||
"...",
|
|
||||||
null,
|
|
||||||
"else",
|
|
||||||
"AC_TWO",
|
|
||||||
"AC_THREE",
|
|
||||||
"AC_THREE",
|
|
||||||
"",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null});
|
|
||||||
|
|
||||||
AutoconfElement[] kids = tree.getChildren();
|
AutoconfElement[] kids = tree.getChildren();
|
||||||
assertEqualSource("AC_ONE(...)", kids[0].getChildren()[0]);
|
assertEqualSource("AC_ONE(...)", kids[0].getChildren()[0]);
|
||||||
assertEqualSource("AC_TWO(AC_THREE())", kids[0].getChildren()[1].getChildren()[0]);
|
assertEqualSource("AC_TWO(AC_THREE())", kids[0].getChildren()[1].getChildren()[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIf2() {
|
public void testIf2() {
|
||||||
String text =
|
String text = "if blah\n" + "then fi\n";
|
||||||
"if blah\n" +
|
|
||||||
"then fi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] { "if" });
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfElif() {
|
public void testIfElif() {
|
||||||
String text = "# comment\n"+
|
String text = "# comment\n" + "\tif true; then\n" + "\t\tAC_ONE(...);\n" + "\telif false; then \n"
|
||||||
"\tif true; then\n" +
|
+ "\t\tAC_TWO(...);\n" + "\tfi\n";
|
||||||
"\t\tAC_ONE(...);\n"+
|
|
||||||
"\telif false; then \n"+
|
|
||||||
"\t\tAC_TWO(...);\n"+
|
|
||||||
"\tfi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree,
|
||||||
"if",
|
new String[] { "if", "AC_ONE", "...", null, "elif", "AC_TWO", "...", null, null, null });
|
||||||
"AC_ONE",
|
|
||||||
"...",
|
|
||||||
null,
|
|
||||||
"elif",
|
|
||||||
"AC_TWO",
|
|
||||||
"...",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfErr1() {
|
public void testIfErr1() {
|
||||||
String text =
|
String text = "if then fi\n";
|
||||||
"if then fi\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.INVALID_SPECIFIER, "then"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.INVALID_SPECIFIER, "then"));
|
||||||
assertTreeStructure(tree, new String[] { "if" });
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfErr2() {
|
public void testIfErr2() {
|
||||||
String text =
|
String text = "if true; do fi\n";
|
||||||
"if true; do fi\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getString(AutoconfParser.INVALID_DO));
|
checkError(AutoconfEditorMessages.getString(AutoconfParser.INVALID_DO));
|
||||||
assertTreeStructure(tree, new String[] { "if" });
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfErr3() {
|
public void testIfErr3() {
|
||||||
String text =
|
String text = "if; else bar; fi\n";
|
||||||
"if; else bar; fi\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.MISSING_SPECIFIER, "then"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.MISSING_SPECIFIER, "then"));
|
||||||
assertTreeStructure(tree, new String[] { "if", "else", null });
|
assertTreeStructure(tree, new String[] { "if", "else", null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfErr4() {
|
public void testIfErr4() {
|
||||||
String text =
|
String text = "if true; then stmt fi\n";
|
||||||
"if true; then stmt fi\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.INVALID_TERMINATION, "fi"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.INVALID_TERMINATION, "fi"));
|
||||||
assertTreeStructure(tree, new String[] { "if" });
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfErr5() {
|
public void testIfErr5() {
|
||||||
String text =
|
String text = "if true; then\n";
|
||||||
"if true; then\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "if"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "if"));
|
||||||
assertTreeStructure(tree, new String[] { "if" });
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfErr6() {
|
public void testIfErr6() {
|
||||||
String text =
|
String text = "if true; then foo; else\n";
|
||||||
"if true; then foo; else\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(2, errors.size());
|
assertEquals(2, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "if"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "if"));
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "else"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "else"));
|
||||||
assertTreeStructure(tree, new String[] { "if", "else", null });
|
assertTreeStructure(tree, new String[] { "if", "else", null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhile() {
|
public void testWhile() {
|
||||||
String text =
|
String text = "while true; do foo; done\n";
|
||||||
"while true; do foo; done\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] { "while" });
|
assertTreeStructure(tree, new String[] { "while" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhile2() {
|
public void testWhile2() {
|
||||||
String text =
|
String text = "while true\n" + "do\n" + "AC_SOMETHING(...); done\n";
|
||||||
"while true\n" +
|
|
||||||
"do\n"+
|
|
||||||
"AC_SOMETHING(...); done\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] { "while", "AC_SOMETHING", "...", null, null });
|
assertTreeStructure(tree, new String[] { "while", "AC_SOMETHING", "...", null, null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhileErr() {
|
public void testWhileErr() {
|
||||||
String text =
|
String text = "while; AC_SOMETHING(...) done\n";
|
||||||
"while; AC_SOMETHING(...) done\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(2, errors.size());
|
assertEquals(2, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.MISSING_SPECIFIER, "do"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.MISSING_SPECIFIER, "do"));
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.INVALID_TERMINATION, "done"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.INVALID_TERMINATION, "done"));
|
||||||
assertTreeStructure(tree, new String[] { "while", "AC_SOMETHING", "...", null, null });
|
assertTreeStructure(tree, new String[] { "while", "AC_SOMETHING", "...", null, null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWhileErr2() {
|
public void testWhileErr2() {
|
||||||
String text =
|
String text = "while true; do AC_SOMETHING(...)\n";
|
||||||
"while true; do AC_SOMETHING(...)\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "while"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "while"));
|
||||||
assertTreeStructure(tree, new String[] { "while", "AC_SOMETHING", "...", null, null });
|
assertTreeStructure(tree, new String[] { "while", "AC_SOMETHING", "...", null, null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCase() {
|
public void testCase() {
|
||||||
String text =
|
String text = "case $VAL in\n" + "linux-*-*) AC_FIRST($VAL) ; true ;;\n" + "bsd-* | macosx-*) : ;;\n"
|
||||||
"case $VAL in\n"+
|
+ "*) echo \"I dunno $VAL\";;\n" + "esac\n";
|
||||||
"linux-*-*) AC_FIRST($VAL) ; true ;;\n"+
|
|
||||||
"bsd-* | macosx-*) : ;;\n"+
|
|
||||||
"*) echo \"I dunno $VAL\";;\n"+
|
|
||||||
"esac\n";
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree,
|
||||||
"case",
|
new String[] { "case", "linux-*-*", "AC_FIRST", "$VAL", null, null, "bsd-* | macosx-*", "*", null });
|
||||||
"linux-*-*",
|
|
||||||
"AC_FIRST",
|
|
||||||
"$VAL",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"bsd-* | macosx-*",
|
|
||||||
"*",
|
|
||||||
null
|
|
||||||
});
|
|
||||||
|
|
||||||
AutoconfElement[] kids = tree.getChildren();
|
AutoconfElement[] kids = tree.getChildren();
|
||||||
assertEquals(1, kids.length);
|
assertEquals(1, kids.length);
|
||||||
assertTrue(kids[0] instanceof AutoconfCaseElement);
|
assertTrue(kids[0] instanceof AutoconfCaseElement);
|
||||||
|
|
||||||
AutoconfCaseElement caseEl = (AutoconfCaseElement) kids[0];
|
AutoconfCaseElement caseEl = (AutoconfCaseElement) kids[0];
|
||||||
assertEqualSource(text.substring(0, text.length()-1), caseEl);
|
assertEqualSource(text.substring(0, text.length() - 1), caseEl);
|
||||||
|
|
||||||
assertEquals(3, caseEl.getChildren().length);
|
assertEquals(3, caseEl.getChildren().length);
|
||||||
|
|
||||||
|
@ -289,10 +223,10 @@ public class TestShellParser extends BaseParserTest {
|
||||||
assertEquals(0, caseCond.getChildren().length);
|
assertEquals(0, caseCond.getChildren().length);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCaseErr() {
|
public void testCaseErr() {
|
||||||
String text =
|
String text = "case $VAL; linux-*-*) AC_FIRST($VAL) ; true esac\n";
|
||||||
"case $VAL; linux-*-*) AC_FIRST($VAL) ; true esac\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(2, errors.size());
|
assertEquals(2, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getString(AutoconfParser.INVALID_IN));
|
checkError(AutoconfEditorMessages.getString(AutoconfParser.INVALID_IN));
|
||||||
|
@ -308,10 +242,10 @@ public class TestShellParser extends BaseParserTest {
|
||||||
assertEqualSource("AC_FIRST($VAL)", caseCond.getChildren()[0]);
|
assertEqualSource("AC_FIRST($VAL)", caseCond.getChildren()[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCaseErr2() {
|
public void testCaseErr2() {
|
||||||
String text =
|
String text = "case $VAL in\n";
|
||||||
"case $VAL in\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "case"));
|
checkError(AutoconfEditorMessages.getFormattedString(AutoconfParser.UNTERMINATED_CONSTRUCT, "case"));
|
||||||
|
@ -319,137 +253,84 @@ public class TestShellParser extends BaseParserTest {
|
||||||
assertTreeStructure(tree, new String[] { "case" });
|
assertTreeStructure(tree, new String[] { "case" });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForIn() {
|
public void testForIn() {
|
||||||
// don't get upset by 'in'
|
// don't get upset by 'in'
|
||||||
String text =
|
String text = "for VAL in 1 2 3 4; do echo $VAL; done\n";
|
||||||
"for VAL in 1 2 3 4; do echo $VAL; done\n";
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
|
|
||||||
assertTreeStructure(tree, new String[] { "for" });
|
assertTreeStructure(tree, new String[] { "for" });
|
||||||
AutoconfElement[] kids = tree.getChildren();
|
AutoconfElement[] kids = tree.getChildren();
|
||||||
|
|
||||||
AutoconfElement forEl = kids[0];
|
AutoconfElement forEl = kids[0];
|
||||||
assertEqualSource(text.substring(0, text.length()-1), forEl);
|
assertEqualSource(text.substring(0, text.length() - 1), forEl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForDo() {
|
public void testForDo() {
|
||||||
// don't get upset by parentheses
|
// don't get upset by parentheses
|
||||||
String text =
|
String text = "for (( AC_1; AC_2(); AC_3(...) )); do echo $VAL; done\n";
|
||||||
"for (( AC_1; AC_2(); AC_3(...) )); do echo $VAL; done\n";
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
|
|
||||||
assertTreeStructure(tree, new String[] { "for", "AC_1", "AC_2", "", null, "AC_3", "...", null, null });
|
assertTreeStructure(tree, new String[] { "for", "AC_1", "AC_2", "", null, "AC_3", "...", null, null });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUntil() {
|
public void testUntil() {
|
||||||
String text =
|
String text = "until false; do AC_SOMETHING(...); done\n";
|
||||||
"until false; do AC_SOMETHING(...); done\n";
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
assertTreeStructure(tree, new String[] { "until", "AC_SOMETHING", "...", null, null });
|
assertTreeStructure(tree, new String[] { "until", "AC_SOMETHING", "...", null, null });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelect() {
|
public void testSelect() {
|
||||||
String text =
|
String text = "select VAR in 1 2 3; do AC_SOMETHING(...); done\n" + "select VAR; do AC_SOMETHING; done\n";
|
||||||
"select VAR in 1 2 3; do AC_SOMETHING(...); done\n"+
|
|
||||||
"select VAR; do AC_SOMETHING; done\n";
|
|
||||||
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree,
|
||||||
"select",
|
new String[] { "select", "AC_SOMETHING", "...", null, null, "select", "AC_SOMETHING", null });
|
||||||
"AC_SOMETHING",
|
|
||||||
"...",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"select",
|
|
||||||
"AC_SOMETHING",
|
|
||||||
null
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplex1() {
|
public void testComplex1() {
|
||||||
String text =
|
String text = "AM_INIT_AUTOMAKE([foo1], 1.96)\n" + "while true; do \n" + " var=shift;\n"
|
||||||
"AM_INIT_AUTOMAKE([foo1], 1.96)\n" +
|
+ " if [ test -f \"$var\"] ; then\n" + " AC_SOMETHING($var);\n" + " fi\n" + "done;\n"
|
||||||
"while true; do \n" +
|
+ "AM_GENERATE(Makefile)\n";
|
||||||
" var=shift;\n" +
|
|
||||||
" if [ test -f \"$var\"] ; then\n"+
|
|
||||||
" AC_SOMETHING($var);\n"+
|
|
||||||
" fi\n"+
|
|
||||||
"done;\n"+
|
|
||||||
"AM_GENERATE(Makefile)\n";
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree, new String[] { "AM_INIT_AUTOMAKE", "foo1", "1.96", null, "while", "if",
|
||||||
"AM_INIT_AUTOMAKE",
|
"AC_SOMETHING", "$var", null, null, null, "AM_GENERATE", "Makefile", null });
|
||||||
"foo1",
|
|
||||||
"1.96",
|
|
||||||
null,
|
|
||||||
"while",
|
|
||||||
"if",
|
|
||||||
"AC_SOMETHING",
|
|
||||||
"$var",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"AM_GENERATE",
|
|
||||||
"Makefile",
|
|
||||||
null
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplex2() {
|
public void testComplex2() {
|
||||||
String text =
|
String text = "if true; then\n" + "AC_CANONICAL_HOST\n" + "else\n" + "case foo in \n" + " 3) 1 ;;\n"
|
||||||
"if true; then\n" +
|
+ "esac;\n" + "fi\n";
|
||||||
"AC_CANONICAL_HOST\n" +
|
|
||||||
"else\n" +
|
|
||||||
"case foo in \n" +
|
|
||||||
" 3) 1 ;;\n" +
|
|
||||||
"esac;\n" +
|
|
||||||
"fi\n";
|
|
||||||
AutoconfElement tree = parse(text, false);
|
AutoconfElement tree = parse(text, false);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree, new String[] { "if", "AC_CANONICAL_HOST", "else", "case", "3", null, null, null });
|
||||||
"if",
|
|
||||||
"AC_CANONICAL_HOST",
|
|
||||||
"else",
|
|
||||||
"case",
|
|
||||||
"3",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyClose() {
|
public void testEarlyClose() {
|
||||||
String text =
|
String text = "if true; then foo ; fi\n" + "fi\n" + "while true; do done;\n";
|
||||||
"if true; then foo ; fi\n"+
|
|
||||||
"fi\n"+
|
|
||||||
"while true; do done;\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree, new String[] { "if", "while" });
|
||||||
"if",
|
|
||||||
"while"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverlapping() {
|
public void testOverlapping() {
|
||||||
String text =
|
String text = "for foo\n" + "if bar\n";
|
||||||
"for foo\n"+
|
|
||||||
"if bar\n";
|
|
||||||
AutoconfElement tree = parse(text, true);
|
AutoconfElement tree = parse(text, true);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree, new String[] { "for", "if" });
|
||||||
"for",
|
|
||||||
"if"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDollar() {
|
public void testDollar() {
|
||||||
// dollars guard keywords
|
// dollars guard keywords
|
||||||
String text =
|
String text = "if [ $if == 3 ] ; then $for; fi\n";
|
||||||
"if [ $if == 3 ] ; then $for; fi\n";
|
|
||||||
AutoconfElement tree = parse(text);
|
AutoconfElement tree = parse(text);
|
||||||
assertTreeStructure(tree, new String[] {
|
assertTreeStructure(tree, new String[] { "if" });
|
||||||
"if"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.eclipse.jface.text.Document;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test autoconf tokenizer. The tokenizer mainly is used to detect boundaries and keywords
|
* Test autoconf tokenizer. The tokenizer mainly is used to detect boundaries and keywords
|
||||||
* and is not a full shell tokenizer.
|
* and is not a full shell tokenizer.
|
||||||
|
@ -69,6 +68,7 @@ public class TestTokenizer {
|
||||||
protected void checkNoErrors() {
|
protected void checkNoErrors() {
|
||||||
assertEquals(0, tokenizerErrors.size());
|
assertEquals(0, tokenizerErrors.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmpty() {
|
public void testEmpty() {
|
||||||
IDocument document = createDocument("");
|
IDocument document = createDocument("");
|
||||||
|
@ -76,6 +76,7 @@ public class TestTokenizer {
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(0, tokens.size());
|
assertEquals(0, tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEOL1() {
|
public void testEOL1() {
|
||||||
IDocument document = createDocument("\n");
|
IDocument document = createDocument("\n");
|
||||||
|
@ -84,6 +85,7 @@ public class TestTokenizer {
|
||||||
assertEquals(1, tokens.size());
|
assertEquals(1, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(0), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEOL2() {
|
public void testEOL2() {
|
||||||
IDocument document = createDocument("\r\n");
|
IDocument document = createDocument("\r\n");
|
||||||
|
@ -92,6 +94,7 @@ public class TestTokenizer {
|
||||||
assertEquals(1, tokens.size());
|
assertEquals(1, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.EOL, "\r\n");
|
checkToken(tokens.get(0), document, ITokenConstants.EOL, "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEOL3() {
|
public void testEOL3() {
|
||||||
IDocument document = createDocument("\n\r\n\n");
|
IDocument document = createDocument("\n\r\n\n");
|
||||||
|
@ -102,6 +105,7 @@ public class TestTokenizer {
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\r\n");
|
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\r\n");
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellText() {
|
public void testShellText() {
|
||||||
// default mode is shell
|
// default mode is shell
|
||||||
|
@ -110,13 +114,12 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(4, tokens.size());
|
assertEquals(4, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "random");
|
||||||
"random");
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.WORD,
|
checkToken(tokens.get(2), document, ITokenConstants.WORD, "stuff");
|
||||||
"stuff");
|
|
||||||
checkToken(tokens.get(3), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(3), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellTokens() {
|
public void testShellTokens() {
|
||||||
// default mode is shell
|
// default mode is shell
|
||||||
|
@ -125,18 +128,16 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(8, tokens.size());
|
assertEquals(8, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.SH_WHILE,
|
checkToken(tokens.get(0), document, ITokenConstants.SH_WHILE, "while");
|
||||||
"while");
|
checkToken(tokens.get(1), document, ITokenConstants.WORD, "true");
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.WORD,
|
|
||||||
"true");
|
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.SEMI, ";");
|
checkToken(tokens.get(2), document, ITokenConstants.SEMI, ";");
|
||||||
checkToken(tokens.get(3), document, ITokenConstants.SH_DO, "do");
|
checkToken(tokens.get(3), document, ITokenConstants.SH_DO, "do");
|
||||||
checkToken(tokens.get(4), document, ITokenConstants.WORD, "ls");
|
checkToken(tokens.get(4), document, ITokenConstants.WORD, "ls");
|
||||||
checkToken(tokens.get(5), document, ITokenConstants.SEMI, ";");
|
checkToken(tokens.get(5), document, ITokenConstants.SEMI, ";");
|
||||||
checkToken(tokens.get(6), document, ITokenConstants.SH_DONE,
|
checkToken(tokens.get(6), document, ITokenConstants.SH_DONE, "done");
|
||||||
"done");
|
|
||||||
checkToken(tokens.get(7), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(7), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellTokens2() {
|
public void testShellTokens2() {
|
||||||
// don't misread partial tokens
|
// don't misread partial tokens
|
||||||
|
@ -145,11 +146,10 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(2, tokens.size());
|
assertEquals(2, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "while_stuff");
|
||||||
"while_stuff");
|
checkToken(tokens.get(1), document, ITokenConstants.WORD, "incase");
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.WORD,
|
|
||||||
"incase");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellTokens3() {
|
public void testShellTokens3() {
|
||||||
// don't interpret m4 strings in shell mode
|
// don't interpret m4 strings in shell mode
|
||||||
|
@ -160,6 +160,7 @@ public class TestTokenizer {
|
||||||
assertEquals(1, tokens.size());
|
assertEquals(1, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.SH_STRING_BACKTICK, "foo'", 5);
|
checkToken(tokens.get(0), document, ITokenConstants.SH_STRING_BACKTICK, "foo'", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellTokens4() {
|
public void testShellTokens4() {
|
||||||
String text = "echo $if $((foo)) $\n";
|
String text = "echo $if $((foo)) $\n";
|
||||||
|
@ -181,6 +182,7 @@ public class TestTokenizer {
|
||||||
checkToken(tokens.get(10), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(10), document, ITokenConstants.EOL, "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellTokens5() {
|
public void testShellTokens5() {
|
||||||
String text = "while do select for until done\n";
|
String text = "while do select for until done\n";
|
||||||
|
@ -197,6 +199,7 @@ public class TestTokenizer {
|
||||||
checkToken(tokens.get(6), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(6), document, ITokenConstants.EOL, "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellComments() {
|
public void testShellComments() {
|
||||||
// comments are stripped and ignored in the shell mode
|
// comments are stripped and ignored in the shell mode
|
||||||
|
@ -205,10 +208,10 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(2, tokens.size());
|
assertEquals(2, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.SH_FOR,
|
checkToken(tokens.get(0), document, ITokenConstants.SH_FOR, "for");
|
||||||
"for");
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellComments2() {
|
public void testShellComments2() {
|
||||||
// comments are stripped and ignored in the shell mode
|
// comments are stripped and ignored in the shell mode
|
||||||
|
@ -221,6 +224,7 @@ public class TestTokenizer {
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Tokens0() {
|
public void testM4Tokens0() {
|
||||||
String text = "while_stuff incase";
|
String text = "while_stuff incase";
|
||||||
|
@ -228,56 +232,49 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(document, true);
|
List<Token> tokens = tokenize(document, true);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(2, tokens.size());
|
assertEquals(2, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "while_stuff");
|
||||||
"while_stuff");
|
checkToken(tokens.get(1), document, ITokenConstants.WORD, "incase");
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.WORD,
|
|
||||||
"incase");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellStrings() {
|
public void testShellStrings() {
|
||||||
String QUOTED =
|
String QUOTED = "ls -la \"*.c\"";
|
||||||
"ls -la \"*.c\"";
|
|
||||||
String text = "echo `" + QUOTED + "`\n";
|
String text = "echo `" + QUOTED + "`\n";
|
||||||
IDocument document = createDocument(text);
|
IDocument document = createDocument(text);
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(3, tokens.size());
|
assertEquals(3, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "echo");
|
||||||
"echo");
|
checkToken(tokens.get(1), document, ITokenConstants.SH_STRING_BACKTICK, QUOTED, QUOTED.length() + 2);
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.SH_STRING_BACKTICK,
|
|
||||||
QUOTED, QUOTED.length() + 2);
|
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellStrings2() {
|
public void testShellStrings2() {
|
||||||
String QUOTED =
|
String QUOTED = "ls -la 'space file'";
|
||||||
"ls -la 'space file'";
|
|
||||||
String text = "echo \"" + QUOTED + "\"\n";
|
String text = "echo \"" + QUOTED + "\"\n";
|
||||||
IDocument document = createDocument(text);
|
IDocument document = createDocument(text);
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(3, tokens.size());
|
assertEquals(3, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "echo");
|
||||||
"echo");
|
checkToken(tokens.get(1), document, ITokenConstants.SH_STRING_DOUBLE, QUOTED, QUOTED.length() + 2);
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.SH_STRING_DOUBLE,
|
|
||||||
QUOTED, QUOTED.length() + 2);
|
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShellStrings3() {
|
public void testShellStrings3() {
|
||||||
String QUOTED =
|
String QUOTED = "echo \"*.c\" | sed s/[a-z]/[A-Z]/g";
|
||||||
"echo \"*.c\" | sed s/[a-z]/[A-Z]/g";
|
|
||||||
String text = "echo '" + QUOTED + "'\n";
|
String text = "echo '" + QUOTED + "'\n";
|
||||||
IDocument document = createDocument(text);
|
IDocument document = createDocument(text);
|
||||||
List<Token> tokens = tokenize(document, false);
|
List<Token> tokens = tokenize(document, false);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(3, tokens.size());
|
assertEquals(3, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "echo");
|
||||||
"echo");
|
checkToken(tokens.get(1), document, ITokenConstants.SH_STRING_SINGLE, QUOTED, QUOTED.length() + 2);
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.SH_STRING_SINGLE,
|
|
||||||
QUOTED, QUOTED.length() + 2);
|
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Tokens1() {
|
public void testM4Tokens1() {
|
||||||
String text = "define(`hi\', `HI\')\n";
|
String text = "define(`hi\', `HI\')\n";
|
||||||
|
@ -285,18 +282,16 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(document, true);
|
List<Token> tokens = tokenize(document, true);
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(7, tokens.size());
|
assertEquals(7, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "define");
|
||||||
"define");
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.LPAREN, "(");
|
checkToken(tokens.get(1), document, ITokenConstants.LPAREN, "(");
|
||||||
// strings are unquoted in token text
|
// strings are unquoted in token text
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.M4_STRING,
|
checkToken(tokens.get(2), document, ITokenConstants.M4_STRING, "hi", 4);
|
||||||
"hi", 4);
|
|
||||||
checkToken(tokens.get(3), document, ITokenConstants.COMMA, ",");
|
checkToken(tokens.get(3), document, ITokenConstants.COMMA, ",");
|
||||||
checkToken(tokens.get(4), document, ITokenConstants.M4_STRING,
|
checkToken(tokens.get(4), document, ITokenConstants.M4_STRING, "HI", 4);
|
||||||
"HI", 4);
|
|
||||||
checkToken(tokens.get(5), document, ITokenConstants.RPAREN, ")");
|
checkToken(tokens.get(5), document, ITokenConstants.RPAREN, ")");
|
||||||
checkToken(tokens.get(6), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(6), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Comments() {
|
public void testM4Comments() {
|
||||||
String text = "dnl # comment\n";
|
String text = "dnl # comment\n";
|
||||||
|
@ -305,9 +300,9 @@ public class TestTokenizer {
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
assertEquals(2, tokens.size());
|
assertEquals(2, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD, "dnl");
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "dnl");
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.M4_COMMENT,
|
checkToken(tokens.get(1), document, ITokenConstants.M4_COMMENT, "# comment\n");
|
||||||
"# comment\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Comments2() {
|
public void testM4Comments2() {
|
||||||
String text = "dnl /* word(`quoted')\n" + "*/\n";
|
String text = "dnl /* word(`quoted')\n" + "*/\n";
|
||||||
|
@ -319,10 +314,10 @@ public class TestTokenizer {
|
||||||
List<Token> tokens = tokenize(tokenizer);
|
List<Token> tokens = tokenize(tokenizer);
|
||||||
assertEquals(3, tokens.size());
|
assertEquals(3, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD, "dnl");
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "dnl");
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.M4_COMMENT,
|
checkToken(tokens.get(1), document, ITokenConstants.M4_COMMENT, "/* word(`quoted')\n*/");
|
||||||
"/* word(`quoted')\n*/");
|
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(2), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Strings1() {
|
public void testM4Strings1() {
|
||||||
// double quotes only removes one level of quotes
|
// double quotes only removes one level of quotes
|
||||||
|
@ -333,10 +328,10 @@ public class TestTokenizer {
|
||||||
|
|
||||||
List<Token> tokens = tokenize(tokenizer);
|
List<Token> tokens = tokenize(tokenizer);
|
||||||
assertEquals(2, tokens.size());
|
assertEquals(2, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.M4_STRING,
|
checkToken(tokens.get(0), document, ITokenConstants.M4_STRING, "`double'", 8 + 1 + 1);
|
||||||
"`double'", 8 + 1 + 1);
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Strings2() {
|
public void testM4Strings2() {
|
||||||
String text = "myword(!!boundary==)\n";
|
String text = "myword(!!boundary==)\n";
|
||||||
|
@ -347,14 +342,13 @@ public class TestTokenizer {
|
||||||
|
|
||||||
List<Token> tokens = tokenize(tokenizer);
|
List<Token> tokens = tokenize(tokenizer);
|
||||||
assertEquals(5, tokens.size());
|
assertEquals(5, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "myword");
|
||||||
"myword");
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.LPAREN, "(");
|
checkToken(tokens.get(1), document, ITokenConstants.LPAREN, "(");
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.M4_STRING,
|
checkToken(tokens.get(2), document, ITokenConstants.M4_STRING, "boundary", 8 + 2 + 2);
|
||||||
"boundary", 8 + 2 + 2);
|
|
||||||
checkToken(tokens.get(3), document, ITokenConstants.RPAREN, ")");
|
checkToken(tokens.get(3), document, ITokenConstants.RPAREN, ")");
|
||||||
checkToken(tokens.get(4), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(4), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4Tokens2() {
|
public void testM4Tokens2() {
|
||||||
// dollar is not seen in m4 mode (only important when expanding)
|
// dollar is not seen in m4 mode (only important when expanding)
|
||||||
|
@ -365,8 +359,7 @@ public class TestTokenizer {
|
||||||
|
|
||||||
List<Token> tokens = tokenize(tokenizer);
|
List<Token> tokens = tokenize(tokenizer);
|
||||||
assertEquals(8, tokens.size());
|
assertEquals(8, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.WORD,
|
checkToken(tokens.get(0), document, ITokenConstants.WORD, "define");
|
||||||
"define");
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.LPAREN, "(");
|
checkToken(tokens.get(1), document, ITokenConstants.LPAREN, "(");
|
||||||
checkToken(tokens.get(2), document, ITokenConstants.WORD, "foo");
|
checkToken(tokens.get(2), document, ITokenConstants.WORD, "foo");
|
||||||
checkToken(tokens.get(3), document, ITokenConstants.COMMA, ",");
|
checkToken(tokens.get(3), document, ITokenConstants.COMMA, ",");
|
||||||
|
@ -375,21 +368,22 @@ public class TestTokenizer {
|
||||||
checkToken(tokens.get(6), document, ITokenConstants.RPAREN, ")");
|
checkToken(tokens.get(6), document, ITokenConstants.RPAREN, ")");
|
||||||
checkToken(tokens.get(7), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(7), document, ITokenConstants.EOL, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testM4QuoteNesting() {
|
public void testM4QuoteNesting() {
|
||||||
String quote = "this is `nested\'!";
|
String quote = "this is `nested\'!";
|
||||||
String text = "`" + quote +"'\n";
|
String text = "`" + quote + "'\n";
|
||||||
IDocument document = createDocument(text);
|
IDocument document = createDocument(text);
|
||||||
AutoconfTokenizer tokenizer = createTokenizer(document);
|
AutoconfTokenizer tokenizer = createTokenizer(document);
|
||||||
tokenizer.setM4Context(true);
|
tokenizer.setM4Context(true);
|
||||||
|
|
||||||
List<Token> tokens = tokenize(tokenizer);
|
List<Token> tokens = tokenize(tokenizer);
|
||||||
assertEquals(2, tokens.size());
|
assertEquals(2, tokens.size());
|
||||||
checkToken(tokens.get(0), document, ITokenConstants.M4_STRING,
|
checkToken(tokens.get(0), document, ITokenConstants.M4_STRING, quote, quote.length() + 2);
|
||||||
quote, quote.length() + 2);
|
|
||||||
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
checkToken(tokens.get(1), document, ITokenConstants.EOL, "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMixedContext() {
|
public void testMixedContext() {
|
||||||
String text = "AM_INIT([arg])if true\n";
|
String text = "AM_INIT([arg])if true\n";
|
||||||
|
@ -447,12 +441,11 @@ public class TestTokenizer {
|
||||||
assertSame(document, token.getDocument());
|
assertSame(document, token.getDocument());
|
||||||
assertTrue(token.getOffset() >= 0);
|
assertTrue(token.getOffset() >= 0);
|
||||||
assertTrue(token.getType() == ITokenConstants.EOF || token.getLength() > 0);
|
assertTrue(token.getType() == ITokenConstants.EOF || token.getLength() > 0);
|
||||||
assertEquals(document.get().substring(token.getOffset(),
|
assertEquals(document.get().substring(token.getOffset(), token.getOffset() + token.getLength()),
|
||||||
token.getOffset() + token.getLength()), token.getText());
|
token.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkToken(Token token, IDocument document, int type,
|
private void checkToken(Token token, IDocument document, int type, String text) {
|
||||||
String text) {
|
|
||||||
assertEquals(type, token.getType());
|
assertEquals(type, token.getType());
|
||||||
assertSame(document, token.getDocument());
|
assertSame(document, token.getDocument());
|
||||||
assertTrue(token.getOffset() >= 0);
|
assertTrue(token.getOffset() >= 0);
|
||||||
|
@ -460,8 +453,7 @@ public class TestTokenizer {
|
||||||
assertEquals(text.length(), token.getLength());
|
assertEquals(text.length(), token.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkToken(Token token, IDocument document, int type,
|
private void checkToken(Token token, IDocument document, int type, String text, int length) {
|
||||||
String text, int length) {
|
|
||||||
assertEquals(type, token.getType());
|
assertEquals(type, token.getType());
|
||||||
assertSame(document, token.getDocument());
|
assertSame(document, token.getDocument());
|
||||||
assertTrue(token.getOffset() >= 0);
|
assertTrue(token.getOffset() >= 0);
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class AutotoolsUIPlugin extends AbstractUIPlugin {
|
||||||
* Returns the active workbench page or <code>null</code> if none.
|
* Returns the active workbench page or <code>null</code> if none.
|
||||||
*/
|
*/
|
||||||
public static IWorkbenchPage getActivePage() {
|
public static IWorkbenchPage getActivePage() {
|
||||||
IWorkbenchWindow window= getActiveWorkbenchWindow();
|
IWorkbenchWindow window = getActiveWorkbenchWindow();
|
||||||
if (window != null) {
|
if (window != null) {
|
||||||
return window.getActivePage();
|
return window.getActivePage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,7 @@ public class AcInitElement extends AutoconfMacroElement {
|
||||||
if (this.getChildren().length == 0)
|
if (this.getChildren().length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (VersionComparator.compare(version,
|
if (VersionComparator.compare(version, AutotoolsPropertyConstants.AC_VERSION_2_59) >= 0) {
|
||||||
AutotoolsPropertyConstants.AC_VERSION_2_59) >= 0){
|
|
||||||
if (this.getChildren().length < 2)
|
if (this.getChildren().length < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -49,7 +48,7 @@ public class AcInitElement extends AutoconfMacroElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMultipleArguments () throws InvalidMacroException{
|
private void validateMultipleArguments() throws InvalidMacroException {
|
||||||
|
|
||||||
// There are no restrictions on the first argument.
|
// There are no restrictions on the first argument.
|
||||||
|
|
||||||
|
@ -57,7 +56,7 @@ public class AcInitElement extends AutoconfMacroElement {
|
||||||
AutoconfElement argument = this.getChildren()[1];
|
AutoconfElement argument = this.getChildren()[1];
|
||||||
// match a digit followed by a dot zero or more times
|
// match a digit followed by a dot zero or more times
|
||||||
// but always end with a digit
|
// but always end with a digit
|
||||||
if (!argument.getName().matches("(\\d*\\.)*((\\d+))")){
|
if (!argument.getName().matches("(\\d*\\.)*((\\d+))")) {
|
||||||
throw new InvalidMacroException(AutoconfEditorMessages.getString(BAD_VERSION_NUMBER), argument);
|
throw new InvalidMacroException(AutoconfEditorMessages.getString(BAD_VERSION_NUMBER), argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
import org.eclipse.jface.text.source.LineRange;
|
import org.eclipse.jface.text.source.LineRange;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension {
|
public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +43,7 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
|
||||||
|
|
||||||
if (position.getOffset() > -1 && position.getLength() > -1) {
|
if (position.getOffset() > -1 && position.getLength() > -1) {
|
||||||
try {
|
try {
|
||||||
int markerLine= document.getLineOfOffset(position.getOffset());
|
int markerLine = document.getLineOfOffset(position.getOffset());
|
||||||
if (line == markerLine)
|
if (line == markerLine)
|
||||||
return 1;
|
return 1;
|
||||||
if (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
|
if (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
|
||||||
|
@ -69,20 +68,20 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
|
||||||
*/
|
*/
|
||||||
protected List<Annotation> getAnnotationsForLine(ISourceViewer viewer, int line) {
|
protected List<Annotation> getAnnotationsForLine(ISourceViewer viewer, int line) {
|
||||||
|
|
||||||
IDocument document= viewer.getDocument();
|
IDocument document = viewer.getDocument();
|
||||||
IAnnotationModel model= viewer.getAnnotationModel();
|
IAnnotationModel model = viewer.getAnnotationModel();
|
||||||
|
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<Annotation> exact= new ArrayList<>();
|
List<Annotation> exact = new ArrayList<>();
|
||||||
List<Annotation> including= new ArrayList<>();
|
List<Annotation> including = new ArrayList<>();
|
||||||
|
|
||||||
Iterator<?> e = model.getAnnotationIterator();
|
Iterator<?> e = model.getAnnotationIterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Object o= e.next();
|
Object o = e.next();
|
||||||
if (o instanceof Annotation) {
|
if (o instanceof Annotation) {
|
||||||
Annotation a= (Annotation) o;
|
Annotation a = (Annotation) o;
|
||||||
switch (compareRulerLine(model.getPosition(a), document, line)) {
|
switch (compareRulerLine(model.getPosition(a), document, line)) {
|
||||||
case 1:
|
case 1:
|
||||||
exact.add(a);
|
exact.add(a);
|
||||||
|
@ -106,18 +105,18 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
|
||||||
|
|
||||||
// optimization
|
// optimization
|
||||||
Annotation annotation = annotations.get(0);
|
Annotation annotation = annotations.get(0);
|
||||||
String message= annotation.getText();
|
String message = annotation.getText();
|
||||||
if (message != null && message.trim().length() > 0)
|
if (message != null && message.trim().length() > 0)
|
||||||
return formatSingleMessage(message);
|
return formatSingleMessage(message);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
List<String> messages= new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
Iterator<Annotation> e= annotations.iterator();
|
Iterator<Annotation> e = annotations.iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
Annotation annotation = e.next();
|
Annotation annotation = e.next();
|
||||||
String message= annotation.getText();
|
String message = annotation.getText();
|
||||||
if (message != null && message.trim().length() > 0)
|
if (message != null && message.trim().length() > 0)
|
||||||
messages.add(message.trim());
|
messages.add(message.trim());
|
||||||
}
|
}
|
||||||
|
@ -133,12 +132,11 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Formats a message as HTML text.
|
* Formats a message as HTML text.
|
||||||
*/
|
*/
|
||||||
private String formatSingleMessage(String message) {
|
private String formatSingleMessage(String message) {
|
||||||
StringBuilder buffer= new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
HTMLPrinter.addPageProlog(buffer);
|
HTMLPrinter.addPageProlog(buffer);
|
||||||
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
|
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
|
||||||
HTMLPrinter.addPageEpilog(buffer);
|
HTMLPrinter.addPageEpilog(buffer);
|
||||||
|
@ -149,12 +147,13 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
|
||||||
* Formats several message as HTML text.
|
* Formats several message as HTML text.
|
||||||
*/
|
*/
|
||||||
private String formatMultipleMessages(List<String> messages) {
|
private String formatMultipleMessages(List<String> messages) {
|
||||||
StringBuilder buffer= new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
HTMLPrinter.addPageProlog(buffer);
|
HTMLPrinter.addPageProlog(buffer);
|
||||||
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(AutoconfEditorMessages.getString("AutoconfAnnotationHover.multipleMarkers"))); //$NON-NLS-1$
|
HTMLPrinter.addParagraph(buffer, HTMLPrinter
|
||||||
|
.convertToHTMLContent(AutoconfEditorMessages.getString("AutoconfAnnotationHover.multipleMarkers"))); //$NON-NLS-1$
|
||||||
|
|
||||||
HTMLPrinter.startBulletList(buffer);
|
HTMLPrinter.startBulletList(buffer);
|
||||||
Iterator<String> e= messages.iterator();
|
Iterator<String> e = messages.iterator();
|
||||||
while (e.hasNext())
|
while (e.hasNext())
|
||||||
HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next()));
|
HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next()));
|
||||||
HTMLPrinter.endBulletList(buffer);
|
HTMLPrinter.endBulletList(buffer);
|
||||||
|
@ -167,7 +166,6 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
|
||||||
// We need to use the extension to get a Hover Control Creator which
|
// We need to use the extension to get a Hover Control Creator which
|
||||||
// handles html.
|
// handles html.
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getHoverControlCreator() {
|
public IInformationControlCreator getHoverControlCreator() {
|
||||||
return new IInformationControlCreator() {
|
return new IInformationControlCreator() {
|
||||||
|
|
|
@ -38,10 +38,9 @@ import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfCodeScanner extends RuleBasedScanner {
|
public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
private Map<String, IToken> fTokenMap= new HashMap<>();
|
private Map<String, IToken> fTokenMap = new HashMap<>();
|
||||||
private String[] fPropertyNamesColor;
|
private String[] fPropertyNamesColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,37 +54,31 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
*/
|
*/
|
||||||
private String[] fPropertyNamesItalic;
|
private String[] fPropertyNamesItalic;
|
||||||
|
|
||||||
private static String[] keywords = {
|
private static String[] keywords = { "case", "do", "done", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"case", "do", "done", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
"esac", "if", "elif", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"esac", "if", "elif", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"else", "fi", "for", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"else", "fi", "for", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"in", "then" }; //$NON-NLS-1$ //$NON-NLS-2$
|
"in", "then" }; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
static final String[] fTokenProperties = new String[] {
|
static final String[] fTokenProperties = new String[] { ColorManager.AUTOCONF_COMMENT_COLOR,
|
||||||
ColorManager.AUTOCONF_COMMENT_COLOR,
|
ColorManager.AUTOCONF_KEYWORD_COLOR, ColorManager.AUTOCONF_ACMACRO_COLOR,
|
||||||
ColorManager.AUTOCONF_KEYWORD_COLOR,
|
ColorManager.AUTOCONF_AMMACRO_COLOR, ColorManager.AUTOCONF_VAR_REF_COLOR,
|
||||||
ColorManager.AUTOCONF_ACMACRO_COLOR,
|
ColorManager.AUTOCONF_VAR_SET_COLOR, ColorManager.AUTOCONF_CODESEQ_COLOR,
|
||||||
ColorManager.AUTOCONF_AMMACRO_COLOR,
|
ColorManager.AUTOCONF_DEFAULT_COLOR, };
|
||||||
ColorManager.AUTOCONF_VAR_REF_COLOR,
|
|
||||||
ColorManager.AUTOCONF_VAR_SET_COLOR,
|
|
||||||
ColorManager.AUTOCONF_CODESEQ_COLOR,
|
|
||||||
ColorManager.AUTOCONF_DEFAULT_COLOR,
|
|
||||||
};
|
|
||||||
|
|
||||||
public AutoconfCodeScanner() {
|
public AutoconfCodeScanner() {
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
IToken other= getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
IToken other = getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
||||||
IToken keyword = getToken(ColorManager.AUTOCONF_KEYWORD_COLOR);
|
IToken keyword = getToken(ColorManager.AUTOCONF_KEYWORD_COLOR);
|
||||||
IToken comment= getToken(ColorManager.AUTOCONF_COMMENT_COLOR);
|
IToken comment = getToken(ColorManager.AUTOCONF_COMMENT_COLOR);
|
||||||
IToken string = getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
IToken string = getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
||||||
IToken varRef = getToken(ColorManager.AUTOCONF_VAR_REF_COLOR);
|
IToken varRef = getToken(ColorManager.AUTOCONF_VAR_REF_COLOR);
|
||||||
IToken acmacro = getToken(ColorManager.AUTOCONF_ACMACRO_COLOR);
|
IToken acmacro = getToken(ColorManager.AUTOCONF_ACMACRO_COLOR);
|
||||||
IToken ammacro = getToken(ColorManager.AUTOCONF_AMMACRO_COLOR);
|
IToken ammacro = getToken(ColorManager.AUTOCONF_AMMACRO_COLOR);
|
||||||
IToken code = getToken(ColorManager.AUTOCONF_CODESEQ_COLOR);
|
IToken code = getToken(ColorManager.AUTOCONF_CODESEQ_COLOR);
|
||||||
|
|
||||||
List<IRule> rules= new ArrayList<>();
|
List<IRule> rules = new ArrayList<>();
|
||||||
|
|
||||||
// Add rule for single line comments.
|
// Add rule for single line comments.
|
||||||
rules.add(new EndOfLineRule("dnl", comment)); //$NON-NLS-1$
|
rules.add(new EndOfLineRule("dnl", comment)); //$NON-NLS-1$
|
||||||
|
@ -93,8 +86,7 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
// Add special recursive rule for strings which allows variable
|
// Add special recursive rule for strings which allows variable
|
||||||
// references to be internally tokenized.
|
// references to be internally tokenized.
|
||||||
RecursiveSingleLineRule stringRule =
|
RecursiveSingleLineRule stringRule = new RecursiveSingleLineRule("\"", "\"", string, '\\'); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new RecursiveSingleLineRule("\"", "\"", string, '\\'); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
stringRule.addRule(new SingleLineRule("${", "}", varRef)); //$NON-NLS-1$ //$NON-NLS-2$
|
stringRule.addRule(new SingleLineRule("${", "}", varRef)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
rules.add(stringRule);
|
rules.add(stringRule);
|
||||||
|
|
||||||
|
@ -119,8 +111,8 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
rules.add(new InlineDataRule(code));
|
rules.add(new InlineDataRule(code));
|
||||||
|
|
||||||
// Add word rule for keywords.
|
// Add word rule for keywords.
|
||||||
WordRule wordRule= new WordRule(new AutoconfWordDetector(), Token.UNDEFINED);
|
WordRule wordRule = new WordRule(new AutoconfWordDetector(), Token.UNDEFINED);
|
||||||
for (int i= 0; i < keywords.length; i++)
|
for (int i = 0; i < keywords.length; i++)
|
||||||
wordRule.addWord(keywords[i], keyword);
|
wordRule.addWord(keywords[i], keyword);
|
||||||
rules.add(wordRule);
|
rules.add(wordRule);
|
||||||
|
|
||||||
|
@ -134,7 +126,7 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
setDefaultReturnToken(other);
|
setDefaultReturnToken(other);
|
||||||
|
|
||||||
IRule[] result= new IRule[rules.size()];
|
IRule[] result = new IRule[rules.size()];
|
||||||
rules.toArray(result);
|
rules.toArray(result);
|
||||||
setRules(result);
|
setRules(result);
|
||||||
}
|
}
|
||||||
|
@ -153,9 +145,10 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
private int indexOf(String property) {
|
private int indexOf(String property) {
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
int length= fPropertyNamesColor.length;
|
int length = fPropertyNamesColor.length;
|
||||||
for (int i= 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i]))
|
if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i])
|
||||||
|
|| property.equals(fPropertyNamesItalic[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,9 +160,9 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adaptToPreferenceChange(PropertyChangeEvent event) {
|
public void adaptToPreferenceChange(PropertyChangeEvent event) {
|
||||||
String p= event.getProperty();
|
String p = event.getProperty();
|
||||||
int index= indexOf(p);
|
int index = indexOf(p);
|
||||||
Token token= getToken(fPropertyNamesColor[index]);
|
Token token = getToken(fPropertyNamesColor[index]);
|
||||||
if (fPropertyNamesColor[index].equals(p))
|
if (fPropertyNamesColor[index].equals(p))
|
||||||
adaptToColorChange(event, token);
|
adaptToColorChange(event, token);
|
||||||
else if (fPropertyNamesBold[index].equals(p))
|
else if (fPropertyNamesBold[index].equals(p))
|
||||||
|
@ -179,17 +172,18 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void adaptToColorChange(PropertyChangeEvent event, Token token) {
|
protected void adaptToColorChange(PropertyChangeEvent event, Token token) {
|
||||||
RGB rgb= null;
|
RGB rgb = null;
|
||||||
Object value= event.getNewValue();
|
Object value = event.getNewValue();
|
||||||
if (value instanceof RGB) {
|
if (value instanceof RGB) {
|
||||||
rgb= (RGB) value;
|
rgb = (RGB) value;
|
||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
rgb= StringConverter.asRGB((String) value);
|
rgb = StringConverter.asRGB((String) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rgb != null) {
|
if (rgb != null) {
|
||||||
TextAttribute attr= (TextAttribute) token.getData();
|
TextAttribute attr = (TextAttribute) token.getData();
|
||||||
token.setData(new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle()));
|
token.setData(
|
||||||
|
new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,28 +191,29 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean eventValue= false;
|
boolean eventValue = false;
|
||||||
Object value= event.getNewValue();
|
Object value = event.getNewValue();
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
eventValue= ((Boolean) value).booleanValue();
|
eventValue = ((Boolean) value).booleanValue();
|
||||||
} else if (IPreferenceStore.TRUE.equals(value)) {
|
} else if (IPreferenceStore.TRUE.equals(value)) {
|
||||||
eventValue= true;
|
eventValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAttribute attr= (TextAttribute) token.getData();
|
TextAttribute attr = (TextAttribute) token.getData();
|
||||||
boolean activeValue= (attr.getStyle() & styleAttribute) == styleAttribute;
|
boolean activeValue = (attr.getStyle() & styleAttribute) == styleAttribute;
|
||||||
if (activeValue != eventValue) {
|
if (activeValue != eventValue) {
|
||||||
token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(), eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute));
|
token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(),
|
||||||
|
eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TextAttribute createTextAttribute(String colorID, String boldKey, String italicKey) {
|
protected TextAttribute createTextAttribute(String colorID, String boldKey, String italicKey) {
|
||||||
Color color= null;
|
Color color = null;
|
||||||
if (colorID != null) {
|
if (colorID != null) {
|
||||||
color= AutoconfEditor.getPreferenceColor(colorID);
|
color = AutoconfEditor.getPreferenceColor(colorID);
|
||||||
}
|
}
|
||||||
IPreferenceStore store= AutotoolsPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store = AutotoolsPlugin.getDefault().getPreferenceStore();
|
||||||
int style= store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
|
int style = store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
|
||||||
if (store.getBoolean(italicKey)) {
|
if (store.getBoolean(italicKey)) {
|
||||||
style |= SWT.ITALIC;
|
style |= SWT.ITALIC;
|
||||||
}
|
}
|
||||||
|
@ -230,14 +225,14 @@ public class AutoconfCodeScanner extends RuleBasedScanner {
|
||||||
*/
|
*/
|
||||||
public final void initialize() {
|
public final void initialize() {
|
||||||
|
|
||||||
fPropertyNamesColor= getTokenProperties();
|
fPropertyNamesColor = getTokenProperties();
|
||||||
int length= fPropertyNamesColor.length;
|
int length = fPropertyNamesColor.length;
|
||||||
fPropertyNamesBold= new String[length];
|
fPropertyNamesBold = new String[length];
|
||||||
fPropertyNamesItalic= new String[length];
|
fPropertyNamesItalic = new String[length];
|
||||||
|
|
||||||
for (int i= 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
fPropertyNamesBold[i]= fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX;
|
fPropertyNamesBold[i] = fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX;
|
||||||
fPropertyNamesItalic[i]= fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX;
|
fPropertyNamesItalic[i] = fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX;
|
||||||
addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]);
|
addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class AutoconfDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDocument getDocument(Object element) {
|
public IDocument getDocument(Object element) {
|
||||||
FileInfo info= getFileInfo(element);
|
FileInfo info = getFileInfo(element);
|
||||||
if (info != null)
|
if (info != null)
|
||||||
return info.fTextFileBuffer.getDocument();
|
return info.fTextFileBuffer.getDocument();
|
||||||
return getParentProvider().getDocument(element);
|
return getParentProvider().getDocument(element);
|
||||||
|
|
|
@ -19,23 +19,20 @@ import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IDocumentExtension3;
|
import org.eclipse.jface.text.IDocumentExtension3;
|
||||||
import org.eclipse.jface.text.IDocumentListener;
|
import org.eclipse.jface.text.IDocumentListener;
|
||||||
|
|
||||||
public class AutoconfDocumentSetupParticipant implements
|
public class AutoconfDocumentSetupParticipant implements IDocumentSetupParticipant, IDocumentListener {
|
||||||
IDocumentSetupParticipant, IDocumentListener {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(IDocument document) {
|
public void setup(IDocument document) {
|
||||||
AutoconfPartitioner partitioner =
|
AutoconfPartitioner partitioner = new AutoconfPartitioner(new AutoconfPartitionScanner(),
|
||||||
new AutoconfPartitioner(
|
|
||||||
new AutoconfPartitionScanner(),
|
|
||||||
AutoconfPartitionScanner.AUTOCONF_PARTITION_TYPES);
|
AutoconfPartitionScanner.AUTOCONF_PARTITION_TYPES);
|
||||||
partitioner.connect(document, 1);
|
partitioner.connect(document, 1);
|
||||||
if (document instanceof IDocumentExtension3) {
|
if (document instanceof IDocumentExtension3) {
|
||||||
IDocumentExtension3 extension3= (IDocumentExtension3) document;
|
IDocumentExtension3 extension3 = (IDocumentExtension3) document;
|
||||||
extension3.setDocumentPartitioner(AutoconfEditor.AUTOCONF_PARTITIONING, partitioner);
|
extension3.setDocumentPartitioner(AutoconfEditor.AUTOCONF_PARTITIONING, partitioner);
|
||||||
} else {
|
} else {
|
||||||
document.setDocumentPartitioner(partitioner);
|
document.setDocumentPartitioner(partitioner);
|
||||||
}
|
}
|
||||||
// document.addDocumentListener(this);
|
// document.addDocumentListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -86,11 +86,9 @@ import org.eclipse.ui.texteditor.TextEditorAction;
|
||||||
import org.eclipse.ui.texteditor.TextOperationAction;
|
import org.eclipse.ui.texteditor.TextOperationAction;
|
||||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IProjectPropertyListener {
|
public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IProjectPropertyListener {
|
||||||
|
|
||||||
public final static String AUTOCONF_PARTITIONING= "autoconf_partitioning"; //$NON-NLS-1$
|
public final static String AUTOCONF_PARTITIONING = "autoconf_partitioning"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
private AutoconfPartitionScanner fPartitionScanner;
|
private AutoconfPartitionScanner fPartitionScanner;
|
||||||
private RuleBasedScanner fCodeScanner;
|
private RuleBasedScanner fCodeScanner;
|
||||||
|
@ -116,7 +114,6 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
*/
|
*/
|
||||||
private ListenerList<IReconcilingParticipant> fReconcilingListeners = new ListenerList<>(ListenerList.IDENTITY);
|
private ListenerList<IReconcilingParticipant> fReconcilingListeners = new ListenerList<>(ListenerList.IDENTITY);
|
||||||
|
|
||||||
|
|
||||||
public AutoconfEditor() {
|
public AutoconfEditor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +134,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
|
|
||||||
public static AutoconfDocumentProvider getAutoconfDocumentProvider() {
|
public static AutoconfDocumentProvider getAutoconfDocumentProvider() {
|
||||||
if (fDocumentProvider == null)
|
if (fDocumentProvider == null)
|
||||||
fDocumentProvider= new AutoconfDocumentProvider();
|
fDocumentProvider = new AutoconfDocumentProvider();
|
||||||
return fDocumentProvider;
|
return fDocumentProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,8 +155,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doSetInput(IEditorInput newInput) throws CoreException
|
protected void doSetInput(IEditorInput newInput) throws CoreException {
|
||||||
{
|
|
||||||
// If this editor is for a project file, remove this editor as a property
|
// If this editor is for a project file, remove this editor as a property
|
||||||
// change listener.
|
// change listener.
|
||||||
if (fProject != null)
|
if (fProject != null)
|
||||||
|
@ -169,21 +165,18 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
this.input = newInput;
|
this.input = newInput;
|
||||||
|
|
||||||
if (input instanceof IFileEditorInput) {
|
if (input instanceof IFileEditorInput) {
|
||||||
IFile f = ((IFileEditorInput)input).getFile();
|
IFile f = ((IFileEditorInput) input).getFile();
|
||||||
fProject = f.getProject();
|
fProject = f.getProject();
|
||||||
// This is a project file. We want to be notified if the Autoconf editor
|
// This is a project file. We want to be notified if the Autoconf editor
|
||||||
// properties are changed such that the macro versions are changed.
|
// properties are changed such that the macro versions are changed.
|
||||||
AutotoolsPropertyManager.getDefault().addProjectPropertyListener(fProject, this);
|
AutotoolsPropertyManager.getDefault().addProjectPropertyListener(fProject, this);
|
||||||
}
|
}
|
||||||
getOutlinePage().setInput(input);
|
getOutlinePage().setInput(input);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
IDocument document = getInputDocument();
|
IDocument document = getInputDocument();
|
||||||
|
|
||||||
setRootElement(reparseDocument(document));
|
setRootElement(reparseDocument(document));
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,10 +197,9 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
return super.getAdapter(required);
|
return super.getAdapter(required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AutoconfContentOutlinePage getOutlinePage() {
|
public AutoconfContentOutlinePage getOutlinePage() {
|
||||||
if (outlinePage == null) {
|
if (outlinePage == null) {
|
||||||
outlinePage= new AutoconfContentOutlinePage(this);
|
outlinePage = new AutoconfContentOutlinePage(this);
|
||||||
if (getEditorInput() != null)
|
if (getEditorInput() != null)
|
||||||
outlinePage.setInput(getEditorInput());
|
outlinePage.setInput(getEditorInput());
|
||||||
}
|
}
|
||||||
|
@ -235,7 +227,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
*/
|
*/
|
||||||
public AutoconfPartitionScanner getAutoconfPartitionScanner() {
|
public AutoconfPartitionScanner getAutoconfPartitionScanner() {
|
||||||
if (fPartitionScanner == null)
|
if (fPartitionScanner == null)
|
||||||
fPartitionScanner= new AutoconfPartitionScanner();
|
fPartitionScanner = new AutoconfPartitionScanner();
|
||||||
return fPartitionScanner;
|
return fPartitionScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +238,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
*/
|
*/
|
||||||
public RuleBasedScanner getAutoconfCodeScanner() {
|
public RuleBasedScanner getAutoconfCodeScanner() {
|
||||||
if (fCodeScanner == null)
|
if (fCodeScanner == null)
|
||||||
fCodeScanner= new AutoconfCodeScanner();
|
fCodeScanner = new AutoconfCodeScanner();
|
||||||
return fCodeScanner;
|
return fCodeScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +249,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
*/
|
*/
|
||||||
public RuleBasedScanner getAutoconfMacroCodeScanner() {
|
public RuleBasedScanner getAutoconfMacroCodeScanner() {
|
||||||
if (fMacroCodeScanner == null)
|
if (fMacroCodeScanner == null)
|
||||||
fMacroCodeScanner= new AutoconfMacroCodeScanner();
|
fMacroCodeScanner = new AutoconfMacroCodeScanner();
|
||||||
return fMacroCodeScanner;
|
return fMacroCodeScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,13 +257,14 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
* Returns the preference color, identified by the given preference.
|
* Returns the preference color, identified by the given preference.
|
||||||
*/
|
*/
|
||||||
public static Color getPreferenceColor(String key) {
|
public static Color getPreferenceColor(String key) {
|
||||||
return ColorManager.getDefault().getColor(PreferenceConverter.getColor(AutotoolsPlugin.getDefault().getPreferenceStore(), key));
|
return ColorManager.getDefault()
|
||||||
|
.getColor(PreferenceConverter.getColor(AutotoolsPlugin.getDefault().getPreferenceStore(), key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleProjectPropertyChanged(IProject project, String property) {
|
public void handleProjectPropertyChanged(IProject project, String property) {
|
||||||
if (property.equals(AutotoolsPropertyConstants.AUTOCONF_MACRO_VERSIONING)) {
|
if (property.equals(AutotoolsPropertyConstants.AUTOCONF_MACRO_VERSIONING)) {
|
||||||
ISourceViewer sourceViewer= getSourceViewer();
|
ISourceViewer sourceViewer = getSourceViewer();
|
||||||
if (sourceViewer == null)
|
if (sourceViewer == null)
|
||||||
return;
|
return;
|
||||||
handleVersionChange(sourceViewer);
|
handleVersionChange(sourceViewer);
|
||||||
|
@ -291,28 +284,27 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
IDocument document = getInputDocument();
|
IDocument document = getInputDocument();
|
||||||
|
|
||||||
setRootElement(reparseDocument(document));
|
setRootElement(reparseDocument(document));
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AutoconfElement reparseDocument(IDocument document) {
|
private AutoconfElement reparseDocument(IDocument document) {
|
||||||
AutoconfParser parser = getAutoconfParser();
|
AutoconfParser parser = getAutoconfParser();
|
||||||
((AutoconfErrorHandler)parser.getErrorHandler()).removeAllExistingMarkers();
|
((AutoconfErrorHandler) parser.getErrorHandler()).removeAllExistingMarkers();
|
||||||
|
|
||||||
return parser.parse(document);
|
return parser.parse(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
|
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
|
||||||
ISourceViewer sourceViewer= getSourceViewer();
|
ISourceViewer sourceViewer = getSourceViewer();
|
||||||
if (sourceViewer == null)
|
if (sourceViewer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String property = event.getProperty();
|
String property = event.getProperty();
|
||||||
|
|
||||||
AutoconfCodeScanner scanner = (AutoconfCodeScanner)getAutoconfCodeScanner();
|
AutoconfCodeScanner scanner = (AutoconfCodeScanner) getAutoconfCodeScanner();
|
||||||
if (scanner != null) {
|
if (scanner != null) {
|
||||||
if (scanner.affectsBehavior(event)) {
|
if (scanner.affectsBehavior(event)) {
|
||||||
scanner.adaptToPreferenceChange(event);
|
scanner.adaptToPreferenceChange(event);
|
||||||
|
@ -320,16 +312,16 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION.equals(property) ||
|
if (AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION.equals(property)
|
||||||
AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION.equals(property)) {
|
|| AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION.equals(property)) {
|
||||||
handleVersionChange(sourceViewer);
|
handleVersionChange(sourceViewer);
|
||||||
} else if (AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) {
|
} else if (AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) {
|
||||||
if (sourceViewer instanceof ProjectionViewer) {
|
if (sourceViewer instanceof ProjectionViewer) {
|
||||||
ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
|
ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
|
||||||
if (fProjectionFileUpdater != null)
|
if (fProjectionFileUpdater != null)
|
||||||
fProjectionFileUpdater.uninstall();
|
fProjectionFileUpdater.uninstall();
|
||||||
// either freshly enabled or provider changed
|
// either freshly enabled or provider changed
|
||||||
fProjectionFileUpdater= new ProjectionFileUpdater();
|
fProjectionFileUpdater = new ProjectionFileUpdater();
|
||||||
if (fProjectionFileUpdater != null) {
|
if (fProjectionFileUpdater != null) {
|
||||||
fProjectionFileUpdater.install(this, projectionViewer);
|
fProjectionFileUpdater.install(this, projectionViewer);
|
||||||
}
|
}
|
||||||
|
@ -345,21 +337,24 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
*
|
*
|
||||||
* @since 3.1.1
|
* @since 3.1.1
|
||||||
*/
|
*/
|
||||||
private static final class InformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
|
private static final class InformationProvider
|
||||||
|
implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
|
||||||
|
|
||||||
private IRegion fHoverRegion;
|
private IRegion fHoverRegion;
|
||||||
private Object fHoverInfo;
|
private Object fHoverInfo;
|
||||||
private IInformationControlCreator fControlCreator;
|
private IInformationControlCreator fControlCreator;
|
||||||
|
|
||||||
InformationProvider(IRegion hoverRegion, Object hoverInfo, IInformationControlCreator controlCreator) {
|
InformationProvider(IRegion hoverRegion, Object hoverInfo, IInformationControlCreator controlCreator) {
|
||||||
fHoverRegion= hoverRegion;
|
fHoverRegion = hoverRegion;
|
||||||
fHoverInfo= hoverInfo;
|
fHoverInfo = hoverInfo;
|
||||||
fControlCreator= controlCreator;
|
fControlCreator = controlCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRegion getSubject(ITextViewer textViewer, int invocationOffset) {
|
public IRegion getSubject(ITextViewer textViewer, int invocationOffset) {
|
||||||
return fHoverRegion;
|
return fHoverRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInformation(ITextViewer textViewer, IRegion subject) {
|
public String getInformation(ITextViewer textViewer, IRegion subject) {
|
||||||
return fHoverInfo.toString();
|
return fHoverInfo.toString();
|
||||||
|
@ -369,6 +364,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
public Object getInformation2(ITextViewer textViewer, IRegion subject) {
|
public Object getInformation2(ITextViewer textViewer, IRegion subject) {
|
||||||
return fHoverInfo;
|
return fHoverInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
return fControlCreator;
|
return fControlCreator;
|
||||||
|
@ -394,38 +390,39 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
* @param prefix the prefix
|
* @param prefix the prefix
|
||||||
* @param textOperationAction the text operation action
|
* @param textOperationAction the text operation action
|
||||||
*/
|
*/
|
||||||
public InformationDispatchAction(ResourceBundle resourceBundle, String prefix, final TextOperationAction textOperationAction) {
|
public InformationDispatchAction(ResourceBundle resourceBundle, String prefix,
|
||||||
|
final TextOperationAction textOperationAction) {
|
||||||
super(resourceBundle, prefix, AutoconfEditor.this);
|
super(resourceBundle, prefix, AutoconfEditor.this);
|
||||||
if (textOperationAction == null)
|
if (textOperationAction == null)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
fTextOperationAction= textOperationAction;
|
fTextOperationAction = textOperationAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
ISourceViewer sourceViewer= getSourceViewer();
|
ISourceViewer sourceViewer = getSourceViewer();
|
||||||
if (sourceViewer == null) {
|
if (sourceViewer == null) {
|
||||||
fTextOperationAction.run();
|
fTextOperationAction.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceViewer instanceof ITextViewerExtension4) {
|
if (sourceViewer instanceof ITextViewerExtension4) {
|
||||||
ITextViewerExtension4 extension4= (ITextViewerExtension4) sourceViewer;
|
ITextViewerExtension4 extension4 = (ITextViewerExtension4) sourceViewer;
|
||||||
if (extension4.moveFocusToWidgetToken())
|
if (extension4.moveFocusToWidgetToken())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceViewer instanceof ITextViewerExtension2) {
|
if (sourceViewer instanceof ITextViewerExtension2) {
|
||||||
// does a text hover exist?
|
// does a text hover exist?
|
||||||
ITextHover textHover= ((ITextViewerExtension2) sourceViewer).getCurrentTextHover();
|
ITextHover textHover = ((ITextViewerExtension2) sourceViewer).getCurrentTextHover();
|
||||||
if (textHover != null && makeTextHoverFocusable(sourceViewer, textHover))
|
if (textHover != null && makeTextHoverFocusable(sourceViewer, textHover))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceViewer instanceof ISourceViewerExtension3) {
|
if (sourceViewer instanceof ISourceViewerExtension3) {
|
||||||
// does an annotation hover exist?
|
// does an annotation hover exist?
|
||||||
IAnnotationHover annotationHover= ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover();
|
IAnnotationHover annotationHover = ((ISourceViewerExtension3) sourceViewer).getCurrentAnnotationHover();
|
||||||
if (annotationHover != null && makeAnnotationHoverFocusable(sourceViewer, annotationHover))
|
if (annotationHover != null && makeAnnotationHoverFocusable(sourceViewer, annotationHover))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -443,28 +440,31 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private boolean makeTextHoverFocusable(ISourceViewer sourceViewer, ITextHover textHover) {
|
private boolean makeTextHoverFocusable(ISourceViewer sourceViewer, ITextHover textHover) {
|
||||||
Point hoverEventLocation= ((ITextViewerExtension2) sourceViewer).getHoverEventLocation();
|
Point hoverEventLocation = ((ITextViewerExtension2) sourceViewer).getHoverEventLocation();
|
||||||
int offset= computeOffsetAtLocation(sourceViewer, hoverEventLocation.x, hoverEventLocation.y);
|
int offset = computeOffsetAtLocation(sourceViewer, hoverEventLocation.x, hoverEventLocation.y);
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IRegion hoverRegion= textHover.getHoverRegion(sourceViewer, offset);
|
IRegion hoverRegion = textHover.getHoverRegion(sourceViewer, offset);
|
||||||
if (hoverRegion == null)
|
if (hoverRegion == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
String hoverInfo= textHover.getHoverInfo(sourceViewer, hoverRegion);
|
String hoverInfo = textHover.getHoverInfo(sourceViewer, hoverRegion);
|
||||||
|
|
||||||
IInformationControlCreator controlCreator= null;
|
IInformationControlCreator controlCreator = null;
|
||||||
if (textHover instanceof IInformationProviderExtension2)
|
if (textHover instanceof IInformationProviderExtension2)
|
||||||
controlCreator= ((IInformationProviderExtension2)textHover).getInformationPresenterControlCreator();
|
controlCreator = ((IInformationProviderExtension2) textHover)
|
||||||
|
.getInformationPresenterControlCreator();
|
||||||
|
|
||||||
IInformationProvider informationProvider= new InformationProvider(hoverRegion, hoverInfo, controlCreator);
|
IInformationProvider informationProvider = new InformationProvider(hoverRegion, hoverInfo,
|
||||||
|
controlCreator);
|
||||||
|
|
||||||
fInformationPresenter.setOffset(offset);
|
fInformationPresenter.setOffset(offset);
|
||||||
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM);
|
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM);
|
||||||
fInformationPresenter.setMargins(6, 6); // default values from AbstractInformationControlManager
|
fInformationPresenter.setMargins(6, 6); // default values from AbstractInformationControlManager
|
||||||
String contentType= TextUtilities.getContentType(sourceViewer.getDocument(), AutoconfPartitionScanner.AUTOCONF_MACRO, offset, true);
|
String contentType = TextUtilities.getContentType(sourceViewer.getDocument(),
|
||||||
|
AutoconfPartitionScanner.AUTOCONF_MACRO, offset, true);
|
||||||
fInformationPresenter.setInformationProvider(informationProvider, contentType);
|
fInformationPresenter.setInformationProvider(informationProvider, contentType);
|
||||||
fInformationPresenter.showInformation();
|
fInformationPresenter.showInformation();
|
||||||
|
|
||||||
|
@ -483,8 +483,8 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
* @return <code>true</code> if successful, <code>false</code> otherwise
|
* @return <code>true</code> if successful, <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
private boolean makeAnnotationHoverFocusable(ISourceViewer sourceViewer, IAnnotationHover annotationHover) {
|
private boolean makeAnnotationHoverFocusable(ISourceViewer sourceViewer, IAnnotationHover annotationHover) {
|
||||||
IVerticalRulerInfo info= getVerticalRuler();
|
IVerticalRulerInfo info = getVerticalRuler();
|
||||||
int line= info.getLineOfLastMouseButtonActivity();
|
int line = info.getLineOfLastMouseButtonActivity();
|
||||||
if (line == -1)
|
if (line == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -493,44 +493,47 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
// compute the hover information
|
// compute the hover information
|
||||||
Object hoverInfo;
|
Object hoverInfo;
|
||||||
if (annotationHover instanceof IAnnotationHoverExtension) {
|
if (annotationHover instanceof IAnnotationHoverExtension) {
|
||||||
IAnnotationHoverExtension extension= (IAnnotationHoverExtension) annotationHover;
|
IAnnotationHoverExtension extension = (IAnnotationHoverExtension) annotationHover;
|
||||||
ILineRange hoverLineRange= extension.getHoverLineRange(sourceViewer, line);
|
ILineRange hoverLineRange = extension.getHoverLineRange(sourceViewer, line);
|
||||||
if (hoverLineRange == null)
|
if (hoverLineRange == null)
|
||||||
return false;
|
return false;
|
||||||
final int maxVisibleLines= Integer.MAX_VALUE; // allow any number of lines being displayed, as we support scrolling
|
final int maxVisibleLines = Integer.MAX_VALUE; // allow any number of lines being displayed, as we support scrolling
|
||||||
hoverInfo= extension.getHoverInfo(sourceViewer, hoverLineRange, maxVisibleLines);
|
hoverInfo = extension.getHoverInfo(sourceViewer, hoverLineRange, maxVisibleLines);
|
||||||
} else {
|
} else {
|
||||||
hoverInfo= annotationHover.getHoverInfo(sourceViewer, line);
|
hoverInfo = annotationHover.getHoverInfo(sourceViewer, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hover region: the beginning of the concerned line to place the control right over the line
|
// hover region: the beginning of the concerned line to place the control right over the line
|
||||||
IDocument document= sourceViewer.getDocument();
|
IDocument document = sourceViewer.getDocument();
|
||||||
int offset= document.getLineOffset(line);
|
int offset = document.getLineOffset(line);
|
||||||
String contentType= TextUtilities.getContentType(document, AutoconfPartitionScanner.AUTOCONF_MACRO, offset, true);
|
String contentType = TextUtilities.getContentType(document, AutoconfPartitionScanner.AUTOCONF_MACRO,
|
||||||
|
offset, true);
|
||||||
|
|
||||||
IInformationControlCreator controlCreator= null;
|
IInformationControlCreator controlCreator = null;
|
||||||
|
|
||||||
// /*
|
// /*
|
||||||
// * XXX: This is a hack to avoid API changes at the end of 3.2,
|
// * XXX: This is a hack to avoid API changes at the end of 3.2,
|
||||||
// * and should be fixed for 3.3, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=137967
|
// * and should be fixed for 3.3, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=137967
|
||||||
// */
|
// */
|
||||||
// if ("org.eclipse.jface.text.source.projection.ProjectionAnnotationHover".equals(annotationHover.getClass().getName())) { //$NON-NLS-1$
|
// if ("org.eclipse.jface.text.source.projection.ProjectionAnnotationHover".equals(annotationHover.getClass().getName())) { //$NON-NLS-1$
|
||||||
// controlCreator= new IInformationControlCreator() {
|
// controlCreator= new IInformationControlCreator() {
|
||||||
// public IInformationControl createInformationControl(Shell shell) {
|
// public IInformationControl createInformationControl(Shell shell) {
|
||||||
// int shellStyle= SWT.RESIZE | SWT.TOOL | getOrientation();
|
// int shellStyle= SWT.RESIZE | SWT.TOOL | getOrientation();
|
||||||
// int style= SWT.V_SCROLL | SWT.H_SCROLL;
|
// int style= SWT.V_SCROLL | SWT.H_SCROLL;
|
||||||
// return new SourceViewerInformationControl(shell, shellStyle, style);
|
// return new SourceViewerInformationControl(shell, shellStyle, style);
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// } else {
|
// } else {
|
||||||
if (annotationHover instanceof IInformationProviderExtension2)
|
if (annotationHover instanceof IInformationProviderExtension2)
|
||||||
controlCreator= ((IInformationProviderExtension2) annotationHover).getInformationPresenterControlCreator();
|
controlCreator = ((IInformationProviderExtension2) annotationHover)
|
||||||
|
.getInformationPresenterControlCreator();
|
||||||
else if (annotationHover instanceof IAnnotationHoverExtension)
|
else if (annotationHover instanceof IAnnotationHoverExtension)
|
||||||
controlCreator= ((IAnnotationHoverExtension) annotationHover).getHoverControlCreator();
|
controlCreator = ((IAnnotationHoverExtension) annotationHover).getHoverControlCreator();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
IInformationProvider informationProvider= new InformationProvider(new Region(offset, 0), hoverInfo, controlCreator);
|
IInformationProvider informationProvider = new InformationProvider(new Region(offset, 0), hoverInfo,
|
||||||
|
controlCreator);
|
||||||
|
|
||||||
fInformationPresenter.setOffset(offset);
|
fInformationPresenter.setOffset(offset);
|
||||||
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT);
|
fInformationPresenter.setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT);
|
||||||
|
@ -548,23 +551,23 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
// modified version from TextViewer
|
// modified version from TextViewer
|
||||||
private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) {
|
private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) {
|
||||||
|
|
||||||
StyledText styledText= textViewer.getTextWidget();
|
StyledText styledText = textViewer.getTextWidget();
|
||||||
IDocument document= textViewer.getDocument();
|
IDocument document = textViewer.getDocument();
|
||||||
|
|
||||||
if (document == null)
|
if (document == null)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int widgetOffset= styledText.getOffsetAtLocation(new Point(x, y));
|
int widgetOffset = styledText.getOffsetAtLocation(new Point(x, y));
|
||||||
Point p= styledText.getLocationAtOffset(widgetOffset);
|
Point p = styledText.getLocationAtOffset(widgetOffset);
|
||||||
if (p.x > x)
|
if (p.x > x)
|
||||||
widgetOffset--;
|
widgetOffset--;
|
||||||
|
|
||||||
if (textViewer instanceof ITextViewerExtension5) {
|
if (textViewer instanceof ITextViewerExtension5) {
|
||||||
ITextViewerExtension5 extension= (ITextViewerExtension5) textViewer;
|
ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
|
||||||
return extension.widgetOffset2ModelOffset(widgetOffset);
|
return extension.widgetOffset2ModelOffset(widgetOffset);
|
||||||
} else {
|
} else {
|
||||||
IRegion visibleRegion= textViewer.getVisibleRegion();
|
IRegion visibleRegion = textViewer.getVisibleRegion();
|
||||||
return widgetOffset + visibleRegion.getOffset();
|
return widgetOffset + visibleRegion.getOffset();
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -613,30 +616,33 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
* @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
|
* @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
boolean isFoldingEnabled() {
|
boolean isFoldingEnabled() {
|
||||||
return AutotoolsPlugin.getDefault().getPreferenceStore().getBoolean(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED);
|
return AutotoolsPlugin.getDefault().getPreferenceStore()
|
||||||
|
.getBoolean(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeKeyBindingScopes() {
|
protected void initializeKeyBindingScopes() {
|
||||||
setKeyBindingScopes(new String [] { AutotoolsUIPlugin.getUniqueIdentifier() + ".editor.scope" } ); //$NON-NLS-1$
|
setKeyBindingScopes(new String[] { AutotoolsUIPlugin.getUniqueIdentifier() + ".editor.scope" }); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createActions() {
|
protected void createActions() {
|
||||||
super.createActions();
|
super.createActions();
|
||||||
// TODO: Figure out how to do this later.
|
// TODO: Figure out how to do this later.
|
||||||
// fFoldingGroup= new FoldingActionGroup(this, getSourceViewer());
|
// fFoldingGroup= new FoldingActionGroup(this, getSourceViewer());
|
||||||
|
|
||||||
// Sticky hover support
|
// Sticky hover support
|
||||||
ResourceAction resAction= new TextOperationAction(AutoconfEditorMessages.getResourceBundle(), "ShowToolTip.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
|
ResourceAction resAction = new TextOperationAction(AutoconfEditorMessages.getResourceBundle(), "ShowToolTip.", //$NON-NLS-1$
|
||||||
resAction= new InformationDispatchAction(AutoconfEditorMessages.getResourceBundle(), "ShowToolTip.", (TextOperationAction) resAction); //$NON-NLS-1$
|
this, ISourceViewer.INFORMATION, true);
|
||||||
|
resAction = new InformationDispatchAction(AutoconfEditorMessages.getResourceBundle(), "ShowToolTip.", //$NON-NLS-1$
|
||||||
|
(TextOperationAction) resAction);
|
||||||
resAction.setActionDefinitionId(IAutotoolEditorActionDefinitionIds.SHOW_TOOLTIP);
|
resAction.setActionDefinitionId(IAutotoolEditorActionDefinitionIds.SHOW_TOOLTIP);
|
||||||
setAction("ShowToolTip", resAction); //$NON-NLS-1$
|
setAction("ShowToolTip", resAction); //$NON-NLS-1$
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(resAction, IAutotoolHelpContextIds.SHOW_TOOLTIP_ACTION);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(resAction, IAutotoolHelpContextIds.SHOW_TOOLTIP_ACTION);
|
||||||
|
|
||||||
// Content assist
|
// Content assist
|
||||||
Action action = new ContentAssistAction(AutoconfEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
|
Action action = new ContentAssistAction(AutoconfEditorMessages.getResourceBundle(), "ContentAssistProposal.", //$NON-NLS-1$
|
||||||
|
this);
|
||||||
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
|
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
|
||||||
setAction("ContentAssistProposal", action); //$NON-NLS-1$
|
setAction("ContentAssistProposal", action); //$NON-NLS-1$
|
||||||
markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
|
markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
|
||||||
|
@ -659,21 +665,21 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
super.createPartControl(parent);
|
super.createPartControl(parent);
|
||||||
|
|
||||||
// Sticky hover support
|
// Sticky hover support
|
||||||
IInformationControlCreator informationControlCreator= new IInformationControlCreator() {
|
IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
|
||||||
@Override
|
@Override
|
||||||
public IInformationControl createInformationControl(Shell shell) {
|
public IInformationControl createInformationControl(Shell shell) {
|
||||||
return new DefaultInformationControl(shell, true);
|
return new DefaultInformationControl(shell, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fInformationPresenter= new InformationPresenter(informationControlCreator);
|
fInformationPresenter = new InformationPresenter(informationControlCreator);
|
||||||
fInformationPresenter.setSizeConstraints(60, 10, true, true);
|
fInformationPresenter.setSizeConstraints(60, 10, true, true);
|
||||||
fInformationPresenter.install(getSourceViewer());
|
fInformationPresenter.install(getSourceViewer());
|
||||||
fInformationPresenter.setDocumentPartitioning(AutoconfPartitionScanner.AUTOCONF_MACRO);
|
fInformationPresenter.setDocumentPartitioning(AutoconfPartitionScanner.AUTOCONF_MACRO);
|
||||||
|
|
||||||
ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
|
ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
|
||||||
|
|
||||||
fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
|
fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
|
||||||
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
|
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
|
||||||
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
|
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
|
||||||
fProjectionSupport.install();
|
fProjectionSupport.install();
|
||||||
|
@ -681,7 +687,7 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
if (isFoldingEnabled())
|
if (isFoldingEnabled())
|
||||||
projectionViewer.doOperation(ProjectionViewer.TOGGLE);
|
projectionViewer.doOperation(ProjectionViewer.TOGGLE);
|
||||||
|
|
||||||
fProjectionFileUpdater= new ProjectionFileUpdater();
|
fProjectionFileUpdater = new ProjectionFileUpdater();
|
||||||
if (fProjectionFileUpdater != null) {
|
if (fProjectionFileUpdater != null) {
|
||||||
fProjectionFileUpdater.install(this, projectionViewer);
|
fProjectionFileUpdater.install(this, projectionViewer);
|
||||||
fProjectionFileUpdater.initialize();
|
fProjectionFileUpdater.initialize();
|
||||||
|
@ -690,13 +696,14 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IAutotoolHelpContextIds.AC_EDITOR_VIEW);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IAutotoolHelpContextIds.AC_EDITOR_VIEW);
|
||||||
|
|
||||||
// TODO: Do we need the following two lines?
|
// TODO: Do we need the following two lines?
|
||||||
// fEditorSelectionChangedListener= new EditorSelectionChangedListener();
|
// fEditorSelectionChangedListener= new EditorSelectionChangedListener();
|
||||||
// fEditorSelectionChangedListener.install(getSelectionProvider());
|
// fEditorSelectionChangedListener.install(getSelectionProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
|
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
|
||||||
ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
|
ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(),
|
||||||
|
styles);
|
||||||
|
|
||||||
// ensure decoration support has been created and configured.
|
// ensure decoration support has been created and configured.
|
||||||
getSourceViewerDecorationSupport(viewer);
|
getSourceViewerDecorationSupport(viewer);
|
||||||
|
@ -704,12 +711,11 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (fProjectionFileUpdater != null) {
|
if (fProjectionFileUpdater != null) {
|
||||||
fProjectionFileUpdater.uninstall();
|
fProjectionFileUpdater.uninstall();
|
||||||
fProjectionFileUpdater= null;
|
fProjectionFileUpdater = null;
|
||||||
}
|
}
|
||||||
if (fProject != null) {
|
if (fProject != null) {
|
||||||
AutotoolsPropertyManager.getDefault().removeProjectPropertyListener(fProject, this);
|
AutotoolsPropertyManager.getDefault().removeProjectPropertyListener(fProject, this);
|
||||||
|
@ -719,11 +725,11 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void performRevert() {
|
protected void performRevert() {
|
||||||
ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
|
ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
|
||||||
projectionViewer.setRedraw(false);
|
projectionViewer.setRedraw(false);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
boolean projectionMode= projectionViewer.isProjectionMode();
|
boolean projectionMode = projectionViewer.isProjectionMode();
|
||||||
if (projectionMode) {
|
if (projectionMode) {
|
||||||
projectionViewer.disableProjection();
|
projectionViewer.disableProjection();
|
||||||
if (fProjectionFileUpdater != null)
|
if (fProjectionFileUpdater != null)
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a macro call by checking against the stored macro prototypes
|
* Validate a macro call by checking against the stored macro prototypes
|
||||||
*/
|
*/
|
||||||
|
@ -44,8 +43,7 @@ public class AutoconfEditorMacroValidator implements IAutoconfMacroValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateMacroCall(AutoconfMacroElement macro)
|
public void validateMacroCall(AutoconfMacroElement macro) throws ParseException, InvalidMacroException {
|
||||||
throws ParseException, InvalidMacroException {
|
|
||||||
AutoconfPrototype p = AutoconfTextHover.getPrototype(macro.getName(), fEditor);
|
AutoconfPrototype p = AutoconfTextHover.getPrototype(macro.getName(), fEditor);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
boolean tooFew = false;
|
boolean tooFew = false;
|
||||||
|
@ -81,22 +79,16 @@ public class AutoconfEditorMacroValidator implements IAutoconfMacroValidator {
|
||||||
if (!justRight) {
|
if (!justRight) {
|
||||||
if (tooFew) {
|
if (tooFew) {
|
||||||
String formatString = AutoconfEditorMessages.getFormattedString(AUTOCONF_MACRO_ARGS_TOO_FEW,
|
String formatString = AutoconfEditorMessages.getFormattedString(AUTOCONF_MACRO_ARGS_TOO_FEW,
|
||||||
AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION),
|
AutotoolsPlugin.getDefault().getPreferenceStore()
|
||||||
|
.getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION),
|
||||||
p.getName(), Integer.toString(minParms));
|
p.getName(), Integer.toString(minParms));
|
||||||
throw new ParseException(
|
throw new ParseException(formatString, start, end, lineNumber, 0, length, IMarker.SEVERITY_WARNING);
|
||||||
formatString,
|
|
||||||
start, end,
|
|
||||||
lineNumber, 0, length,
|
|
||||||
IMarker.SEVERITY_WARNING);
|
|
||||||
} else if (tooMany) {
|
} else if (tooMany) {
|
||||||
String formatString = AutoconfEditorMessages.getFormattedString(AUTOCONF_MACRO_ARGS_TOO_MANY,
|
String formatString = AutoconfEditorMessages.getFormattedString(AUTOCONF_MACRO_ARGS_TOO_MANY,
|
||||||
AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION),
|
AutotoolsPlugin.getDefault().getPreferenceStore()
|
||||||
|
.getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION),
|
||||||
p.getName(), Integer.toString(maxParms));
|
p.getName(), Integer.toString(maxParms));
|
||||||
throw new ParseException(
|
throw new ParseException(formatString, start, end, lineNumber, 0, length, IMarker.SEVERITY_WARNING);
|
||||||
formatString,
|
|
||||||
start, end,
|
|
||||||
lineNumber, 0, length,
|
|
||||||
IMarker.SEVERITY_WARNING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,14 @@ import java.text.MessageFormat;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AutoconfEditorMessages
|
* AutoconfEditorMessages
|
||||||
*/
|
*/
|
||||||
public class AutoconfEditorMessages {
|
public class AutoconfEditorMessages {
|
||||||
|
|
||||||
private static final String RESOURCE_BUNDLE= AutoconfEditorMessages.class.getName();
|
private static final String RESOURCE_BUNDLE = AutoconfEditorMessages.class.getName();
|
||||||
|
|
||||||
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
private static ResourceBundle fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||||
|
|
||||||
private AutoconfEditorMessages() {
|
private AutoconfEditorMessages() {
|
||||||
}
|
}
|
||||||
|
@ -42,6 +41,7 @@ public class AutoconfEditorMessages {
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a string from the resource bundle and formats it with the argument
|
* Gets a string from the resource bundle and formats it with the argument
|
||||||
*
|
*
|
||||||
|
@ -49,16 +49,17 @@ public class AutoconfEditorMessages {
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(String key, Object arg) {
|
public static String getFormattedString(String key, Object arg) {
|
||||||
String format= null;
|
String format = null;
|
||||||
try {
|
try {
|
||||||
format= fgResourceBundle.getString(key);
|
format = fgResourceBundle.getString(key);
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (arg == null)
|
if (arg == null)
|
||||||
arg= ""; //$NON-NLS-1$
|
arg = ""; //$NON-NLS-1$
|
||||||
return MessageFormat.format(format, new Object[] { arg });
|
return MessageFormat.format(format, new Object[] { arg });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a string from the resource bundle and formats it with the arguments
|
* Gets a string from the resource bundle and formats it with the arguments
|
||||||
*
|
*
|
||||||
|
@ -66,16 +67,16 @@ public class AutoconfEditorMessages {
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(String key, Object arg1, Object arg2) {
|
public static String getFormattedString(String key, Object arg1, Object arg2) {
|
||||||
String format= null;
|
String format = null;
|
||||||
try {
|
try {
|
||||||
format= fgResourceBundle.getString(key);
|
format = fgResourceBundle.getString(key);
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (arg1 == null)
|
if (arg1 == null)
|
||||||
arg1= ""; //$NON-NLS-1$
|
arg1 = ""; //$NON-NLS-1$
|
||||||
if (arg2 == null)
|
if (arg2 == null)
|
||||||
arg2= ""; //$NON-NLS-1$
|
arg2 = ""; //$NON-NLS-1$
|
||||||
return MessageFormat.format(format, new Object[] { arg1, arg2 });
|
return MessageFormat.format(format, new Object[] { arg1, arg2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,18 +87,18 @@ public class AutoconfEditorMessages {
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(String key, Object arg1, Object arg2, Object arg3) {
|
public static String getFormattedString(String key, Object arg1, Object arg2, Object arg3) {
|
||||||
String format= null;
|
String format = null;
|
||||||
try {
|
try {
|
||||||
format= fgResourceBundle.getString(key);
|
format = fgResourceBundle.getString(key);
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (arg1 == null)
|
if (arg1 == null)
|
||||||
arg1= ""; //$NON-NLS-1$
|
arg1 = ""; //$NON-NLS-1$
|
||||||
if (arg2 == null)
|
if (arg2 == null)
|
||||||
arg2= ""; //$NON-NLS-1$
|
arg2 = ""; //$NON-NLS-1$
|
||||||
if (arg3 == null)
|
if (arg3 == null)
|
||||||
arg3= ""; //$NON-NLS-1$
|
arg3 = ""; //$NON-NLS-1$
|
||||||
return MessageFormat.format(format, new Object[] { arg1, arg2, arg3 });
|
return MessageFormat.format(format, new Object[] { arg1, arg2, arg3 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +109,9 @@ public class AutoconfEditorMessages {
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public static String getFormattedString(String key, boolean arg) {
|
public static String getFormattedString(String key, boolean arg) {
|
||||||
String format= null;
|
String format = null;
|
||||||
try {
|
try {
|
||||||
format= fgResourceBundle.getString(key);
|
format = fgResourceBundle.getString(key);
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.jface.text.source.Annotation;
|
||||||
import org.eclipse.jface.text.source.AnnotationModel;
|
import org.eclipse.jface.text.source.AnnotationModel;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfErrorHandler implements IAutoconfErrorHandler {
|
public class AutoconfErrorHandler implements IAutoconfErrorHandler {
|
||||||
|
|
||||||
public static final String CDT_ANNOTATION_INFO = "org.eclipse.cdt.ui.info"; //$NON-NLS-1$
|
public static final String CDT_ANNOTATION_INFO = "org.eclipse.cdt.ui.info"; //$NON-NLS-1$
|
||||||
|
@ -40,7 +39,8 @@ public class AutoconfErrorHandler implements IAutoconfErrorHandler {
|
||||||
private AnnotationModel fAnnotationModel;
|
private AnnotationModel fAnnotationModel;
|
||||||
|
|
||||||
public AutoconfErrorHandler(IEditorInput input) {
|
public AutoconfErrorHandler(IEditorInput input) {
|
||||||
this.fAnnotationModel = (AnnotationModel)AutoconfEditor.getAutoconfDocumentProvider().getAnnotationModel(input);
|
this.fAnnotationModel = (AnnotationModel) AutoconfEditor.getAutoconfDocumentProvider()
|
||||||
|
.getAnnotationModel(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: no quickfixes yet implemented, but maybe in the future
|
// TODO: no quickfixes yet implemented, but maybe in the future
|
||||||
|
@ -77,19 +77,17 @@ public class AutoconfErrorHandler implements IAutoconfErrorHandler {
|
||||||
else if (e.getSeverity() == CDT_WARNING)
|
else if (e.getSeverity() == CDT_WARNING)
|
||||||
annotationType = CDT_ANNOTATION_WARNING;
|
annotationType = CDT_ANNOTATION_WARNING;
|
||||||
Annotation annotation = new AutoconfAnnotation(annotationType, true, e.getLocalizedMessage());
|
Annotation annotation = new AutoconfAnnotation(annotationType, true, e.getLocalizedMessage());
|
||||||
Position p = new Position(charStart.intValue(),charEnd.intValue() - charStart.intValue());
|
Position p = new Position(charStart.intValue(), charEnd.intValue() - charStart.intValue());
|
||||||
fAnnotationModel.addAnnotation(annotation, p);
|
fAnnotationModel.addAnnotation(annotation, p);
|
||||||
annotations.put(p, annotation);
|
annotations.put(p, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAllExistingMarkers()
|
public void removeAllExistingMarkers() {
|
||||||
{
|
|
||||||
fAnnotationModel.removeAllAnnotations();
|
fAnnotationModel.removeAllAnnotations();
|
||||||
annotations.clear();
|
annotations.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeExistingMarkers(int offset, int length)
|
public void removeExistingMarkers(int offset, int length) {
|
||||||
{
|
|
||||||
Iterator<Annotation> i = fAnnotationModel.getAnnotationIterator();
|
Iterator<Annotation> i = fAnnotationModel.getAnnotationIterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Annotation annotation = i.next();
|
Annotation annotation = i.next();
|
||||||
|
|
|
@ -42,10 +42,10 @@ public class AutoconfIdentifierRule implements IPredicateRule {
|
||||||
@Override
|
@Override
|
||||||
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
|
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
|
||||||
int c = scanner.read();
|
int c = scanner.read();
|
||||||
if (Character.isLetterOrDigit((char)c) || fExtraChars.indexOf((char)c) >= 0) {
|
if (Character.isLetterOrDigit((char) c) || fExtraChars.indexOf((char) c) >= 0) {
|
||||||
do {
|
do {
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
} while (Character.isLetterOrDigit((char)c) || fExtraChars.indexOf((char)c) >= 0);
|
} while (Character.isLetterOrDigit((char) c) || fExtraChars.indexOf((char) c) >= 0);
|
||||||
scanner.unread();
|
scanner.unread();
|
||||||
return fToken;
|
return fToken;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,3 @@ public class AutoconfKeywordDetector implements IWordDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class AutoconfMacro implements Comparable<Object> {
|
||||||
public boolean equals(Object x) {
|
public boolean equals(Object x) {
|
||||||
if (x == null)
|
if (x == null)
|
||||||
return false;
|
return false;
|
||||||
AutoconfMacro y = (AutoconfMacro)x;
|
AutoconfMacro y = (AutoconfMacro) x;
|
||||||
return getName().equals(y.getName());
|
return getName().equals(y.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,9 @@ import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
private Map<String, IToken> fTokenMap= new HashMap<>();
|
private Map<String, IToken> fTokenMap = new HashMap<>();
|
||||||
private String[] fPropertyNamesColor;
|
private String[] fPropertyNamesColor;
|
||||||
|
|
||||||
private int quoteLevel;
|
private int quoteLevel;
|
||||||
|
@ -55,37 +54,31 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
*/
|
*/
|
||||||
private String[] fPropertyNamesItalic;
|
private String[] fPropertyNamesItalic;
|
||||||
|
|
||||||
private static String[] keywords = {
|
private static String[] keywords = { "case", "do", "done", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"case", "do", "done", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
"esac", "if", "elif", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"esac", "if", "elif", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"else", "fi", "for", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"else", "fi", "for", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"in", "then" }; //$NON-NLS-1$ //$NON-NLS-2$
|
"in", "then" }; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
static final String[] fTokenProperties = new String[] {
|
static final String[] fTokenProperties = new String[] { ColorManager.AUTOCONF_COMMENT_COLOR,
|
||||||
ColorManager.AUTOCONF_COMMENT_COLOR,
|
ColorManager.AUTOCONF_KEYWORD_COLOR, ColorManager.AUTOCONF_ACMACRO_COLOR,
|
||||||
ColorManager.AUTOCONF_KEYWORD_COLOR,
|
ColorManager.AUTOCONF_AMMACRO_COLOR, ColorManager.AUTOCONF_VAR_REF_COLOR,
|
||||||
ColorManager.AUTOCONF_ACMACRO_COLOR,
|
ColorManager.AUTOCONF_VAR_SET_COLOR, ColorManager.AUTOCONF_CODESEQ_COLOR,
|
||||||
ColorManager.AUTOCONF_AMMACRO_COLOR,
|
ColorManager.AUTOCONF_DEFAULT_COLOR, };
|
||||||
ColorManager.AUTOCONF_VAR_REF_COLOR,
|
|
||||||
ColorManager.AUTOCONF_VAR_SET_COLOR,
|
|
||||||
ColorManager.AUTOCONF_CODESEQ_COLOR,
|
|
||||||
ColorManager.AUTOCONF_DEFAULT_COLOR,
|
|
||||||
};
|
|
||||||
|
|
||||||
public AutoconfMacroCodeScanner() {
|
public AutoconfMacroCodeScanner() {
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
IToken other= getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
IToken other = getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
||||||
IToken keyword = getToken(ColorManager.AUTOCONF_KEYWORD_COLOR);
|
IToken keyword = getToken(ColorManager.AUTOCONF_KEYWORD_COLOR);
|
||||||
IToken comment= getToken(ColorManager.AUTOCONF_COMMENT_COLOR);
|
IToken comment = getToken(ColorManager.AUTOCONF_COMMENT_COLOR);
|
||||||
IToken string = getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
IToken string = getToken(ColorManager.AUTOCONF_DEFAULT_COLOR);
|
||||||
IToken varRef = getToken(ColorManager.AUTOCONF_VAR_REF_COLOR);
|
IToken varRef = getToken(ColorManager.AUTOCONF_VAR_REF_COLOR);
|
||||||
IToken acmacro = getToken(ColorManager.AUTOCONF_ACMACRO_COLOR);
|
IToken acmacro = getToken(ColorManager.AUTOCONF_ACMACRO_COLOR);
|
||||||
IToken ammacro = getToken(ColorManager.AUTOCONF_AMMACRO_COLOR);
|
IToken ammacro = getToken(ColorManager.AUTOCONF_AMMACRO_COLOR);
|
||||||
IToken code = getToken(ColorManager.AUTOCONF_CODESEQ_COLOR);
|
IToken code = getToken(ColorManager.AUTOCONF_CODESEQ_COLOR);
|
||||||
|
|
||||||
List<IRule> rules= new ArrayList<>();
|
List<IRule> rules = new ArrayList<>();
|
||||||
|
|
||||||
// Add rule for single line comments.
|
// Add rule for single line comments.
|
||||||
rules.add(new RestrictedEndOfLineRule("dnl", "[]", comment)); //$NON-NLS-1$
|
rules.add(new RestrictedEndOfLineRule("dnl", "[]", comment)); //$NON-NLS-1$
|
||||||
|
@ -93,8 +86,7 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
// Add special recursive rule for strings which allows variable
|
// Add special recursive rule for strings which allows variable
|
||||||
// references to be internally tokenized.
|
// references to be internally tokenized.
|
||||||
RecursiveSingleLineRule stringRule =
|
RecursiveSingleLineRule stringRule = new RecursiveSingleLineRule("\"", "\"", string, '\\'); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
new RecursiveSingleLineRule("\"", "\"", string, '\\'); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
stringRule.addRule(new SingleLineRule("${", "}", varRef)); //$NON-NLS-1$ //$NON-NLS-2$
|
stringRule.addRule(new SingleLineRule("${", "}", varRef)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
rules.add(stringRule);
|
rules.add(stringRule);
|
||||||
|
|
||||||
|
@ -116,8 +108,8 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
rules.add(new InlineDataRule(code));
|
rules.add(new InlineDataRule(code));
|
||||||
|
|
||||||
// Add word rule for keywords.
|
// Add word rule for keywords.
|
||||||
WordRule wordRule= new WordRule(new AutoconfWordDetector(), other);
|
WordRule wordRule = new WordRule(new AutoconfWordDetector(), other);
|
||||||
for (int i= 0; i < keywords.length; i++)
|
for (int i = 0; i < keywords.length; i++)
|
||||||
wordRule.addWord(keywords[i], keyword);
|
wordRule.addWord(keywords[i], keyword);
|
||||||
rules.add(wordRule);
|
rules.add(wordRule);
|
||||||
|
|
||||||
|
@ -129,7 +121,7 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
rules.add(new WhitespaceRule(new AutoconfWhitespaceDetector()));
|
rules.add(new WhitespaceRule(new AutoconfWhitespaceDetector()));
|
||||||
|
|
||||||
IRule[] result= new IRule[rules.size()];
|
IRule[] result = new IRule[rules.size()];
|
||||||
rules.toArray(result);
|
rules.toArray(result);
|
||||||
setRules(result);
|
setRules(result);
|
||||||
}
|
}
|
||||||
|
@ -162,9 +154,10 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
|
|
||||||
private int indexOf(String property) {
|
private int indexOf(String property) {
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
int length= fPropertyNamesColor.length;
|
int length = fPropertyNamesColor.length;
|
||||||
for (int i= 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i]))
|
if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i])
|
||||||
|
|| property.equals(fPropertyNamesItalic[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,9 +185,9 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adaptToPreferenceChange(PropertyChangeEvent event) {
|
public void adaptToPreferenceChange(PropertyChangeEvent event) {
|
||||||
String p= event.getProperty();
|
String p = event.getProperty();
|
||||||
int index= indexOf(p);
|
int index = indexOf(p);
|
||||||
Token token= getToken(fPropertyNamesColor[index]);
|
Token token = getToken(fPropertyNamesColor[index]);
|
||||||
if (fPropertyNamesColor[index].equals(p))
|
if (fPropertyNamesColor[index].equals(p))
|
||||||
adaptToColorChange(event, token);
|
adaptToColorChange(event, token);
|
||||||
else if (fPropertyNamesBold[index].equals(p))
|
else if (fPropertyNamesBold[index].equals(p))
|
||||||
|
@ -204,17 +197,18 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void adaptToColorChange(PropertyChangeEvent event, Token token) {
|
protected void adaptToColorChange(PropertyChangeEvent event, Token token) {
|
||||||
RGB rgb= null;
|
RGB rgb = null;
|
||||||
Object value= event.getNewValue();
|
Object value = event.getNewValue();
|
||||||
if (value instanceof RGB) {
|
if (value instanceof RGB) {
|
||||||
rgb= (RGB) value;
|
rgb = (RGB) value;
|
||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
rgb= StringConverter.asRGB((String) value);
|
rgb = StringConverter.asRGB((String) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rgb != null) {
|
if (rgb != null) {
|
||||||
TextAttribute attr= (TextAttribute) token.getData();
|
TextAttribute attr = (TextAttribute) token.getData();
|
||||||
token.setData(new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle()));
|
token.setData(
|
||||||
|
new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,28 +216,29 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean eventValue= false;
|
boolean eventValue = false;
|
||||||
Object value= event.getNewValue();
|
Object value = event.getNewValue();
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
eventValue= ((Boolean) value).booleanValue();
|
eventValue = ((Boolean) value).booleanValue();
|
||||||
} else if (IPreferenceStore.TRUE.equals(value)) {
|
} else if (IPreferenceStore.TRUE.equals(value)) {
|
||||||
eventValue= true;
|
eventValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAttribute attr= (TextAttribute) token.getData();
|
TextAttribute attr = (TextAttribute) token.getData();
|
||||||
boolean activeValue= (attr.getStyle() & styleAttribute) == styleAttribute;
|
boolean activeValue = (attr.getStyle() & styleAttribute) == styleAttribute;
|
||||||
if (activeValue != eventValue) {
|
if (activeValue != eventValue) {
|
||||||
token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(), eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute));
|
token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(),
|
||||||
|
eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TextAttribute createTextAttribute(String colorID, String boldKey, String italicKey) {
|
protected TextAttribute createTextAttribute(String colorID, String boldKey, String italicKey) {
|
||||||
Color color= null;
|
Color color = null;
|
||||||
if (colorID != null) {
|
if (colorID != null) {
|
||||||
color= AutoconfEditor.getPreferenceColor(colorID);
|
color = AutoconfEditor.getPreferenceColor(colorID);
|
||||||
}
|
}
|
||||||
IPreferenceStore store= AutotoolsPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store = AutotoolsPlugin.getDefault().getPreferenceStore();
|
||||||
int style= store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
|
int style = store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
|
||||||
if (store.getBoolean(italicKey)) {
|
if (store.getBoolean(italicKey)) {
|
||||||
style |= SWT.ITALIC;
|
style |= SWT.ITALIC;
|
||||||
}
|
}
|
||||||
|
@ -256,14 +251,14 @@ public class AutoconfMacroCodeScanner extends RuleBasedScanner {
|
||||||
public final void initialize() {
|
public final void initialize() {
|
||||||
|
|
||||||
resetQuoteLevel();
|
resetQuoteLevel();
|
||||||
fPropertyNamesColor= getTokenProperties();
|
fPropertyNamesColor = getTokenProperties();
|
||||||
int length= fPropertyNamesColor.length;
|
int length = fPropertyNamesColor.length;
|
||||||
fPropertyNamesBold= new String[length];
|
fPropertyNamesBold = new String[length];
|
||||||
fPropertyNamesItalic= new String[length];
|
fPropertyNamesItalic = new String[length];
|
||||||
|
|
||||||
for (int i= 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
fPropertyNamesBold[i]= fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX;
|
fPropertyNamesBold[i] = fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX;
|
||||||
fPropertyNamesItalic[i]= fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX;
|
fPropertyNamesItalic[i] = fPropertyNamesColor[i] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX;
|
||||||
addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]);
|
addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,7 @@ import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
|
||||||
import org.eclipse.jface.text.contentassist.IContextInformation;
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
|
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
|
||||||
|
|
||||||
|
public class AutoconfMacroContentAssistProcessor implements IContentAssistProcessor {
|
||||||
public class AutoconfMacroContentAssistProcessor implements
|
|
||||||
IContentAssistProcessor {
|
|
||||||
|
|
||||||
protected AutoconfEditor editor;
|
protected AutoconfEditor editor;
|
||||||
|
|
||||||
|
@ -50,8 +48,7 @@ public class AutoconfMacroContentAssistProcessor implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
|
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
|
||||||
int offset) {
|
|
||||||
|
|
||||||
IDocument document = viewer.getDocument();
|
IDocument document = viewer.getDocument();
|
||||||
String prefix = ""; //$NON-NLS-1$
|
String prefix = ""; //$NON-NLS-1$
|
||||||
|
@ -80,11 +77,12 @@ public class AutoconfMacroContentAssistProcessor implements
|
||||||
if (macros[i].hasParms()) {
|
if (macros[i].hasParms()) {
|
||||||
// Provide parameter info as context information that
|
// Provide parameter info as context information that
|
||||||
// is tied to the completion proposal.
|
// is tied to the completion proposal.
|
||||||
ci = new AutoconfMacroProposalContextInformation(macros[i].getParms(), macros[i].getParms());
|
ci = new AutoconfMacroProposalContextInformation(macros[i].getParms(),
|
||||||
|
macros[i].getParms());
|
||||||
ci.setContextInformationPosition(offset - prefixLen + cursorPos - 1);
|
ci.setContextInformationPosition(offset - prefixLen + cursorPos - 1);
|
||||||
}
|
}
|
||||||
ICompletionProposal cp = new CompletionProposal(template, offset - prefixLen, prefixLen, cursorPos, null,
|
ICompletionProposal cp = new CompletionProposal(template, offset - prefixLen, prefixLen,
|
||||||
name, ci, AutoconfTextHover.getIndexedInfo(name, editor));
|
cursorPos, null, name, ci, AutoconfTextHover.getIndexedInfo(name, editor));
|
||||||
validList.add(cp);
|
validList.add(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,8 +94,7 @@ public class AutoconfMacroContentAssistProcessor implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IContextInformation[] computeContextInformation(ITextViewer viewer,
|
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
|
||||||
int offset) {
|
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,4 @@ public class AutoconfMacroDamagerRepairer extends DefaultDamagerRepairer {
|
||||||
super(scanner);
|
super(scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,16 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
@Override
|
@Override
|
||||||
public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
|
public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
|
||||||
|
|
||||||
fPosition= documentPosition;
|
fPosition = documentPosition;
|
||||||
fViewer= viewer;
|
fViewer = viewer;
|
||||||
fInformation= info;
|
fInformation = info;
|
||||||
|
|
||||||
fCurrentParameter= -1;
|
fCurrentParameter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
|
private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
|
||||||
while (pos < end) {
|
while (pos < end) {
|
||||||
char curr= d.getChar(pos);
|
char curr = d.getChar(pos);
|
||||||
pos++;
|
pos++;
|
||||||
if (curr == '\\') {
|
if (curr == '\\') {
|
||||||
// ignore escaped characters
|
// ignore escaped characters
|
||||||
|
@ -66,8 +66,8 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCharCount(IDocument document, int start, int end,
|
private int getCharCount(IDocument document, int start, int end, char increment, char decrement,
|
||||||
char increment, char decrement, boolean considerNesting) throws BadLocationException {
|
boolean considerNesting) throws BadLocationException {
|
||||||
|
|
||||||
Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
|
Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
|
||||||
|
|
||||||
|
@ -83,32 +83,32 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
switch (curr) {
|
switch (curr) {
|
||||||
case 'd':
|
case 'd':
|
||||||
if (start < end - 2) {
|
if (start < end - 2) {
|
||||||
char next= document.getChar(start);
|
char next = document.getChar(start);
|
||||||
if (next == 'n') {
|
if (next == 'n') {
|
||||||
// a comment starts, advance to the comment end
|
// a comment starts, advance to the comment end
|
||||||
next = document.getChar(start + 1);
|
next = document.getChar(start + 1);
|
||||||
if (next == 'l')
|
if (next == 'l')
|
||||||
// dnl-comment: nothing to do anymore on this line
|
// dnl-comment: nothing to do anymore on this line
|
||||||
start= end;
|
start = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
start= getStringEnd(document, start, end, curr);
|
start = getStringEnd(document, start, end, curr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ('[' == curr)
|
if ('[' == curr)
|
||||||
++ macroQuotingLevel;
|
++macroQuotingLevel;
|
||||||
else if (']' == curr)
|
else if (']' == curr)
|
||||||
-- macroQuotingLevel;
|
--macroQuotingLevel;
|
||||||
if (macroQuotingLevel != 0)
|
if (macroQuotingLevel != 0)
|
||||||
break;
|
break;
|
||||||
if (considerNesting) {
|
if (considerNesting) {
|
||||||
if ('(' == curr)
|
if ('(' == curr)
|
||||||
++ macroNestingLevel;
|
++macroNestingLevel;
|
||||||
else if (')' == curr) {
|
else if (')' == curr) {
|
||||||
-- macroNestingLevel;
|
--macroNestingLevel;
|
||||||
}
|
}
|
||||||
if (macroNestingLevel != 0)
|
if (macroNestingLevel != 0)
|
||||||
break;
|
break;
|
||||||
|
@ -121,7 +121,7 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
|
|
||||||
if (decrement != 0) {
|
if (decrement != 0) {
|
||||||
if (curr == decrement) {
|
if (curr == decrement) {
|
||||||
-- charCount;
|
--charCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,8 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
if (position < fPosition)
|
if (position < fPosition)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IDocument document= fViewer.getDocument();
|
IDocument document = fViewer.getDocument();
|
||||||
IRegion line= document.getLineInformationOfOffset(fPosition);
|
IRegion line = document.getLineInformationOfOffset(fPosition);
|
||||||
|
|
||||||
if (position > line.getOffset() + line.getLength())
|
if (position > line.getOffset() + line.getLength())
|
||||||
return false;
|
return false;
|
||||||
|
@ -153,9 +153,9 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
@Override
|
@Override
|
||||||
public boolean updatePresentation(int position, TextPresentation presentation) {
|
public boolean updatePresentation(int position, TextPresentation presentation) {
|
||||||
|
|
||||||
int currentParameter= -1;
|
int currentParameter = -1;
|
||||||
try {
|
try {
|
||||||
currentParameter= getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
|
currentParameter = getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
|
||||||
} catch (BadLocationException x) {
|
} catch (BadLocationException x) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -166,22 +166,22 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
}
|
}
|
||||||
|
|
||||||
presentation.clear();
|
presentation.clear();
|
||||||
fCurrentParameter= currentParameter;
|
fCurrentParameter = currentParameter;
|
||||||
|
|
||||||
//Don't presume what has been done to the string, rather use as is
|
//Don't presume what has been done to the string, rather use as is
|
||||||
String s= fInformation.getInformationDisplayString();
|
String s = fInformation.getInformationDisplayString();
|
||||||
|
|
||||||
//@@@ This is obviously going to have problems with functions such
|
//@@@ This is obviously going to have problems with functions such
|
||||||
//int myfunction(int (*function_argument)(void * extra, int param), void * extra)
|
//int myfunction(int (*function_argument)(void * extra, int param), void * extra)
|
||||||
//int myfunction(/*A comment, indeed */int a);
|
//int myfunction(/*A comment, indeed */int a);
|
||||||
int start= 0;
|
int start = 0;
|
||||||
int occurrences= 0;
|
int occurrences = 0;
|
||||||
while (occurrences < fCurrentParameter) {
|
while (occurrences < fCurrentParameter) {
|
||||||
int found= s.indexOf(',', start);
|
int found = s.indexOf(',', start);
|
||||||
if (found == -1)
|
if (found == -1)
|
||||||
break;
|
break;
|
||||||
start= found + 1;
|
start = found + 1;
|
||||||
++ occurrences;
|
++occurrences;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (occurrences < fCurrentParameter) {
|
if (occurrences < fCurrentParameter) {
|
||||||
|
@ -190,11 +190,11 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start == -1)
|
if (start == -1)
|
||||||
start= 0;
|
start = 0;
|
||||||
|
|
||||||
int end= s.indexOf(',', start);
|
int end = s.indexOf(',', start);
|
||||||
if (end == -1)
|
if (end == -1)
|
||||||
end= s.length();
|
end = s.length();
|
||||||
|
|
||||||
if (start > 0)
|
if (start > 0)
|
||||||
presentation.addStyleRange(new StyleRange(0, start, null, null, SWT.NORMAL));
|
presentation.addStyleRange(new StyleRange(0, start, null, null, SWT.NORMAL));
|
||||||
|
@ -208,4 +208,3 @@ public class AutoconfMacroParameterListValidator implements IContextInformationV
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.jface.text.rules.IWhitespaceDetector;
|
||||||
import org.eclipse.jface.text.rules.IWordDetector;
|
import org.eclipse.jface.text.rules.IWordDetector;
|
||||||
import org.eclipse.jface.text.rules.Token;
|
import org.eclipse.jface.text.rules.Token;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfMacroPartitionRule implements IPredicateRule {
|
public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
/**
|
/**
|
||||||
* The default token to be returned on success and if nothing else has been
|
* The default token to be returned on success and if nothing else has been
|
||||||
|
@ -61,8 +60,7 @@ public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
while (!finished && c != ICharacterScanner.EOF) {
|
while (!finished && c != ICharacterScanner.EOF) {
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
++quoteDepth;
|
++quoteDepth;
|
||||||
}
|
} else if (c == ']') {
|
||||||
else if (c == ']') {
|
|
||||||
--quoteDepth;
|
--quoteDepth;
|
||||||
if (quoteDepth < 0)
|
if (quoteDepth < 0)
|
||||||
finished = true;
|
finished = true;
|
||||||
|
@ -72,8 +70,7 @@ public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
--depth;
|
--depth;
|
||||||
if (depth <= 0)
|
if (depth <= 0)
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
} else if (c == '(') {
|
||||||
else if (c == '(') {
|
|
||||||
++depth;
|
++depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +80,8 @@ public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
|
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
|
||||||
// if (resume)
|
// if (resume)
|
||||||
// return Token.UNDEFINED;
|
// return Token.UNDEFINED;
|
||||||
return evaluate(scanner);
|
return evaluate(scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +90,10 @@ public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
int c = scanner.read();
|
int c = scanner.read();
|
||||||
fBuffer.setLength(0);
|
fBuffer.setLength(0);
|
||||||
|
|
||||||
fBuffer.append((char)c);
|
fBuffer.append((char) c);
|
||||||
if (c == 'A') {
|
if (c == 'A') {
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
fBuffer.append((char)c);
|
fBuffer.append((char) c);
|
||||||
if (c != 'C' && c != 'H' && c != 'M') {
|
if (c != 'C' && c != 'H' && c != 'M') {
|
||||||
unreadBuffer(scanner);
|
unreadBuffer(scanner);
|
||||||
return Token.UNDEFINED;
|
return Token.UNDEFINED;
|
||||||
|
@ -104,7 +101,7 @@ public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
fDetector = generalMacroWordDetector;
|
fDetector = generalMacroWordDetector;
|
||||||
} else if (c == 'm') {
|
} else if (c == 'm') {
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
fBuffer.append((char)c);
|
fBuffer.append((char) c);
|
||||||
if (c != 4) {
|
if (c != 4) {
|
||||||
unreadBuffer(scanner);
|
unreadBuffer(scanner);
|
||||||
return Token.UNDEFINED;
|
return Token.UNDEFINED;
|
||||||
|
@ -116,20 +113,17 @@ public class AutoconfMacroPartitionRule implements IPredicateRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
while (c != ICharacterScanner.EOF
|
while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)) {
|
||||||
&& fDetector.isWordPart((char) c)) {
|
|
||||||
fBuffer.append((char) c);
|
fBuffer.append((char) c);
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != ICharacterScanner.EOF) {
|
if (c != ICharacterScanner.EOF) {
|
||||||
if (c == ';' || fWsDetector.isWhitespace((char)c)) {
|
if (c == ';' || fWsDetector.isWhitespace((char) c)) {
|
||||||
// We are done
|
// We are done
|
||||||
}
|
} else if (c == '(') {
|
||||||
else if (c == '(') {
|
|
||||||
matchParentheses(scanner);
|
matchParentheses(scanner);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
scanner.unread();
|
scanner.unread();
|
||||||
unreadBuffer(scanner);
|
unreadBuffer(scanner);
|
||||||
return Token.UNDEFINED;
|
return Token.UNDEFINED;
|
||||||
|
|
|
@ -51,20 +51,22 @@ public class AutoconfMacroProposalContextInformation implements IContextInformat
|
||||||
* @param informationDisplayString the string to be displayed when presenting the context information,
|
* @param informationDisplayString the string to be displayed when presenting the context information,
|
||||||
* may not be <code>null</code>
|
* may not be <code>null</code>
|
||||||
*/
|
*/
|
||||||
public AutoconfMacroProposalContextInformation(Image image, String contextDisplayString, String informationDisplayString) {
|
public AutoconfMacroProposalContextInformation(Image image, String contextDisplayString,
|
||||||
|
String informationDisplayString) {
|
||||||
//Assert.isNotNull(informationDisplayString);
|
//Assert.isNotNull(informationDisplayString);
|
||||||
fImage= image;
|
fImage = image;
|
||||||
fContextDisplayString= contextDisplayString;
|
fContextDisplayString = contextDisplayString;
|
||||||
fInformationDisplayString= informationDisplayString;
|
fInformationDisplayString = informationDisplayString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object instanceof IContextInformation) {
|
if (object instanceof IContextInformation) {
|
||||||
IContextInformation contextInformation= (IContextInformation) object;
|
IContextInformation contextInformation = (IContextInformation) object;
|
||||||
boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString());
|
boolean equals = fInformationDisplayString
|
||||||
|
.equalsIgnoreCase(contextInformation.getInformationDisplayString());
|
||||||
if (fContextDisplayString != null)
|
if (fContextDisplayString != null)
|
||||||
equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
|
equals = equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
|
||||||
return equals;
|
return equals;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -98,7 +100,7 @@ public class AutoconfMacroProposalContextInformation implements IContextInformat
|
||||||
return fInformationPosition;
|
return fInformationPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContextInformationPosition( int pos ){
|
public void setContextInformationPosition(int pos) {
|
||||||
fInformationPosition = pos;
|
fInformationPosition = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,7 @@ public class AutoconfMacroRule implements IRule {
|
||||||
|
|
||||||
private String fStartingSequence;
|
private String fStartingSequence;
|
||||||
|
|
||||||
public AutoconfMacroRule(String startingSequence,
|
public AutoconfMacroRule(String startingSequence, IWordDetector detector, IToken inToken) {
|
||||||
IWordDetector detector, IToken inToken) {
|
|
||||||
token = inToken;
|
token = inToken;
|
||||||
fDetector = detector;
|
fDetector = detector;
|
||||||
fStartingSequence = startingSequence;
|
fStartingSequence = startingSequence;
|
||||||
|
@ -62,14 +61,12 @@ public class AutoconfMacroRule implements IRule {
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c != ICharacterScanner.EOF
|
while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)) {
|
||||||
&& fDetector.isWordPart((char) c)) {
|
|
||||||
fBuffer.append((char) c);
|
fBuffer.append((char) c);
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != ICharacterScanner.EOF && c != '(' && c != ';'
|
if (c != ICharacterScanner.EOF && c != '(' && c != ';' && !fWsDetector.isWhitespace((char) c)) {
|
||||||
&& !fWsDetector.isWhitespace((char)c)) {
|
|
||||||
unreadBuffer(scanner);
|
unreadBuffer(scanner);
|
||||||
return Token.UNDEFINED;
|
return Token.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ public class AutoconfMacroWordDetector implements IWordDetector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWordPart(char c) {
|
public boolean isWordPart(char c) {
|
||||||
return ((Character.isLetter(c) && Character.isUpperCase(c)) ||
|
return ((Character.isLetter(c) && Character.isUpperCase(c)) || Character.isDigit(c) || c == '_');
|
||||||
Character.isDigit(c) || c == '_');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,8 +19,7 @@ public class AutoconfPKGWordDetector implements IWordDetector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWordPart(char c) {
|
public boolean isWordPart(char c) {
|
||||||
return ((Character.isLetter(c) && Character.isUpperCase(c)) ||
|
return ((Character.isLetter(c) && Character.isUpperCase(c)) || Character.isDigit(c) || c == '_');
|
||||||
Character.isDigit(c) || c == '_');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,8 +27,7 @@ public class AutoconfPartitionScanner extends RuleBasedPartitionScanner {
|
||||||
|
|
||||||
public final static String AUTOCONF_MACRO = "autoconf_macro"; //$NON-NLS-1$
|
public final static String AUTOCONF_MACRO = "autoconf_macro"; //$NON-NLS-1$
|
||||||
public final static String AUTOCONF_COMMENT = "autoconf_comment"; //$NON-NLS-1$
|
public final static String AUTOCONF_COMMENT = "autoconf_comment"; //$NON-NLS-1$
|
||||||
final static String[] AUTOCONF_PARTITION_TYPES=
|
final static String[] AUTOCONF_PARTITION_TYPES = new String[] { AUTOCONF_MACRO, AUTOCONF_COMMENT };
|
||||||
new String[] { AUTOCONF_MACRO, AUTOCONF_COMMENT };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the partitioner and sets up the appropriate rules.
|
* Creates the partitioner and sets up the appropriate rules.
|
||||||
|
@ -36,14 +35,13 @@ public class AutoconfPartitionScanner extends RuleBasedPartitionScanner {
|
||||||
public AutoconfPartitionScanner() {
|
public AutoconfPartitionScanner() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
List<IRule> rules= new ArrayList<>();
|
List<IRule> rules = new ArrayList<>();
|
||||||
Token macro = new Token(AUTOCONF_MACRO);
|
Token macro = new Token(AUTOCONF_MACRO);
|
||||||
Token comment = new Token(AUTOCONF_COMMENT);
|
Token comment = new Token(AUTOCONF_COMMENT);
|
||||||
|
|
||||||
// Add rule for target bodies.
|
// Add rule for target bodies.
|
||||||
rules.add(new AutoconfMacroPartitionRule(macro));
|
rules.add(new AutoconfMacroPartitionRule(macro));
|
||||||
|
|
||||||
|
|
||||||
rules.add(new EndOfLineRule("dnl", comment)); //$NON-NLS-1$
|
rules.add(new EndOfLineRule("dnl", comment)); //$NON-NLS-1$
|
||||||
rules.add(new SingleLineRule("\\#", null, Token.UNDEFINED));
|
rules.add(new SingleLineRule("\\#", null, Token.UNDEFINED));
|
||||||
rules.add(new EndOfLineRule("#", comment, '\\')); //$NON-NLS-1$
|
rules.add(new EndOfLineRule("#", comment, '\\')); //$NON-NLS-1$
|
||||||
|
@ -52,7 +50,7 @@ public class AutoconfPartitionScanner extends RuleBasedPartitionScanner {
|
||||||
// names inside them.
|
// names inside them.
|
||||||
rules.add(new AutoconfIdentifierRule(Token.UNDEFINED));
|
rules.add(new AutoconfIdentifierRule(Token.UNDEFINED));
|
||||||
|
|
||||||
IPredicateRule[] result= new IPredicateRule[rules.size()];
|
IPredicateRule[] result = new IPredicateRule[rules.size()];
|
||||||
rules.toArray(result);
|
rules.toArray(result);
|
||||||
setPredicateRules(result);
|
setPredicateRules(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,29 +34,23 @@ public class AutoconfPartitioner extends FastPartitioner {
|
||||||
// method. We cannot do it at connect time because the document may be zero length
|
// method. We cannot do it at connect time because the document may be zero length
|
||||||
// at the time and we will end up getting default partitioning from then on.
|
// at the time and we will end up getting default partitioning from then on.
|
||||||
@Override
|
@Override
|
||||||
public ITypedRegion[] computePartitioning(int offset, int length,
|
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLength) {
|
||||||
boolean includeZeroLength) {
|
|
||||||
ITypedRegion[] regions = super.computePartitioning(offset, length, includeZeroLength);
|
ITypedRegion[] regions = super.computePartitioning(offset, length, includeZeroLength);
|
||||||
// Uncomment the following line to see partitioning.
|
// Uncomment the following line to see partitioning.
|
||||||
// printPartitions(regions);
|
// printPartitions(regions);
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printPartitions(ITypedRegion[] partitions)
|
public void printPartitions(ITypedRegion[] partitions) {
|
||||||
{
|
for (int i = 0; i < partitions.length; i++) {
|
||||||
for (int i = 0; i < partitions.length; i++)
|
try {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
System.out.print("Partition type: " + partitions[i].getType() //$NON-NLS-1$
|
System.out.print("Partition type: " + partitions[i].getType() //$NON-NLS-1$
|
||||||
+ ", offset: " + partitions[i].getOffset() //$NON-NLS-1$
|
+ ", offset: " + partitions[i].getOffset() //$NON-NLS-1$
|
||||||
+ ", length: " + partitions[i].getLength() //$NON-NLS-1$
|
+ ", length: " + partitions[i].getLength() //$NON-NLS-1$
|
||||||
+"\nText:\n" //$NON-NLS-1$
|
+ "\nText:\n" //$NON-NLS-1$
|
||||||
+ super.fDocument.get(partitions[i].getOffset(), partitions[i].getLength())
|
+ super.fDocument.get(partitions[i].getOffset(), partitions[i].getLength())
|
||||||
+ "\n---------------------------\n\n\n"); //$NON-NLS-1$
|
+ "\n---------------------------\n\n\n"); //$NON-NLS-1$
|
||||||
}
|
} catch (BadLocationException e) {
|
||||||
catch (BadLocationException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,17 +21,16 @@ import org.eclipse.jface.text.reconciler.DirtyRegion;
|
||||||
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
|
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfReconcilingStrategy implements IReconcilingStrategy {
|
public class AutoconfReconcilingStrategy implements IReconcilingStrategy {
|
||||||
|
|
||||||
AutoconfContentOutlinePage outline;
|
AutoconfContentOutlinePage outline;
|
||||||
// int lastRegionOffset;
|
// int lastRegionOffset;
|
||||||
AutoconfEditor editor;
|
AutoconfEditor editor;
|
||||||
IDocumentProvider documentProvider;
|
IDocumentProvider documentProvider;
|
||||||
|
|
||||||
public AutoconfReconcilingStrategy(AutoconfEditor editor) {
|
public AutoconfReconcilingStrategy(AutoconfEditor editor) {
|
||||||
outline= editor.getOutlinePage();
|
outline = editor.getOutlinePage();
|
||||||
// lastRegionOffset = Integer.MAX_VALUE;
|
// lastRegionOffset = Integer.MAX_VALUE;
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
documentProvider = editor.getDocumentProvider();
|
documentProvider = editor.getDocumentProvider();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +39,7 @@ public class AutoconfReconcilingStrategy implements IReconcilingStrategy {
|
||||||
public void reconcile(IRegion partition) {
|
public void reconcile(IRegion partition) {
|
||||||
try {
|
try {
|
||||||
AutoconfParser parser = editor.getAutoconfParser();
|
AutoconfParser parser = editor.getAutoconfParser();
|
||||||
((AutoconfErrorHandler)parser.getErrorHandler()).removeAllExistingMarkers();
|
((AutoconfErrorHandler) parser.getErrorHandler()).removeAllExistingMarkers();
|
||||||
|
|
||||||
editor.setRootElement(parser.parse(documentProvider.getDocument(editor.getEditorInput())));
|
editor.setRootElement(parser.parse(documentProvider.getDocument(editor.getEditorInput())));
|
||||||
outline.update();
|
outline.update();
|
||||||
|
|
|
@ -29,9 +29,7 @@ import org.eclipse.jface.text.source.IAnnotationHover;
|
||||||
import org.eclipse.jface.text.source.ISourceViewer;
|
import org.eclipse.jface.text.source.ISourceViewer;
|
||||||
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
|
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
|
||||||
|
|
||||||
|
public class AutoconfSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
||||||
public class AutoconfSourceViewerConfiguration extends
|
|
||||||
TextSourceViewerConfiguration {
|
|
||||||
|
|
||||||
private ITextHover acHover;
|
private ITextHover acHover;
|
||||||
private IAnnotationHover aaHover;
|
private IAnnotationHover aaHover;
|
||||||
|
@ -65,9 +63,8 @@ public class AutoconfSourceViewerConfiguration extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
|
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
|
||||||
return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
|
return new String[] { IDocument.DEFAULT_CONTENT_TYPE, AutoconfPartitionScanner.AUTOCONF_MACRO,
|
||||||
AutoconfPartitionScanner.AUTOCONF_MACRO,
|
AutoconfPartitionScanner.AUTOCONF_COMMENT };
|
||||||
AutoconfPartitionScanner.AUTOCONF_COMMENT};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,11 +83,12 @@ public class AutoconfSourceViewerConfiguration extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
||||||
MonoReconciler reconciler= new MonoReconciler(new AutoconfReconcilingStrategy(fEditor), false);
|
MonoReconciler reconciler = new MonoReconciler(new AutoconfReconcilingStrategy(fEditor), false);
|
||||||
reconciler.setDelay(1000);
|
reconciler.setDelay(1000);
|
||||||
reconciler.setProgressMonitor(new NullProgressMonitor());
|
reconciler.setProgressMonitor(new NullProgressMonitor());
|
||||||
return reconciler;
|
return reconciler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
|
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
|
||||||
return new AutoconfPresentationReconciler();
|
return new AutoconfPresentationReconciler();
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.autotools.ui.editors;
|
||||||
import org.eclipse.cdt.internal.autotools.ui.editors.automake.IReconcilingParticipant;
|
import org.eclipse.cdt.internal.autotools.ui.editors.automake.IReconcilingParticipant;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
|
||||||
public interface IAutotoolsEditor extends ITextEditor {
|
public interface IAutotoolsEditor extends ITextEditor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,11 +49,11 @@ public class InlineDataRule implements IRule {
|
||||||
protected boolean confirmDelimeter(ICharacterScanner scanner, char[] delimeter) {
|
protected boolean confirmDelimeter(ICharacterScanner scanner, char[] delimeter) {
|
||||||
int c = scanner.read();
|
int c = scanner.read();
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append((char)c);
|
buffer.append((char) c);
|
||||||
for (int i = 1; i < delimeter.length; ++i) {
|
for (int i = 1; i < delimeter.length; ++i) {
|
||||||
if (c == delimeter[i]) {
|
if (c == delimeter[i]) {
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
buffer.append((char)c);
|
buffer.append((char) c);
|
||||||
} else {
|
} else {
|
||||||
for (int j = buffer.length() - 1; j >= 0; j--)
|
for (int j = buffer.length() - 1; j >= 0; j--)
|
||||||
scanner.unread();
|
scanner.unread();
|
||||||
|
@ -63,6 +63,7 @@ public class InlineDataRule implements IRule {
|
||||||
scanner.unread();
|
scanner.unread();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IToken evaluate(ICharacterScanner scanner) {
|
public IToken evaluate(ICharacterScanner scanner) {
|
||||||
int c = scanner.read();
|
int c = scanner.read();
|
||||||
|
@ -81,23 +82,21 @@ public class InlineDataRule implements IRule {
|
||||||
char[][] lineDelimeters = scanner.getLegalLineDelimiters();
|
char[][] lineDelimeters = scanner.getLegalLineDelimiters();
|
||||||
StringBuilder endMarkerBuffer = new StringBuilder();
|
StringBuilder endMarkerBuffer = new StringBuilder();
|
||||||
if (c == '-') {
|
if (c == '-') {
|
||||||
fBuffer.append((char)c);
|
fBuffer.append((char) c);
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
} else if (c == '\'') {
|
} else if (c == '\'') {
|
||||||
fBuffer.append((char)c);
|
fBuffer.append((char) c);
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c != ICharacterScanner.EOF &&
|
while (c != ICharacterScanner.EOF && Character.isJavaIdentifierPart((char) c) && c != '\'') {
|
||||||
Character.isJavaIdentifierPart((char)c) &&
|
fBuffer.append((char) c);
|
||||||
c != '\'') {
|
endMarkerBuffer.append((char) c);
|
||||||
fBuffer.append((char)c);
|
|
||||||
endMarkerBuffer.append((char)c);
|
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\'') {
|
if (c == '\'') {
|
||||||
fBuffer.append((char)c);
|
fBuffer.append((char) c);
|
||||||
c = scanner.read();
|
c = scanner.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.jface.text.rules.ITokenScanner;
|
||||||
|
|
||||||
public class MultilineRuleDamagerRepairer extends DefaultDamagerRepairer {
|
public class MultilineRuleDamagerRepairer extends DefaultDamagerRepairer {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
|
* Creates a damager/repairer that uses the given scanner. The scanner may not be <code>null</code>
|
||||||
* and is assumed to return only token that carry text attributes.
|
* and is assumed to return only token that carry text attributes.
|
||||||
|
|
|
@ -21,31 +21,40 @@ public class ParseException extends Exception {
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
int startColumn;
|
int startColumn;
|
||||||
int endColumn;
|
int endColumn;
|
||||||
|
|
||||||
public int getEndColumn() {
|
public int getEndColumn() {
|
||||||
return endColumn;
|
return endColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndColumn(int endColumn) {
|
public void setEndColumn(int endColumn) {
|
||||||
this.endColumn = endColumn;
|
this.endColumn = endColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLineNumber() {
|
public int getLineNumber() {
|
||||||
return lineNumber;
|
return lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLineNumber(int lineNumber) {
|
public void setLineNumber(int lineNumber) {
|
||||||
this.lineNumber = lineNumber;
|
this.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStartColumn() {
|
public int getStartColumn() {
|
||||||
return startColumn;
|
return startColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartColumn(int startColumn) {
|
public void setStartColumn(int startColumn) {
|
||||||
this.startColumn = startColumn;
|
this.startColumn = startColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParseException(String message, int lineNumber, int startColumn, int endColumn, int severity) {
|
public ParseException(String message, int lineNumber, int startColumn, int endColumn, int severity) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -54,9 +63,11 @@ public class ParseException extends Exception {
|
||||||
this.endColumn = endColumn;
|
this.endColumn = endColumn;
|
||||||
this.severity = severity;
|
this.severity = severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSeverity() {
|
public int getSeverity() {
|
||||||
return severity;
|
return severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeverity(int severity) {
|
public void setSeverity(int severity) {
|
||||||
this.severity = severity;
|
this.severity = severity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class RecursiveSingleLineRule extends SingleLineRule {
|
||||||
private int endBoundary;
|
private int endBoundary;
|
||||||
private String startSequence;
|
private String startSequence;
|
||||||
private String endSequence;
|
private String endSequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a rule for the given starting and ending sequence
|
* Creates a rule for the given starting and ending sequence
|
||||||
* which, if detected, will return the specified token.
|
* which, if detected, will return the specified token.
|
||||||
|
@ -72,7 +73,8 @@ public class RecursiveSingleLineRule extends SingleLineRule {
|
||||||
* @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
* @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public RecursiveSingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF) {
|
public RecursiveSingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter,
|
||||||
|
boolean breaksOnEOF) {
|
||||||
super(startSequence, endSequence, token, escapeCharacter, breaksOnEOF);
|
super(startSequence, endSequence, token, escapeCharacter, breaksOnEOF);
|
||||||
this.startSequence = startSequence;
|
this.startSequence = startSequence;
|
||||||
this.endSequence = endSequence;
|
this.endSequence = endSequence;
|
||||||
|
@ -99,7 +101,8 @@ public class RecursiveSingleLineRule extends SingleLineRule {
|
||||||
* terminate the line, even if <code>breakOnEOL</code> is true
|
* terminate the line, even if <code>breakOnEOL</code> is true
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public RecursiveSingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOF, boolean escapeContinuesLine) {
|
public RecursiveSingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter,
|
||||||
|
boolean breaksOnEOF, boolean escapeContinuesLine) {
|
||||||
super(startSequence, endSequence, token, escapeCharacter, breaksOnEOF, escapeContinuesLine);
|
super(startSequence, endSequence, token, escapeCharacter, breaksOnEOF, escapeContinuesLine);
|
||||||
this.startSequence = startSequence;
|
this.startSequence = startSequence;
|
||||||
this.endSequence = endSequence;
|
this.endSequence = endSequence;
|
||||||
|
@ -118,7 +121,7 @@ public class RecursiveSingleLineRule extends SingleLineRule {
|
||||||
// The current internal rule index will help us determine which
|
// The current internal rule index will help us determine which
|
||||||
// one.
|
// one.
|
||||||
if (evalIndex < rules.size()) {
|
if (evalIndex < rules.size()) {
|
||||||
SingleLineRule x = (SingleLineRule)rules.get(evalIndex);
|
SingleLineRule x = (SingleLineRule) rules.get(evalIndex);
|
||||||
return x.getSuccessToken();
|
return x.getSuccessToken();
|
||||||
}
|
}
|
||||||
return super.getSuccessToken();
|
return super.getSuccessToken();
|
||||||
|
@ -153,8 +156,7 @@ public class RecursiveSingleLineRule extends SingleLineRule {
|
||||||
// Back up scanner to just after start sequence.
|
// Back up scanner to just after start sequence.
|
||||||
backupScanner(scanner, startIndex + startSequence.length());
|
backupScanner(scanner, startIndex + startSequence.length());
|
||||||
return super.getSuccessToken();
|
return super.getSuccessToken();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
// Outer rule doesn't hold.
|
// Outer rule doesn't hold.
|
||||||
return Token.UNDEFINED;
|
return Token.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +170,7 @@ public class RecursiveSingleLineRule extends SingleLineRule {
|
||||||
column = start;
|
column = start;
|
||||||
while (column < endBoundary) {
|
while (column < endBoundary) {
|
||||||
while (evalIndex < rules.size()) {
|
while (evalIndex < rules.size()) {
|
||||||
SingleLineRule x = (SingleLineRule)rules.get(evalIndex);
|
SingleLineRule x = (SingleLineRule) rules.get(evalIndex);
|
||||||
IToken token = x.evaluate(scanner, false);
|
IToken token = x.evaluate(scanner, false);
|
||||||
if (!token.isUndefined()) {
|
if (!token.isUndefined()) {
|
||||||
// Found internal token. If we had to read to get
|
// Found internal token. If we had to read to get
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class RestrictedEndOfLineRule extends EndOfLineRule {
|
||||||
private int endIndex;
|
private int endIndex;
|
||||||
private String startSequence;
|
private String startSequence;
|
||||||
private String restrictedChars;
|
private String restrictedChars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a rule for the given starting and ending sequence
|
* Creates a rule for the given starting and ending sequence
|
||||||
* which, if detected, will return the specified token.
|
* which, if detected, will return the specified token.
|
||||||
|
@ -71,7 +72,8 @@ public class RestrictedEndOfLineRule extends EndOfLineRule {
|
||||||
* @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
* @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public RestrictedEndOfLineRule(String startSequence, String restrictedChars, IToken token, char escapeCharacter, boolean breaksOnEOF) {
|
public RestrictedEndOfLineRule(String startSequence, String restrictedChars, IToken token, char escapeCharacter,
|
||||||
|
boolean breaksOnEOF) {
|
||||||
super(startSequence, token, escapeCharacter, breaksOnEOF);
|
super(startSequence, token, escapeCharacter, breaksOnEOF);
|
||||||
this.startSequence = startSequence;
|
this.startSequence = startSequence;
|
||||||
this.restrictedChars = restrictedChars;
|
this.restrictedChars = restrictedChars;
|
||||||
|
@ -80,12 +82,10 @@ public class RestrictedEndOfLineRule extends EndOfLineRule {
|
||||||
endIndex = 0;
|
endIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addRule(SingleLineRule rule) {
|
public void addRule(SingleLineRule rule) {
|
||||||
rules.add(rule);
|
rules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void backupScanner(ICharacterScanner scanner, int position) {
|
protected void backupScanner(ICharacterScanner scanner, int position) {
|
||||||
int count = scanner.getColumn() - position;
|
int count = scanner.getColumn() - position;
|
||||||
while (count-- > 0)
|
while (count-- > 0)
|
||||||
|
@ -108,8 +108,7 @@ public class RestrictedEndOfLineRule extends EndOfLineRule {
|
||||||
endIndex = scanner.getColumn();
|
endIndex = scanner.getColumn();
|
||||||
// Back up scanner to just after start sequence.
|
// Back up scanner to just after start sequence.
|
||||||
backupScanner(scanner, startIndex + startSequence.length());
|
backupScanner(scanner, startIndex + startSequence.length());
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
// Base rule doesn't hold.
|
// Base rule doesn't hold.
|
||||||
return Token.UNDEFINED;
|
return Token.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
@ -121,8 +120,7 @@ public class RestrictedEndOfLineRule extends EndOfLineRule {
|
||||||
column = start;
|
column = start;
|
||||||
while (column < endIndex) {
|
while (column < endIndex) {
|
||||||
int ch = scanner.read();
|
int ch = scanner.read();
|
||||||
if (ch == ICharacterScanner.EOF
|
if (ch == ICharacterScanner.EOF || restrictedChars.indexOf(ch) >= 0) {
|
||||||
|| restrictedChars.indexOf(ch) >= 0) {
|
|
||||||
scanner.unread();
|
scanner.unread();
|
||||||
return getSuccessToken();
|
return getSuccessToken();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.ui.part.IPageSite;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
|
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
||||||
|
|
||||||
private ITextEditor editor;
|
private ITextEditor editor;
|
||||||
|
@ -50,14 +49,14 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ISelection updateSelection(ISelection sel) {
|
protected ISelection updateSelection(ISelection sel) {
|
||||||
ArrayList<AutoconfElement> newSelection= new ArrayList<>();
|
ArrayList<AutoconfElement> newSelection = new ArrayList<>();
|
||||||
if (sel instanceof IStructuredSelection) {
|
if (sel instanceof IStructuredSelection) {
|
||||||
Iterator<?> iter = ((IStructuredSelection) sel).iterator();
|
Iterator<?> iter = ((IStructuredSelection) sel).iterator();
|
||||||
for (;iter.hasNext();) {
|
for (; iter.hasNext();) {
|
||||||
//ICElement elem= fInput.findEqualMember((ICElement)iter.next());
|
//ICElement elem= fInput.findEqualMember((ICElement)iter.next());
|
||||||
Object o = iter.next();
|
Object o = iter.next();
|
||||||
if (o instanceof AutoconfElement) {
|
if (o instanceof AutoconfElement) {
|
||||||
newSelection.add((AutoconfElement)o);
|
newSelection.add((AutoconfElement) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,11 +68,9 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
||||||
//update the tree viewer state
|
//update the tree viewer state
|
||||||
final TreeViewer viewer = getTreeViewer();
|
final TreeViewer viewer = getTreeViewer();
|
||||||
|
|
||||||
if (viewer != null)
|
if (viewer != null) {
|
||||||
{
|
|
||||||
final Control control = viewer.getControl();
|
final Control control = viewer.getControl();
|
||||||
if (control != null && !control.isDisposed())
|
if (control != null && !control.isDisposed()) {
|
||||||
{
|
|
||||||
control.getDisplay().asyncExec(() -> {
|
control.getDisplay().asyncExec(() -> {
|
||||||
if (!control.isDisposed()) {
|
if (!control.isDisposed()) {
|
||||||
ISelection sel = viewer.getSelection();
|
ISelection sel = viewer.getSelection();
|
||||||
|
@ -90,7 +87,7 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
||||||
|
|
||||||
super.createControl(parent);
|
super.createControl(parent);
|
||||||
|
|
||||||
TreeViewer viewer= getTreeViewer();
|
TreeViewer viewer = getTreeViewer();
|
||||||
viewer.setContentProvider(new AutoconfContentProvider(editor));
|
viewer.setContentProvider(new AutoconfContentProvider(editor));
|
||||||
viewer.setLabelProvider(new AutoconfLabelProvider());
|
viewer.setLabelProvider(new AutoconfLabelProvider());
|
||||||
viewer.addSelectionChangedListener(this);
|
viewer.addSelectionChangedListener(this);
|
||||||
|
@ -105,8 +102,7 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
||||||
* Change in selection
|
* Change in selection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectionChanged(SelectionChangedEvent event)
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
{
|
|
||||||
super.selectionChanged(event);
|
super.selectionChanged(event);
|
||||||
|
|
||||||
//find out which item in tree viewer we have selected, and set highlight range accordingly
|
//find out which item in tree viewer we have selected, and set highlight range accordingly
|
||||||
|
@ -114,8 +110,7 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
||||||
if (selection.isEmpty()) {
|
if (selection.isEmpty()) {
|
||||||
editor.resetHighlightRange();
|
editor.resetHighlightRange();
|
||||||
} else {
|
} else {
|
||||||
AutoconfElement element = (AutoconfElement) ((IStructuredSelection) selection)
|
AutoconfElement element = (AutoconfElement) ((IStructuredSelection) selection).getFirstElement();
|
||||||
.getFirstElement();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int offset = element.getStartOffset();
|
int offset = element.getStartOffset();
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfContentProvider implements ITreeContentProvider {
|
public class AutoconfContentProvider implements ITreeContentProvider {
|
||||||
|
|
||||||
private IDocumentProvider documentProvider;
|
private IDocumentProvider documentProvider;
|
||||||
|
@ -47,27 +46,20 @@ public class AutoconfContentProvider implements ITreeContentProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
if (oldInput != null)
|
if (oldInput != null) {
|
||||||
{
|
|
||||||
IDocument document = documentProvider.getDocument(oldInput);
|
IDocument document = documentProvider.getDocument(oldInput);
|
||||||
if (document != null)
|
if (document != null) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
document.removePositionCategory(SECTION_POSITIONS);
|
document.removePositionCategory(SECTION_POSITIONS);
|
||||||
}
|
} catch (BadPositionCategoryException x) {
|
||||||
catch (BadPositionCategoryException x)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
document.removePositionUpdater(positionUpdater);
|
document.removePositionUpdater(positionUpdater);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newInput != null)
|
if (newInput != null) {
|
||||||
{
|
|
||||||
IDocument document = documentProvider.getDocument(newInput);
|
IDocument document = documentProvider.getDocument(newInput);
|
||||||
if (document != null)
|
if (document != null) {
|
||||||
{
|
|
||||||
document.addPositionCategory(SECTION_POSITIONS);
|
document.addPositionCategory(SECTION_POSITIONS);
|
||||||
document.addPositionUpdater(positionUpdater);
|
document.addPositionUpdater(positionUpdater);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +69,7 @@ public class AutoconfContentProvider implements ITreeContentProvider {
|
||||||
@Override
|
@Override
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
if (parentElement instanceof AutoconfElement) {
|
if (parentElement instanceof AutoconfElement) {
|
||||||
AutoconfElement element = (AutoconfElement)parentElement;
|
AutoconfElement element = (AutoconfElement) parentElement;
|
||||||
return element.getChildren();
|
return element.getChildren();
|
||||||
}
|
}
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
|
@ -91,7 +83,7 @@ public class AutoconfContentProvider implements ITreeContentProvider {
|
||||||
@Override
|
@Override
|
||||||
public boolean hasChildren(Object element) {
|
public boolean hasChildren(Object element) {
|
||||||
if (element instanceof AutoconfElement) {
|
if (element instanceof AutoconfElement) {
|
||||||
return ((AutoconfElement)element).hasChildren();
|
return ((AutoconfElement) element).hasChildren();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfLabelProvider implements ILabelProvider {
|
public class AutoconfLabelProvider implements ILabelProvider {
|
||||||
|
|
||||||
public AutoconfLabelProvider() {
|
public AutoconfLabelProvider() {
|
||||||
|
@ -85,7 +84,7 @@ public class AutoconfLabelProvider implements ILabelProvider {
|
||||||
@Override
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
if (element instanceof AutoconfElement) {
|
if (element instanceof AutoconfElement) {
|
||||||
AutoconfElement e = (AutoconfElement)element;
|
AutoconfElement e = (AutoconfElement) element;
|
||||||
String result;
|
String result;
|
||||||
String name = e.getName();
|
String name = e.getName();
|
||||||
if (name.length() > 31)
|
if (name.length() > 31)
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class AutoconfElement {
|
||||||
this.children = new ArrayList<>();
|
this.children = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String source = getSource();
|
String source = getSource();
|
||||||
|
@ -95,7 +94,6 @@ public class AutoconfElement {
|
||||||
this.name = string;
|
this.name = string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getVar() {
|
public String getVar() {
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class AutoconfMacroArgumentElement extends AutoconfElement {
|
||||||
public AutoconfMacroArgumentElement() {
|
public AutoconfMacroArgumentElement() {
|
||||||
super(""); // //$NON-NLS-N$
|
super(""); // //$NON-NLS-N$
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoconfMacroArgumentElement(String name) {
|
public AutoconfMacroArgumentElement(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* Ed Swartz (NOKIA Inc) - support standalone parser
|
* Ed Swartz (NOKIA Inc) - support standalone parser
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.autotools.ui.editors.parser;
|
package org.eclipse.cdt.autotools.ui.editors.parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A call to a macro.
|
* A call to a macro.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -32,6 +33,7 @@ public class AutoconfMacroElement extends AutoconfElement {
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParameterCount() {
|
public int getParameterCount() {
|
||||||
return children.size();
|
return children.size();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +49,7 @@ public class AutoconfMacroElement extends AutoconfElement {
|
||||||
* @param verions Autoconf to be used to validate this macro.
|
* @param verions Autoconf to be used to validate this macro.
|
||||||
* @throws InvalidMacroException
|
* @throws InvalidMacroException
|
||||||
*/
|
*/
|
||||||
public void validate (String version) throws InvalidMacroException {}
|
public void validate(String version) throws InvalidMacroException {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,17 +30,14 @@ import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.ui.IStorageEditorInput;
|
import org.eclipse.ui.IStorageEditorInput;
|
||||||
import org.eclipse.ui.texteditor.MarkerUtilities;
|
import org.eclipse.ui.texteditor.MarkerUtilities;
|
||||||
|
|
||||||
|
|
||||||
public class AutoconfOutlineErrorHandler {
|
public class AutoconfOutlineErrorHandler {
|
||||||
|
|
||||||
public static final String PARSE_ERROR_MARKER_ID = AutotoolsUIPlugin.PLUGIN_ID
|
public static final String PARSE_ERROR_MARKER_ID = AutotoolsUIPlugin.PLUGIN_ID + ".outlineparsefileerror"; //$NON-NLS-1$
|
||||||
+ ".outlineparsefileerror"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private IFile file;
|
private IFile file;
|
||||||
private IDocument document;
|
private IDocument document;
|
||||||
|
|
||||||
public AutoconfOutlineErrorHandler(IStorageEditorInput input, IDocument document)
|
public AutoconfOutlineErrorHandler(IStorageEditorInput input, IDocument document) {
|
||||||
{
|
|
||||||
this.document = document;
|
this.document = document;
|
||||||
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tokenizing autoconf parser, based on original work by Jeff Johnston
|
* Tokenizing autoconf parser, based on original work by Jeff Johnston
|
||||||
* @author eswartz
|
* @author eswartz
|
||||||
|
@ -47,8 +46,8 @@ public class AutoconfParser {
|
||||||
public static final String IMPROPER_CASE_CONDITION = "ImproperCaseCondition"; //$NON-NLS-1$
|
public static final String IMPROPER_CASE_CONDITION = "ImproperCaseCondition"; //$NON-NLS-1$
|
||||||
public static final String UNTERMINATED_CASE_CONDITION = "UnterminatedCaseCondition"; //$NON-NLS-1$
|
public static final String UNTERMINATED_CASE_CONDITION = "UnterminatedCaseCondition"; //$NON-NLS-1$
|
||||||
public static final String UNTERMINATED_INLINE_DOCUMENT = "UnterminatedInlineDocument"; //$NON-NLS-1$
|
public static final String UNTERMINATED_INLINE_DOCUMENT = "UnterminatedInlineDocument"; //$NON-NLS-1$
|
||||||
public static final String INCOMPLETE_INLINE_MARKER="IncompleteInlineMarker"; //$NON-NLS-1$
|
public static final String INCOMPLETE_INLINE_MARKER = "IncompleteInlineMarker"; //$NON-NLS-1$
|
||||||
public static final String MISSING_INLINE_MARKER="MissingInlineMarker"; //$NON-NLS-1$
|
public static final String MISSING_INLINE_MARKER = "MissingInlineMarker"; //$NON-NLS-1$
|
||||||
public static final String UNMATCHED_RIGHT_PARENTHESIS = "UnmatchedRightParenthesis"; //$NON-NLS-1$
|
public static final String UNMATCHED_RIGHT_PARENTHESIS = "UnmatchedRightParenthesis"; //$NON-NLS-1$
|
||||||
public static final String UNMATCHED_LEFT_PARENTHESIS = "UnmatchedLeftParenthesis"; //$NON-NLS-1$
|
public static final String UNMATCHED_LEFT_PARENTHESIS = "UnmatchedLeftParenthesis"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -57,13 +56,11 @@ public class AutoconfParser {
|
||||||
private AutoconfTokenizer tokenizer;
|
private AutoconfTokenizer tokenizer;
|
||||||
private IAutoconfMacroDetector macroDetector;
|
private IAutoconfMacroDetector macroDetector;
|
||||||
|
|
||||||
private static final String M4_BUILTINS =
|
private static final String M4_BUILTINS = "define undefine defn pushdef popdef indir builtin ifdef ifelse shift reverse cond " //$NON-NLS-1$
|
||||||
"define undefine defn pushdef popdef indir builtin ifdef ifelse shift reverse cond " + //$NON-NLS-1$
|
+ "dumpdef traceon traceoff debugmode debugfile dnl changequote changecom changeword " + "m4wrap "
|
||||||
"dumpdef traceon traceoff debugmode debugfile dnl changequote changecom changeword " + //$NON-NLS-1$
|
+ "include sinclude divert undivert divnum len index regexp substr translit patsubst "
|
||||||
"m4wrap " + //$NON-NLS-1$
|
+ "format incr decr eval syscmd esyscmd sysval mkstemp maketemp errprint m4exit "
|
||||||
"include sinclude divert undivert divnum len index regexp substr translit patsubst " + //$NON-NLS-1$
|
+ "__file__ __line__ __program__ ";
|
||||||
"format incr decr eval syscmd esyscmd sysval mkstemp maketemp errprint m4exit " + //$NON-NLS-1$
|
|
||||||
"__file__ __line__ __program__ "; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static List<String> m4builtins = new ArrayList<>();
|
private static List<String> m4builtins = new ArrayList<>();
|
||||||
static {
|
static {
|
||||||
|
@ -76,8 +73,7 @@ public class AutoconfParser {
|
||||||
* @param macroDetector
|
* @param macroDetector
|
||||||
* @param macroValidator
|
* @param macroValidator
|
||||||
*/
|
*/
|
||||||
public AutoconfParser(IAutoconfErrorHandler errorHandler,
|
public AutoconfParser(IAutoconfErrorHandler errorHandler, IAutoconfMacroDetector macroDetector,
|
||||||
IAutoconfMacroDetector macroDetector,
|
|
||||||
IAutoconfMacroValidator macroValidator) {
|
IAutoconfMacroValidator macroValidator) {
|
||||||
this.errorHandler = errorHandler;
|
this.errorHandler = errorHandler;
|
||||||
this.macroDetector = macroDetector;
|
this.macroDetector = macroDetector;
|
||||||
|
@ -119,7 +115,6 @@ public class AutoconfParser {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static class BlockEndCondition extends Exception {
|
static class BlockEndCondition extends Exception {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -211,10 +206,8 @@ public class AutoconfParser {
|
||||||
private Token parseBlockExpression(Token open, AutoconfElement block) throws BlockEndCondition {
|
private Token parseBlockExpression(Token open, AutoconfElement block) throws BlockEndCondition {
|
||||||
Token token;
|
Token token;
|
||||||
try {
|
try {
|
||||||
if (block instanceof AutoconfIfElement
|
if (block instanceof AutoconfIfElement || block instanceof AutoconfElifElement
|
||||||
|| block instanceof AutoconfElifElement
|
|| block instanceof AutoconfCaseElement || block instanceof AutoconfWhileElement) {
|
||||||
|| block instanceof AutoconfCaseElement
|
|
||||||
|| block instanceof AutoconfWhileElement) {
|
|
||||||
token = parseExpression(block);
|
token = parseExpression(block);
|
||||||
} else if (block instanceof AutoconfForElement) {
|
} else if (block instanceof AutoconfForElement) {
|
||||||
token = parseForExpression(block);
|
token = parseForExpression(block);
|
||||||
|
@ -239,16 +232,12 @@ public class AutoconfParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.getType() == ITokenConstants.SH_DO) {
|
if (token.getType() == ITokenConstants.SH_DO) {
|
||||||
checkBlockValidity(block, token,
|
checkBlockValidity(block, token, new Class[] { AutoconfForElement.class, AutoconfWhileElement.class },
|
||||||
new Class[] { AutoconfForElement.class, AutoconfWhileElement.class },
|
|
||||||
INVALID_DO);
|
INVALID_DO);
|
||||||
}
|
} else if (token.getType() == ITokenConstants.SH_THEN) {
|
||||||
else if (token.getType() == ITokenConstants.SH_THEN) {
|
checkBlockValidity(block, token, new Class[] { AutoconfIfElement.class, AutoconfElifElement.class },
|
||||||
checkBlockValidity(block, token,
|
|
||||||
new Class[] { AutoconfIfElement.class, AutoconfElifElement.class },
|
|
||||||
INVALID_THEN);
|
INVALID_THEN);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String exp;
|
String exp;
|
||||||
if (block instanceof AutoconfIfElement || block instanceof AutoconfElifElement)
|
if (block instanceof AutoconfIfElement || block instanceof AutoconfElifElement)
|
||||||
exp = "then";
|
exp = "then";
|
||||||
|
@ -372,6 +361,7 @@ public class AutoconfParser {
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSourceStart(AutoconfElement block, Token open) {
|
private void setSourceStart(AutoconfElement block, Token open) {
|
||||||
int offset = open.getOffset();
|
int offset = open.getOffset();
|
||||||
block.setDocument(open.getDocument());
|
block.setDocument(open.getDocument());
|
||||||
|
@ -413,18 +403,17 @@ public class AutoconfParser {
|
||||||
case ITokenConstants.EOF:
|
case ITokenConstants.EOF:
|
||||||
AutoconfElement element = parent;
|
AutoconfElement element = parent;
|
||||||
while (element != null && !(element instanceof AutoconfRootElement)) {
|
while (element != null && !(element instanceof AutoconfRootElement)) {
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, element.getName()));
|
handleError(token,
|
||||||
|
AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, element.getName()));
|
||||||
element = element.getParent();
|
element = element.getParent();
|
||||||
}
|
}
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
|
|
||||||
|
|
||||||
// 1. Check for end of statement
|
// 1. Check for end of statement
|
||||||
case ITokenConstants.EOL:
|
case ITokenConstants.EOL:
|
||||||
case ITokenConstants.SEMI:
|
case ITokenConstants.SEMI:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
// 2. Check macro expansions
|
// 2. Check macro expansions
|
||||||
case ITokenConstants.WORD:
|
case ITokenConstants.WORD:
|
||||||
checkMacro(parent, token);
|
checkMacro(parent, token);
|
||||||
|
@ -452,9 +441,7 @@ public class AutoconfParser {
|
||||||
|
|
||||||
case ITokenConstants.SH_ELIF:
|
case ITokenConstants.SH_ELIF:
|
||||||
checkLineStart(token, atStart);
|
checkLineStart(token, atStart);
|
||||||
checkBlockValidity(
|
checkBlockValidity(parent, token, new Class[] { AutoconfIfElement.class, AutoconfElifElement.class },
|
||||||
parent, token,
|
|
||||||
new Class[] { AutoconfIfElement.class, AutoconfElifElement.class },
|
|
||||||
INVALID_ELIF);
|
INVALID_ELIF);
|
||||||
parseBlock(parent, token, new AutoconfElifElement());
|
parseBlock(parent, token, new AutoconfElifElement());
|
||||||
token = tokenizer.peekToken();
|
token = tokenizer.peekToken();
|
||||||
|
@ -462,9 +449,7 @@ public class AutoconfParser {
|
||||||
|
|
||||||
case ITokenConstants.SH_ELSE:
|
case ITokenConstants.SH_ELSE:
|
||||||
checkLineStart(token, atStart);
|
checkLineStart(token, atStart);
|
||||||
checkBlockValidity(
|
checkBlockValidity(parent, token, new Class[] { AutoconfIfElement.class, AutoconfElifElement.class },
|
||||||
parent, token,
|
|
||||||
new Class[] { AutoconfIfElement.class, AutoconfElifElement.class },
|
|
||||||
INVALID_ELSE);
|
INVALID_ELSE);
|
||||||
parseBlock(parent, token, new AutoconfElseElement());
|
parseBlock(parent, token, new AutoconfElseElement());
|
||||||
token = tokenizer.peekToken();
|
token = tokenizer.peekToken();
|
||||||
|
@ -472,13 +457,11 @@ public class AutoconfParser {
|
||||||
|
|
||||||
case ITokenConstants.SH_FI:
|
case ITokenConstants.SH_FI:
|
||||||
checkLineStart(token, atStart);
|
checkLineStart(token, atStart);
|
||||||
checkBlockValidity(
|
checkBlockValidity(parent, token,
|
||||||
parent, token,
|
|
||||||
new Class[] { AutoconfIfElement.class, AutoconfElifElement.class, AutoconfElseElement.class },
|
new Class[] { AutoconfIfElement.class, AutoconfElifElement.class, AutoconfElseElement.class },
|
||||||
INVALID_FI);
|
INVALID_FI);
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
|
|
||||||
|
|
||||||
// 4. Look for for/while loops
|
// 4. Look for for/while loops
|
||||||
case ITokenConstants.SH_FOR:
|
case ITokenConstants.SH_FOR:
|
||||||
checkLineStart(token, atStart);
|
checkLineStart(token, atStart);
|
||||||
|
@ -502,11 +485,8 @@ public class AutoconfParser {
|
||||||
|
|
||||||
case ITokenConstants.SH_DONE:
|
case ITokenConstants.SH_DONE:
|
||||||
checkLineStart(token, atStart);
|
checkLineStart(token, atStart);
|
||||||
checkBlockValidity(
|
checkBlockValidity(parent, token, new Class[] { AutoconfForElement.class, AutoconfWhileElement.class,
|
||||||
parent, token,
|
AutoconfUntilElement.class, AutoconfSelectElement.class }, INVALID_DONE);
|
||||||
new Class[] { AutoconfForElement.class, AutoconfWhileElement.class,
|
|
||||||
AutoconfUntilElement.class, AutoconfSelectElement.class },
|
|
||||||
INVALID_DONE);
|
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
|
|
||||||
// 5. Look for case statements
|
// 5. Look for case statements
|
||||||
|
@ -516,22 +496,17 @@ public class AutoconfParser {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITokenConstants.SH_CASE_CONDITION_END:
|
case ITokenConstants.SH_CASE_CONDITION_END:
|
||||||
checkBlockValidity(
|
checkBlockValidity(parent, token, new Class[] { AutoconfCaseConditionElement.class },
|
||||||
parent, token,
|
|
||||||
new Class[] { AutoconfCaseConditionElement.class },
|
|
||||||
IMPROPER_CASE_CONDITION);
|
IMPROPER_CASE_CONDITION);
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
|
|
||||||
case ITokenConstants.SH_ESAC:
|
case ITokenConstants.SH_ESAC:
|
||||||
checkLineStart(token, atStart);
|
checkLineStart(token, atStart);
|
||||||
checkBlockValidity(
|
checkBlockValidity(parent, token,
|
||||||
parent, token,
|
|
||||||
// note: we don't strictly recurse here, so accept either parent
|
// note: we don't strictly recurse here, so accept either parent
|
||||||
new Class[] { AutoconfCaseElement.class, AutoconfCaseConditionElement.class },
|
new Class[] { AutoconfCaseElement.class, AutoconfCaseConditionElement.class }, INVALID_ESAC);
|
||||||
INVALID_ESAC);
|
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
|
|
||||||
|
|
||||||
// 6. Check for HERE documents
|
// 6. Check for HERE documents
|
||||||
case ITokenConstants.SH_HERE:
|
case ITokenConstants.SH_HERE:
|
||||||
case ITokenConstants.SH_HERE_DASH:
|
case ITokenConstants.SH_HERE_DASH:
|
||||||
|
@ -566,7 +541,8 @@ public class AutoconfParser {
|
||||||
while (true) {
|
while (true) {
|
||||||
token = tokenizer.readToken();
|
token = tokenizer.readToken();
|
||||||
if (token.getType() == ITokenConstants.EOF) {
|
if (token.getType() == ITokenConstants.EOF) {
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, parent.getName()));
|
handleError(token,
|
||||||
|
AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, parent.getName()));
|
||||||
break;
|
break;
|
||||||
} else if (token.getType() == ITokenConstants.EOL) {
|
} else if (token.getType() == ITokenConstants.EOL) {
|
||||||
atEOL = true;
|
atEOL = true;
|
||||||
|
@ -574,7 +550,8 @@ public class AutoconfParser {
|
||||||
if (atEOL && token.getText().equals(hereTag)) {
|
if (atEOL && token.getText().equals(hereTag)) {
|
||||||
// only the end if it is also followed by EOL without any whitespace
|
// only the end if it is also followed by EOL without any whitespace
|
||||||
Token eol = tokenizer.readToken();
|
Token eol = tokenizer.readToken();
|
||||||
if (eol.getType() == ITokenConstants.EOL && eol.getOffset() == token.getOffset() + token.getLength()) {
|
if (eol.getType() == ITokenConstants.EOL
|
||||||
|
&& eol.getOffset() == token.getOffset() + token.getLength()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,8 +601,7 @@ public class AutoconfParser {
|
||||||
|
|
||||||
case ITokenConstants.SH_IN:
|
case ITokenConstants.SH_IN:
|
||||||
// in 'for' or 'select, an 'in' may occur before 'do'
|
// in 'for' or 'select, an 'in' may occur before 'do'
|
||||||
if (!(parent instanceof AutoconfForElement)
|
if (!(parent instanceof AutoconfForElement) && !(parent instanceof AutoconfSelectElement))
|
||||||
&& !(parent instanceof AutoconfSelectElement))
|
|
||||||
return token;
|
return token;
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
|
@ -684,7 +660,8 @@ public class AutoconfParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Abort on unexpected tokens
|
// 4. Abort on unexpected tokens
|
||||||
else switch (token.getType()) {
|
else
|
||||||
|
switch (token.getType()) {
|
||||||
case ITokenConstants.SH_THEN:
|
case ITokenConstants.SH_THEN:
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString(INVALID_SPECIFIER, token.getText()));
|
handleError(token, AutoconfEditorMessages.getFormattedString(INVALID_SPECIFIER, token.getText()));
|
||||||
tokenizer.unreadToken(token);
|
tokenizer.unreadToken(token);
|
||||||
|
@ -701,7 +678,8 @@ public class AutoconfParser {
|
||||||
case ITokenConstants.SH_ELSE:
|
case ITokenConstants.SH_ELSE:
|
||||||
case ITokenConstants.SH_FI:
|
case ITokenConstants.SH_FI:
|
||||||
case ITokenConstants.SH_DONE:
|
case ITokenConstants.SH_DONE:
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, parent.getName()));
|
handleError(token,
|
||||||
|
AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, parent.getName()));
|
||||||
tokenizer.unreadToken(token);
|
tokenizer.unreadToken(token);
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
}
|
}
|
||||||
|
@ -735,13 +713,13 @@ public class AutoconfParser {
|
||||||
// 3. Check expression terminators
|
// 3. Check expression terminators
|
||||||
else if (parent instanceof AutoconfCaseElement && token.getType() == ITokenConstants.SH_IN) {
|
else if (parent instanceof AutoconfCaseElement && token.getType() == ITokenConstants.SH_IN) {
|
||||||
return token;
|
return token;
|
||||||
}
|
} else if (parent instanceof AutoconfCaseConditionElement && token.getType() == ITokenConstants.RPAREN) {
|
||||||
else if (parent instanceof AutoconfCaseConditionElement && token.getType() == ITokenConstants.RPAREN) {
|
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Abort on unexpected tokens
|
// 4. Abort on unexpected tokens
|
||||||
else switch (token.getType()) {
|
else
|
||||||
|
switch (token.getType()) {
|
||||||
case ITokenConstants.SEMI:
|
case ITokenConstants.SEMI:
|
||||||
case ITokenConstants.SH_IN:
|
case ITokenConstants.SH_IN:
|
||||||
case ITokenConstants.RPAREN:
|
case ITokenConstants.RPAREN:
|
||||||
|
@ -763,7 +741,8 @@ public class AutoconfParser {
|
||||||
case ITokenConstants.SH_ELSE:
|
case ITokenConstants.SH_ELSE:
|
||||||
case ITokenConstants.SH_FI:
|
case ITokenConstants.SH_FI:
|
||||||
case ITokenConstants.SH_DONE:
|
case ITokenConstants.SH_DONE:
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, parent.getName()));
|
handleError(token,
|
||||||
|
AutoconfEditorMessages.getFormattedString(UNTERMINATED_CONSTRUCT, parent.getName()));
|
||||||
tokenizer.unreadToken(token);
|
tokenizer.unreadToken(token);
|
||||||
throw new BlockEndCondition(token);
|
throw new BlockEndCondition(token);
|
||||||
}
|
}
|
||||||
|
@ -779,11 +758,7 @@ public class AutoconfParser {
|
||||||
* @param token
|
* @param token
|
||||||
* @param classes
|
* @param classes
|
||||||
*/
|
*/
|
||||||
private void checkBlockValidity(
|
private void checkBlockValidity(AutoconfElement parent, Token token, Class<?>[] classes, String errorMessage) {
|
||||||
AutoconfElement parent,
|
|
||||||
Token token,
|
|
||||||
Class<?>[] classes,
|
|
||||||
String errorMessage) {
|
|
||||||
for (int i = 0; i < classes.length; i++) {
|
for (int i = 0; i < classes.length; i++) {
|
||||||
if (classes[i].isInstance(parent)) {
|
if (classes[i].isInstance(parent)) {
|
||||||
return;
|
return;
|
||||||
|
@ -800,8 +775,8 @@ public class AutoconfParser {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private AutoconfMacroElement createMacroElement (String name){
|
private AutoconfMacroElement createMacroElement(String name) {
|
||||||
if (name.equals("AC_INIT")){ //$NON-NLS-1$
|
if (name.equals("AC_INIT")) { //$NON-NLS-1$
|
||||||
return new AcInitElement(name);
|
return new AcInitElement(name);
|
||||||
}
|
}
|
||||||
return new AutoconfMacroElement(name);
|
return new AutoconfMacroElement(name);
|
||||||
|
@ -875,8 +850,7 @@ public class AutoconfParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// now validate that the macro is properly terminated
|
// now validate that the macro is properly terminated
|
||||||
if (!(parent instanceof AutoconfMacroArgumentElement)
|
if (!(parent instanceof AutoconfMacroArgumentElement) && !(parent instanceof AutoconfMacroElement)
|
||||||
&& !(parent instanceof AutoconfMacroElement)
|
|
||||||
&& !(parent instanceof AutoconfForElement)) {
|
&& !(parent instanceof AutoconfForElement)) {
|
||||||
Token peek = tokenizer.peekToken();
|
Token peek = tokenizer.peekToken();
|
||||||
if (peek.getType() == ITokenConstants.RPAREN) {
|
if (peek.getType() == ITokenConstants.RPAREN) {
|
||||||
|
@ -889,11 +863,11 @@ public class AutoconfParser {
|
||||||
|
|
||||||
private void validateMacroParameterCount(AutoconfMacroElement macro, Token token, int count) {
|
private void validateMacroParameterCount(AutoconfMacroElement macro, Token token, int count) {
|
||||||
if (macro.getParameterCount() < count) {
|
if (macro.getParameterCount() < count) {
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString("M4MacroArgsTooFew",
|
handleError(token, AutoconfEditorMessages.getFormattedString("M4MacroArgsTooFew", macro.getName(),
|
||||||
macro.getName(), Integer.valueOf(2))); //$NON-NLS-1$
|
Integer.valueOf(2))); //$NON-NLS-1$
|
||||||
} else if (macro.getParameterCount() > count) {
|
} else if (macro.getParameterCount() > count) {
|
||||||
handleError(token, AutoconfEditorMessages.getFormattedString("M4MacroArgsTooMany",
|
handleError(token, AutoconfEditorMessages.getFormattedString("M4MacroArgsTooMany", macro.getName(),
|
||||||
macro.getName(), Integer.valueOf(2))); //$NON-NLS-1$
|
Integer.valueOf(2))); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,8 +941,7 @@ public class AutoconfParser {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.getType() == ITokenConstants.COMMA
|
if (token.getType() == ITokenConstants.COMMA || token.getType() == ITokenConstants.RPAREN
|
||||||
|| token.getType() == ITokenConstants.RPAREN
|
|
||||||
|| token.getType() == ITokenConstants.EOF) {
|
|| token.getType() == ITokenConstants.EOF) {
|
||||||
|
|
||||||
arg.setName(argBuffer.toString());
|
arg.setName(argBuffer.toString());
|
||||||
|
@ -1049,13 +1022,8 @@ public class AutoconfParser {
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
// Don't care if we blow up trying to issue marker
|
// Don't care if we blow up trying to issue marker
|
||||||
}
|
}
|
||||||
errorHandler.handleError(new ParseException(
|
errorHandler.handleError(new ParseException(message, token.getOffset(),
|
||||||
message,
|
token.getOffset() + token.getLength(), lineNumber, startColumn, endColumn, severity));
|
||||||
token.getOffset(),
|
|
||||||
token.getOffset() + token.getLength(),
|
|
||||||
lineNumber,
|
|
||||||
startColumn, endColumn,
|
|
||||||
severity));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,7 +1031,7 @@ public class AutoconfParser {
|
||||||
* Figure out the error location and create a marker and message for it.
|
* Figure out the error location and create a marker and message for it.
|
||||||
* @param exception
|
* @param exception
|
||||||
*/
|
*/
|
||||||
protected void handleError (InvalidMacroException exception) {
|
protected void handleError(InvalidMacroException exception) {
|
||||||
AutoconfElement element = exception.getBadElement();
|
AutoconfElement element = exception.getBadElement();
|
||||||
|
|
||||||
if (errorHandler != null) {
|
if (errorHandler != null) {
|
||||||
|
@ -1078,13 +1046,8 @@ public class AutoconfParser {
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
// Don't care if we blow up trying to issue marker
|
// Don't care if we blow up trying to issue marker
|
||||||
}
|
}
|
||||||
errorHandler.handleError(new ParseException(
|
errorHandler.handleError(new ParseException(exception.getMessage(), element.getStartOffset(),
|
||||||
exception.getMessage(),
|
element.getEndOffset(), lineNumber, startColumn, endColumn, IMarker.SEVERITY_ERROR));
|
||||||
element.getStartOffset(),
|
|
||||||
element.getEndOffset(),
|
|
||||||
lineNumber,
|
|
||||||
startColumn, endColumn,
|
|
||||||
IMarker.SEVERITY_ERROR));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1092,4 +1055,3 @@ public class AutoconfParser {
|
||||||
return errorHandler;
|
return errorHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tokenizer traverses autotools-style text (m4 or configure.ac) to support the
|
* This tokenizer traverses autotools-style text (m4 or configure.ac) to support the
|
||||||
* autoconf parser. It tracks the current context (m4 macro call or shell commands)
|
* autoconf parser. It tracks the current context (m4 macro call or shell commands)
|
||||||
|
@ -329,9 +328,11 @@ public class AutoconfTokenizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quoteLevel > 0) {
|
if (quoteLevel > 0) {
|
||||||
handleError(startOffset, offset, AutoconfEditorMessages.getFormattedString(UNMATCHED_LEFT_QUOTE, m4CloseQuote));
|
handleError(startOffset, offset,
|
||||||
|
AutoconfEditorMessages.getFormattedString(UNMATCHED_LEFT_QUOTE, m4CloseQuote));
|
||||||
} else if (quoteLevel < 0) {
|
} else if (quoteLevel < 0) {
|
||||||
handleError(startOffset, offset, AutoconfEditorMessages.getFormattedString(UNMATCHED_RIGHT_QUOTE, m4OpenQuote));
|
handleError(startOffset, offset,
|
||||||
|
AutoconfEditorMessages.getFormattedString(UNMATCHED_RIGHT_QUOTE, m4OpenQuote));
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeToken(ITokenConstants.M4_STRING, buffer.toString());
|
return makeToken(ITokenConstants.M4_STRING, buffer.toString());
|
||||||
|
@ -365,8 +366,7 @@ public class AutoconfTokenizer {
|
||||||
return makeToken(type, buffer.toString());
|
return makeToken(type, buffer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleError(int start, int end,
|
private void handleError(int start, int end, String message) {
|
||||||
String message) {
|
|
||||||
if (errorHandler != null) {
|
if (errorHandler != null) {
|
||||||
int lineNumber = 0;
|
int lineNumber = 0;
|
||||||
int startColumn = 0;
|
int startColumn = 0;
|
||||||
|
@ -379,11 +379,7 @@ public class AutoconfTokenizer {
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
// Don't care if we blow up trying to issue marker
|
// Don't care if we blow up trying to issue marker
|
||||||
}
|
}
|
||||||
errorHandler.handleError(new ParseException(
|
errorHandler.handleError(new ParseException(message, start, end, lineNumber, startColumn, endColumn,
|
||||||
message,
|
|
||||||
start, end,
|
|
||||||
lineNumber,
|
|
||||||
startColumn, endColumn,
|
|
||||||
IMarker.SEVERITY_ERROR));
|
IMarker.SEVERITY_ERROR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,9 +409,8 @@ public class AutoconfTokenizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Token makeToken(int type) {
|
private Token makeToken(int type) {
|
||||||
return new Token(type,
|
return new Token(type, new String(chars, startOffset, offset - startOffset), document, startOffset,
|
||||||
new String(chars, startOffset, offset - startOffset),
|
offset - startOffset);
|
||||||
document, startOffset, offset - startOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Token makeToken(int type, String text) {
|
private Token makeToken(int type, String text) {
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.autotools.ui.editors.parser;
|
package org.eclipse.cdt.autotools.ui.editors.parser;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clients implement this interface to handle errors encountered while parsing.
|
* Clients implement this interface to handle errors encountered while parsing.
|
||||||
* @author eswartz
|
* @author eswartz
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.autotools.ui.editors.parser;
|
package org.eclipse.cdt.autotools.ui.editors.parser;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clients implement this interface to identify what identifiers represent
|
* Clients implement this interface to identify what identifiers represent
|
||||||
* macros for the autoconf tree.
|
* macros for the autoconf tree.
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.autotools.ui.editors.parser;
|
package org.eclipse.cdt.autotools.ui.editors.parser;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clients implement this interface to validate macro calls.
|
* Clients implement this interface to validate macro calls.
|
||||||
* @author eswartz
|
* @author eswartz
|
||||||
|
|
|
@ -93,5 +93,4 @@ public interface ITokenConstants {
|
||||||
/** an sh backtick-quoted string */
|
/** an sh backtick-quoted string */
|
||||||
int SH_STRING_BACKTICK = 69;
|
int SH_STRING_BACKTICK = 69;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,34 +23,42 @@ public class ParseException extends Exception {
|
||||||
int endColumn;
|
int endColumn;
|
||||||
private int startOffset;
|
private int startOffset;
|
||||||
private int endOffset;
|
private int endOffset;
|
||||||
|
|
||||||
public int getEndColumn() {
|
public int getEndColumn() {
|
||||||
return endColumn;
|
return endColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndColumn(int endColumn) {
|
public void setEndColumn(int endColumn) {
|
||||||
this.endColumn = endColumn;
|
this.endColumn = endColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLineNumber() {
|
public int getLineNumber() {
|
||||||
return lineNumber;
|
return lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLineNumber(int lineNumber) {
|
public void setLineNumber(int lineNumber) {
|
||||||
this.lineNumber = lineNumber;
|
this.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStartColumn() {
|
public int getStartColumn() {
|
||||||
return startColumn;
|
return startColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartColumn(int startColumn) {
|
public void setStartColumn(int startColumn) {
|
||||||
this.startColumn = startColumn;
|
this.startColumn = startColumn;
|
||||||
}
|
}
|
||||||
public ParseException(String message,
|
|
||||||
int startOffset, int endOffset,
|
public ParseException(String message, int startOffset, int endOffset, int lineNumber, int startColumn,
|
||||||
int lineNumber, int startColumn, int endColumn, int severity) {
|
int endColumn, int severity) {
|
||||||
super();
|
super();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.startOffset = startOffset;
|
this.startOffset = startOffset;
|
||||||
|
@ -60,15 +68,19 @@ public class ParseException extends Exception {
|
||||||
this.endColumn = endColumn;
|
this.endColumn = endColumn;
|
||||||
this.severity = severity;
|
this.severity = severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSeverity() {
|
public int getSeverity() {
|
||||||
return severity;
|
return severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeverity(int severity) {
|
public void setSeverity(int severity) {
|
||||||
this.severity = severity;
|
this.severity = severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStartOffset() {
|
public int getStartOffset() {
|
||||||
return startOffset;
|
return startOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEndOffset() {
|
public int getEndOffset() {
|
||||||
return endOffset;
|
return endOffset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@ package org.eclipse.cdt.internal.autotools.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractCBuildPropertyTab;
|
import org.eclipse.cdt.managedbuilder.ui.properties.AbstractCBuildPropertyTab;
|
||||||
|
|
||||||
public abstract class AbstractAutotoolsCPropertyTab extends
|
public abstract class AbstractAutotoolsCPropertyTab extends AbstractCBuildPropertyTab {
|
||||||
AbstractCBuildPropertyTab {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isIndexerAffected() {
|
public boolean isIndexerAffected() {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.resource.ImageRegistry;
|
import org.eclipse.jface.resource.ImageRegistry;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bundle of all images used by the C plugin.
|
* Bundle of all images used by the C plugin.
|
||||||
*/
|
*/
|
||||||
|
@ -39,41 +38,41 @@ public class AutotoolsUIPluginImages {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
fgIconBaseURL= new URL(AutotoolsUIPlugin.getDefault().getBundle().getEntry("/"), "icons/" ); //$NON-NLS-1$ //$NON-NLS-2$
|
fgIconBaseURL = new URL(AutotoolsUIPlugin.getDefault().getBundle().getEntry("/"), "icons/"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final String NAME_PREFIX= AutotoolsUIPlugin.PLUGIN_ID + '.';
|
private static final String NAME_PREFIX = AutotoolsUIPlugin.PLUGIN_ID + '.';
|
||||||
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
|
private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
|
||||||
|
|
||||||
public static final String T_OBJ= "ac16/"; //$NON-NLS-1$
|
public static final String T_OBJ = "ac16/"; //$NON-NLS-1$
|
||||||
public static final String T_BUILD= "elcl16/"; //$NON-NLS-1$
|
public static final String T_BUILD = "elcl16/"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String IMG_OBJS_IF= NAME_PREFIX + "if_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_IF = NAME_PREFIX + "if_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_ELSE= NAME_PREFIX + "else_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_ELSE = NAME_PREFIX + "else_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_ELIF= NAME_PREFIX + "elif_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_ELIF = NAME_PREFIX + "elif_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_CASE= NAME_PREFIX + "case_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_CASE = NAME_PREFIX + "case_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_CONDITION= NAME_PREFIX + "condition_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_CONDITION = NAME_PREFIX + "condition_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_FOR= NAME_PREFIX + "for_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_FOR = NAME_PREFIX + "for_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_WHILE= NAME_PREFIX + "while_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_WHILE = NAME_PREFIX + "while_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_ACMACRO= NAME_PREFIX + "acmacro_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_ACMACRO = NAME_PREFIX + "acmacro_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_AMMACRO= NAME_PREFIX + "ammacro_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_AMMACRO = NAME_PREFIX + "ammacro_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_OBJS_ACMACRO_ARG = NAME_PREFIX + "acmacro_arg_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_ACMACRO_ARG = NAME_PREFIX + "acmacro_arg_obj.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_BUILD_CONFIG = NAME_PREFIX + "build_configs.gif"; //$NON-NLS-1$
|
public static final String IMG_BUILD_CONFIG = NAME_PREFIX + "build_configs.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_CFG_CATEGORY = NAME_PREFIX + "config_category.gif"; //$NON-NLS-1$
|
public static final String IMG_CFG_CATEGORY = NAME_PREFIX + "config_category.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_CFG_TOOL = NAME_PREFIX + "config_tool.gif"; //$NON-NLS-1$
|
public static final String IMG_CFG_TOOL = NAME_PREFIX + "config_tool.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final ImageDescriptor DESC_OBJS_IF= createManaged(T_OBJ, IMG_OBJS_IF);
|
public static final ImageDescriptor DESC_OBJS_IF = createManaged(T_OBJ, IMG_OBJS_IF);
|
||||||
public static final ImageDescriptor DESC_OBJS_ELSE= createManaged(T_OBJ, IMG_OBJS_ELSE);
|
public static final ImageDescriptor DESC_OBJS_ELSE = createManaged(T_OBJ, IMG_OBJS_ELSE);
|
||||||
public static final ImageDescriptor DESC_OBJS_ELIF= createManaged(T_OBJ, IMG_OBJS_ELIF);
|
public static final ImageDescriptor DESC_OBJS_ELIF = createManaged(T_OBJ, IMG_OBJS_ELIF);
|
||||||
public static final ImageDescriptor DESC_OBJS_CASE= createManaged(T_OBJ, IMG_OBJS_CASE);
|
public static final ImageDescriptor DESC_OBJS_CASE = createManaged(T_OBJ, IMG_OBJS_CASE);
|
||||||
public static final ImageDescriptor DESC_OBJS_CONDITION = createManaged(T_OBJ, IMG_OBJS_CONDITION);
|
public static final ImageDescriptor DESC_OBJS_CONDITION = createManaged(T_OBJ, IMG_OBJS_CONDITION);
|
||||||
public static final ImageDescriptor DESC_OBJS_FOR= createManaged(T_OBJ, IMG_OBJS_FOR);
|
public static final ImageDescriptor DESC_OBJS_FOR = createManaged(T_OBJ, IMG_OBJS_FOR);
|
||||||
public static final ImageDescriptor DESC_OBJS_WHILE= createManaged(T_OBJ, IMG_OBJS_WHILE);
|
public static final ImageDescriptor DESC_OBJS_WHILE = createManaged(T_OBJ, IMG_OBJS_WHILE);
|
||||||
public static final ImageDescriptor DESC_OBJS_ACMACRO= createManaged(T_OBJ, IMG_OBJS_ACMACRO);
|
public static final ImageDescriptor DESC_OBJS_ACMACRO = createManaged(T_OBJ, IMG_OBJS_ACMACRO);
|
||||||
public static final ImageDescriptor DESC_OBJS_AMMACRO= createManaged(T_OBJ, IMG_OBJS_AMMACRO);
|
public static final ImageDescriptor DESC_OBJS_AMMACRO = createManaged(T_OBJ, IMG_OBJS_AMMACRO);
|
||||||
public static final ImageDescriptor DESC_OBJS_ACMACRO_ARG= createManaged(T_OBJ, IMG_OBJS_ACMACRO_ARG);
|
public static final ImageDescriptor DESC_OBJS_ACMACRO_ARG = createManaged(T_OBJ, IMG_OBJS_ACMACRO_ARG);
|
||||||
public static final ImageDescriptor DESC_BUILD_CONFIG = createManaged(T_BUILD, IMG_BUILD_CONFIG);
|
public static final ImageDescriptor DESC_BUILD_CONFIG = createManaged(T_BUILD, IMG_BUILD_CONFIG);
|
||||||
public static final ImageDescriptor DESC_CFG_CATEGORY = createManaged(T_BUILD, IMG_CFG_CATEGORY);
|
public static final ImageDescriptor DESC_CFG_CATEGORY = createManaged(T_BUILD, IMG_CFG_CATEGORY);
|
||||||
public static final ImageDescriptor DESC_CFG_TOOL = createManaged(T_BUILD, IMG_CFG_TOOL);
|
public static final ImageDescriptor DESC_CFG_TOOL = createManaged(T_BUILD, IMG_CFG_TOOL);
|
||||||
|
@ -83,7 +82,8 @@ public class AutotoolsUIPluginImages {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
|
private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
|
||||||
ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
|
ImageDescriptor result = ImageDescriptor
|
||||||
|
.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
|
||||||
registry.put(name, result);
|
registry.put(name, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class AutotoolsUIPluginImages {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static URL makeIconFileURL(String prefix, String name) {
|
private static URL makeIconFileURL(String prefix, String name) {
|
||||||
StringBuilder buffer= new StringBuilder(prefix);
|
StringBuilder buffer = new StringBuilder(prefix);
|
||||||
buffer.append(name);
|
buffer.append(name);
|
||||||
try {
|
try {
|
||||||
return new URL(fgIconBaseURL, buffer.toString());
|
return new URL(fgIconBaseURL, buffer.toString());
|
||||||
|
@ -112,9 +112,9 @@ public class AutotoolsUIPluginImages {
|
||||||
*/
|
*/
|
||||||
public static void setImageDescriptors(IAction action, String type, String relPath) {
|
public static void setImageDescriptors(IAction action, String type, String relPath) {
|
||||||
if (relPath.startsWith(NAME_PREFIX))
|
if (relPath.startsWith(NAME_PREFIX))
|
||||||
relPath= relPath.substring(NAME_PREFIX_LENGTH);
|
relPath = relPath.substring(NAME_PREFIX_LENGTH);
|
||||||
action.setDisabledImageDescriptor(create("d" + type, relPath)); //$NON-NLS-1$
|
action.setDisabledImageDescriptor(create("d" + type, relPath)); //$NON-NLS-1$
|
||||||
// action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$
|
// action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$
|
||||||
action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
|
action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
|
||||||
|
|
||||||
// We are still not sure about this, let see TF results first.
|
// We are still not sure about this, let see TF results first.
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.autotools.ui;
|
package org.eclipse.cdt.internal.autotools.ui;
|
||||||
|
|
||||||
|
|
||||||
public class CBuildStepsConsole extends Console {
|
public class CBuildStepsConsole extends Console {
|
||||||
private static final String CONTEXT_MENU_ID = "CAutotoolsBuildStepsConsole"; //$NON-NLS-1$
|
private static final String CONTEXT_MENU_ID = "CAutotoolsBuildStepsConsole"; //$NON-NLS-1$
|
||||||
private static final String CONSOLE_NAME = ConsoleMessages.getString("BuildStepsConsole.name"); //$NON-NLS-1$
|
private static final String CONSOLE_NAME = ConsoleMessages.getString("BuildStepsConsole.name"); //$NON-NLS-1$
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.autotools.ui;
|
package org.eclipse.cdt.internal.autotools.ui;
|
||||||
|
|
||||||
|
|
||||||
public class CConfigureConsole extends Console {
|
public class CConfigureConsole extends Console {
|
||||||
private static final String CONTEXT_MENU_ID = "CAutotoolsConfigureConsole"; //$NON-NLS-1$
|
private static final String CONTEXT_MENU_ID = "CAutotoolsConfigureConsole"; //$NON-NLS-1$
|
||||||
private static final String CONSOLE_NAME = ConsoleMessages.getString("ConfigureConsole.name"); //$NON-NLS-1$
|
private static final String CONSOLE_NAME = ConsoleMessages.getString("ConfigureConsole.name"); //$NON-NLS-1$
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.Region;
|
import org.eclipse.jface.text.Region;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a helper class for the text editor to be able to determine, given a
|
* This is a helper class for the text editor to be able to determine, given a
|
||||||
* particular offset in a document, various candidates segments for things like
|
* particular offset in a document, various candidates segments for things like
|
||||||
|
@ -233,7 +232,8 @@ public class CWordFinder {
|
||||||
if (bracketcount-- == 0) {
|
if (bracketcount-- == 0) {
|
||||||
do {
|
do {
|
||||||
c = document.getChar(pos--);
|
c = document.getChar(pos--);
|
||||||
if (c == BRACE_R) return false;
|
if (c == BRACE_R)
|
||||||
|
return false;
|
||||||
} while (Character.isWhitespace(c));
|
} while (Character.isWhitespace(c));
|
||||||
// container block seems to be not a function or statement body
|
// container block seems to be not a function or statement body
|
||||||
pos++; // step back one symbol
|
pos++; // step back one symbol
|
||||||
|
@ -242,7 +242,8 @@ public class CWordFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (BadLocationException x) { /* Ignore */ }
|
} catch (BadLocationException x) {
|
||||||
|
/* Ignore */ }
|
||||||
// return true in case of unknown result or exception
|
// return true in case of unknown result or exception
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -255,18 +256,19 @@ public class CWordFinder {
|
||||||
* string to search in.
|
* string to search in.
|
||||||
* @return number of LFs met.
|
* @return number of LFs met.
|
||||||
*/
|
*/
|
||||||
public static int countLFs (String s) {
|
public static int countLFs(String s) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
char lf = 0;
|
char lf = 0;
|
||||||
char c;
|
char c;
|
||||||
for (int i=0; i<s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
c = s.charAt(i);
|
c = s.charAt(i);
|
||||||
if (lf == 0) {
|
if (lf == 0) {
|
||||||
if (c == '\n' || c == '\r') {
|
if (c == '\n' || c == '\r') {
|
||||||
lf = c;
|
lf = c;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
} else if (lf == c) counter++;
|
} else if (lf == c)
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
@ -278,9 +280,10 @@ public class CWordFinder {
|
||||||
* text to check
|
* text to check
|
||||||
* @return true if curled brace found.
|
* @return true if curled brace found.
|
||||||
*/
|
*/
|
||||||
public static boolean hasCBraces (String s) {
|
public static boolean hasCBraces(String s) {
|
||||||
if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1) return true;
|
if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1)
|
||||||
else return false;
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,11 @@ public class Console implements IConsole {
|
||||||
IBuildConsoleManager fConsoleManager;
|
IBuildConsoleManager fConsoleManager;
|
||||||
|
|
||||||
public Console(String consoleName, String contextId) {
|
public Console(String consoleName, String contextId) {
|
||||||
fConsoleManager = CUIPlugin.getDefault().getConsoleManager(consoleName,
|
fConsoleManager = CUIPlugin.getDefault().getConsoleManager(consoleName, contextId);
|
||||||
contextId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(IProject project ) {
|
public void start(IProject project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
fConsoleManager.getConsole(project).start(project);
|
fConsoleManager.getConsole(project).start(project);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue