Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2009-04-27 13:29:17 -0400
committerpelder2009-04-27 13:29:17 -0400
commit6f895cb3e1ac8e9cd37cbc83a29604c1233d87f3 (patch)
treed667d931780c76ba1e5ad2e2bccf67b74896ee34
parent0b9fc586f424606188325a4a845036cde1a0ead8 (diff)
downloadorg.eclipse.jet-6f895cb3e1ac8e9cd37cbc83a29604c1233d87f3.tar.gz
org.eclipse.jet-6f895cb3e1ac8e9cd37cbc83a29604c1233d87f3.tar.xz
org.eclipse.jet-6f895cb3e1ac8e9cd37cbc83a29604c1233d87f3.zip
[273909] Errors for java:merge tag can be hard to diagnose
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.properties5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/MergeTag.java25
3 files changed, 28 insertions, 6 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.java
index 8820ad2..29239fd 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -90,6 +90,8 @@ public class JET2Messages extends NLS
public static String MergeTag_FailedOnCompilerError;
+ public static String MergeTag_GeneratedJavaError;
+
public static String MergeTag_UnknownJMergeFacadeHelper;
public static String ModelLoaderExtManager_TypeAlreadyDefined;
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.properties b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.properties
index 2858482..64ebf43 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.properties
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/l10n/JET2Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2008 IBM Corporation and others.
+# Copyright (c) 2005, 2009 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -164,7 +164,8 @@ LoaderManager_MultipleLoaders=Multiple loaders found for ''{0}'': {1}
LoaderManager_CouldNotFindLoader=Could not find a loader for ''{0}''
MergeTag_CouldNotRead=Unable to read file {0}
MergeTag_CouldNotCreateURL=Could not create URL({0}, {1})
-MergeTag_FailedOnCompilerError=Merge of generated content into {0} failed because of a compilation error. Re-run the transformation after you fix the any errors in the file, or rename or delete the file.
+MergeTag_FailedOnCompilerError=Merge of generated content into {0} failed because of compilation errors on the existing file. Fix these errors or delete/rename the file and then re-run the transformation.
+MergeTag_GeneratedJavaError=Merge of generated content into {0} failed because of a compilation error in the generated content. Modify the transformation input, or contact the template creator.
MarkerHelper_CouldNotCreateMarker=Unable to create marker on file {0}
TransformContextExtender_NeedsRebuildForOverride=Transformation {0} needs to be rebuild in order to support override
ReplaceStringsTag_BadList=Error parsing comma-separated list of strings:
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/MergeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/MergeTag.java
index 5c9633d..2e89e03 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/MergeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/MergeTag.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -209,8 +209,8 @@ public class MergeTag extends AbstractEmptyTag
controlModel.initialize(facadeHelper, mergePosition.getRulesURL().toExternalForm());
JMerger merger = new JMerger(controlModel);
- JCompilationUnit sourceCU = facadeHelper.createCompilationUnit(iFile.getName(), writer.toString());
- JCompilationUnit targetCU = facadeHelper.createCompilationUnit(iFile.getName(), targetCUSource);
+ JCompilationUnit sourceCU = getJCompilationUnit(facadeHelper, iFile, writer.toString(), true);
+ JCompilationUnit targetCU = getJCompilationUnit(facadeHelper, iFile, targetCUSource, false);
merger.setSourceCompilationUnit(sourceCU);
merger.setTargetCompilationUnit(targetCU);
@@ -231,6 +231,25 @@ public class MergeTag extends AbstractEmptyTag
}
}
+
+ /**
+ * @param facadeHelper
+ * @param iFile
+ * @param content
+ * @param isGenContent
+ * @return
+ */
+ private JCompilationUnit getJCompilationUnit(FacadeHelper facadeHelper, IFile iFile, final String content, boolean isGenContent)
+ {
+ try {
+ JCompilationUnit sourceCU = facadeHelper.createCompilationUnit(iFile.getName(), content);
+ return sourceCU;
+ } catch( WrappedException e ) {
+ final String baseMsg = isGenContent ? JET2Messages.MergeTag_GeneratedJavaError : JET2Messages.MergeTag_FailedOnCompilerError;
+ final String msg = MessageFormat.format(baseMsg, new Object[] {iFile.getFullPath().makeRelative()});
+ throw new JET2TagException(msg, e.exception());
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.jet.IWriterListener#postCommitContent(org.eclipse.jet.JET2Writer, java.lang.Object)
*/

Back to the top