[Buix-commits] r945 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler
Author: tchemit Date: 2008-10-17 16:43:00 +0000 (Fri, 17 Oct 2008) New Revision: 945 Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompiler.java Log: add method checkReference to check if an object is available on second compil pass Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-10-17 05:07:31 UTC (rev 944) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-10-17 16:43:00 UTC (rev 945) @@ -695,7 +695,7 @@ javaFile.addField(new JavaField(Modifier.PROTECTED, "java.util.Map<String,Object>", "$bindingSources", "new HashMap<String,Object>()")); } - javaFile.addImport("jaxx.runtime.BeanValidator"); + javaFile.addImport("jaxx.runtime.BeanValidator"); javaFile.addField(new JavaField(Modifier.PROTECTED, "java.util.List<String>", "$validatorIds", "new ArrayList<String>()")); if (stylesheet != null) { @@ -2144,4 +2144,30 @@ public boolean hasValidator() { return !validators.isEmpty(); } + + /** + * Check that a reference exists in symbol table on second compil pass + * + * @param tag the current tag + * @param reference the required reference + * @param strict flag to report an error if reference was not found + * @param attribute (if not null reference the attribute where is defined the reference) + * @return <code>true</code> if reference was found, <code>false</code> otherwise and add an error in compiler + */ + public boolean checkReference(Element tag, String reference, boolean strict, String attribute) { + String component = getSymbolTable().getClassTagIds().get(reference); + if (component == null) { + if (strict) { + String msg; + if (attribute != null) { + msg = "tag '" + tag.getLocalName() + "' could not find the reference '" + reference + "' on attribute [" + attribute + "]"; + } else { + msg = "tag '" + tag.getLocalName() + "' could not find the reference '" + reference + "'"; + } + reportError(msg); + } + return false; + } + return true; + } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org