Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Harley2005-08-11 23:56:28 +0000
committerWalter Harley2005-08-11 23:56:28 +0000
commitfa632e87587c69f11b6e90d1ed0b778dff40b23c (patch)
tree3a73a6dccbdd1553f09be341b5f9c71fc227581a /org.eclipse.jdt.apt.ui
parentfe228284fc27f2126f4ffab1f41e7aadc13051c1 (diff)
downloadeclipse.jdt.core-fa632e87587c69f11b6e90d1ed0b778dff40b23c.tar.gz
eclipse.jdt.core-fa632e87587c69f11b6e90d1ed0b778dff40b23c.tar.xz
eclipse.jdt.core-fa632e87587c69f11b6e90d1ed0b778dff40b23c.zip
wharley - validate all automatically added processor options, and fix a problem where invalid gen src dir was not detected at dialog launch time.
Diffstat (limited to 'org.eclipse.jdt.apt.ui')
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java42
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java5
-rw-r--r--org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties4
3 files changed, 28 insertions, 23 deletions
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java
index 403c24cd87..ea91019332 100644
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java
+++ b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/AptConfigurationBlock.java
@@ -282,26 +282,26 @@ public class AptConfigurationBlock extends BaseConfigurationBlock {
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
IStatus status = null;
- if (changedKey == KEY_PROCESSOROPTIONS) {
- status = validateProcessorOptions(newValue);
- }
- else if (changedKey == KEY_GENSRCDIR) {
- status = validateGenSrcDir(newValue);
+ status = validateGenSrcDir();
+ if (status.getSeverity() == IStatus.OK) {
+ status = validateProcessorOptions();
}
- if (null != status) {
- fContext.statusChanged(status);
- }
+ fContext.statusChanged(status);
}
/**
* Validate "generated source directory" setting. It must be a valid
* pathname relative to a project, and must not be a source directory.
- * @param dirName
* @return
*/
- private IStatus validateGenSrcDir(String dirName) {
- Path path= new Path(dirName);
+ private IStatus validateGenSrcDir() {
+ // TODO: this check should be delegated to a validation routine in apt.core.
+ String dirName = fGenSrcDirField.getText();
+ Path path = null;
+ if (dirName != null) {
+ path= new Path(dirName);
+ }
if (path == null ||
path.isAbsolute() ||
path.isEmpty() ||
@@ -314,16 +314,20 @@ public class AptConfigurationBlock extends BaseConfigurationBlock {
}
/**
- * @param newValue
- * @return
+ * Validate the currently set processor options. We do this by
+ * looking at the table contents rather than the packed string,
+ * just because it's easier.
+ * @return a StatusInfo containing a warning if appropriate.
*/
- private IStatus validateProcessorOptions(String newValue) {
- if (newValue != null && (newValue.contains("-Aclasspath") || newValue.contains("-Asourcepath"))) { //$NON-NLS-1$ //$NON-NLS-2$
- return new StatusInfo(IStatus.WARNING, Messages.AptConfigurationBlock_warningIgnoredOptions);
- }
- else {
- return new StatusInfo();
+ private IStatus validateProcessorOptions() {
+ List<ProcessorOption> elements = getListElements();
+ for (ProcessorOption o : elements) {
+ if (AptConfig.isAutomaticProcessorOption(o.key)) {
+ return new StatusInfo(IStatus.WARNING,
+ Messages.AptConfigurationBlock_warningIgnoredOptions + ": " + o.key); //$NON-NLS-1$
+ }
}
+ return new StatusInfo();
}
/**
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java
index 77c9a2627d..a387e845db 100644
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java
+++ b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/ProcessorOptionInputDialog.java
@@ -14,6 +14,7 @@ package org.eclipse.jdt.apt.ui.internal.preferences;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.apt.core.util.AptConfig;
import org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock.ProcessorOption;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
@@ -116,8 +117,8 @@ public class ProcessorOptionInputDialog extends StatusDialog {
status.setError(Messages.ProcessorOptionInputDialog_keyAlreadyInUse);
} else if (newVal.indexOf('=') >= 0) {
status.setError(Messages.ProcessorOptionInputDialog_equalsSignNotValid);
- } else if ("classpath".equals(newKey) || "sourcepath".equals(newKey)) { //$NON-NLS-1$ //$NON-NLS-2$
- status.setWarning(Messages.AptConfigurationBlock_warningIgnoredOptions);
+ } else if (AptConfig.isAutomaticProcessorOption(newKey)) {
+ status.setWarning(Messages.AptConfigurationBlock_warningIgnoredOptions); //$NON-NLS-1$
}
updateStatus(status);
}
diff --git a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties
index 4c4222460a..9ddfb780cf 100644
--- a/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties
+++ b/org.eclipse.jdt.apt.ui/src/org/eclipse/jdt/apt/ui/internal/preferences/messages.properties
@@ -5,8 +5,8 @@ AptConfigurationBlock_edit=Edit...
AptConfigurationBlock_remove=Remove
AptConfigurationBlock_value=Value
AptConfigurationBlock_generatedSrcDir=Generated source directory:
-AptConfigurationBlock_warningIgnoredOptions=-Aclasspath and -Asourcepath options will be ignored
-AptConfigurationBlock_classpathAddedAutomaticallyNote=Note: \"-Aclasspath\" and \"-Asourcepath\" options are automatically passed to all processors, with values corresponding to the project's Java settings.
+AptConfigurationBlock_warningIgnoredOptions=An automatically set option will override this option
+AptConfigurationBlock_classpathAddedAutomaticallyNote=Note: options such as \"-classpath\" and \"-sourcepath\" are automatically passed to all processors, with values corresponding to the project's Java settings.
AptConfigurationBlock_genSrcDirMustBeValidRelativePath=Generated source directory must be a valid relative path
AptConfigurationBlock_options=Processor options (-Akey=value):
AptPreferencePage_preferences=Java annotation processing preferences:

Back to the top