1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 20:45:22 +02:00

Add missing Autotools UI fixes done after initial move.

- fix some findBugs warnings
- use sh -c to invoke Autotool scripts
- switch AutomakeErrorHandler to use IEditorInput
This commit is contained in:
Jeff Johnston 2012-03-30 18:19:17 -04:00
parent a3a513fffb
commit 22ea1c7683
7 changed files with 57 additions and 33 deletions

View file

@ -1,3 +1,31 @@
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java
(AutomakeEditor): Make constructor public so openEditor will work.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeErrorHandler.java
(AutomakeErrorHandler): Change constructor to accept an IEditorInput rather than
an IDocument.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileReconcilingStrategy.java
(AutomakefileReconcilingStrategy): Pass an IEditorInput to create the
AutomakeErrorHandler.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeDocumentProvider.java
(connect): Ditto.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/ui/editors/AutoconfMacro.java
(equals): Fix FindBugs error with missing null case.
(hashCode): New method to fix FindBugs error.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java
(AutomakeEditor): Fix constructor to remove static variable.
(static initializer): Fix FindBugs error with static variable usage.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
Bug #371277
* src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java
(..run): Use sh -c to execute the autotool scripts.
2012-03-29 Jeff Johnston <jjohnstn@redhat.com>
Resolves: bug#374026

View file

@ -42,7 +42,14 @@ public class AutoconfMacro implements Comparable<Object> {
}
public boolean equals(Object x) {
if (x == null)
return false;
AutoconfMacro y = (AutoconfMacro)x;
return getName().equals(y.getName());
}
public int hashCode() {
return getName().hashCode();
}
}

View file

@ -41,7 +41,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@ -259,7 +258,7 @@ public abstract class InvokeAction extends AbstractTargetAction {
Process process = cmdL.execute(command, argumentList, envList,
execDir, new NullProgressMonitor());
if (cmdL.waitAndRead(stdout, stderr) == CommandLauncher.OK) {
if (cmdL.waitAndRead(stdout, stderr, new NullProgressMonitor()) == CommandLauncher.OK) {
try {
status = 0;
monitor.done();
@ -389,30 +388,18 @@ public abstract class InvokeAction extends AbstractTargetAction {
String[] newArgumentList;
// Fix for bug #343905
// For Windows and Mac, we cannot run a script directly (in this case, the
// autotools are scripts). We need to run "sh -c command args where command
// plus args is represented in a single string.
if (Platform.getOS().equals(Platform.OS_WIN32)
|| Platform.getOS().equals(Platform.OS_MACOSX)) {
// Neither Mac or Windows support calling scripts directly.
StringBuffer command = new StringBuffer(strippedCommand);
for (String arg : argumentList) {
command.append(" " + arg);
}
newArgumentList = new String[] { "-c", command.toString() };
} else {
// Otherwise, we don't need the -c argument and can present the command
// name and arguments as individual arguments
if (argumentList == null)
newArgumentList = new String[1];
else
newArgumentList = new String[argumentList.length + 1];
newArgumentList[0] = strippedCommand;
if (argumentList != null)
System.arraycopy(argumentList, 0, newArgumentList, 1, argumentList.length);
}
// Fix for bug #343905 and bug #371277
// For Windows and Mac, we cannot run a script directly (in this case,
// autotools are scripts). We need to run "sh -c command args where command
// plus args is represented in a single string. The same applies for
// some Linux shells such as dash. Using sh -c will work on all Linux
// POSIX-compliant shells.
StringBuffer command = new StringBuffer(strippedCommand);
for (String arg : argumentList) {
command.append(" " + arg);
}
newArgumentList = new String[] { "-c", command.toString() };
OutputStream stdout = consoleOutStream;
OutputStream stderr = consoleOutStream;

View file

@ -17,6 +17,7 @@ import java.util.Iterator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
@ -105,8 +106,7 @@ public class AutomakeDocumentProvider extends TextFileDocumentProvider implement
public void connect(Object element) throws CoreException {
super.connect(element);
IMakefile makefile = getWorkingCopy(element);
IDocument document = getDocument(element);
AutomakeErrorHandler errorHandler = new AutomakeErrorHandler(document);
AutomakeErrorHandler errorHandler = new AutomakeErrorHandler((IEditorInput)element);
errorHandler.update(makefile);
}

View file

@ -34,9 +34,12 @@ public class AutomakeEditor extends MakefileEditor {
private static AutomakeEditor fgInstance;
private IEditorInput input;
static {
fgInstance = new AutomakeEditor();
}
public AutomakeEditor() {
super();
fgInstance = this;
}
/**

View file

@ -52,9 +52,8 @@ public class AutomakeErrorHandler {
}
public AutomakeErrorHandler(IDocument document) {
this.document = document;
IEditorInput input = AutomakeEditor.getDefault().getEditorInput();
public AutomakeErrorHandler(IEditorInput input) {
this.document = AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getDocument(input);
this.fAnnotationModel = (AnnotationModel)AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getAnnotationModel(input);
}

View file

@ -42,7 +42,7 @@ public class AutomakefileReconcilingStrategy implements IReconcilingStrategy {
input = (IEditorInput) fEditor.getEditorInput();
fManager= AutomakeEditorFactory.getDefault().getWorkingCopyManager();
fDocumentProvider= AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider();
fErrorHandler= new AutomakeErrorHandler(fDocumentProvider.getDocument(input));
fErrorHandler= new AutomakeErrorHandler(input);
fMakefileReconcilingParticipant= (IReconcilingParticipant)fEditor;
}