private void validateIdentifierAttribute(Element element, Attr attr, ISchemaAttribute attInfo) { int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_IDENTIFIER); if (severity != CompilerFlags.IGNORE) { String value = attr.getValue(); String basedOn = attInfo.getBasedOn(); // only validate if we have a valid value and basedOn value if (value != null && basedOn != null && value.length() > 0 && basedOn.length() > 0) { Map attributes = PDESchemaHelper.getValidAttributes(attInfo); if (!attributes.containsKey(value)) { // report error if we are missing something report( NLS.bind( MDECoreMessages.ExtensionsErrorReporter_unknownIdentifier, (new String[] {attr.getValue(), attr.getName()})), getLine(element, attr.getName()), severity, MDEMarkerFactory.CAT_OTHER); } } } }
/** * Creates a default class name including package prefix. Uses the schema attribute to determine a * default name, prepends a default package name based on the project and appends the counter if * more than one such class exists. * * @param project project that the class name is being generated for * @param attInfo the schema attribute describing the new class * @param counter used to make each generated name unique */ public static String createDefaultClassName( IProject project, ISchemaAttribute attInfo, int counter) { String tag = attInfo.getParent().getName(); String expectedType = attInfo.getBasedOn(); String className = ""; // $NON-NLS-1$ if (expectedType == null) { StringBuffer buf = new StringBuffer(tag); buf.setCharAt(0, Character.toUpperCase(tag.charAt(0))); className = buf.toString(); } else { className = expectedType; int dotLoc = className.lastIndexOf('.'); if (dotLoc != -1) className = className.substring(dotLoc + 1); if (className.length() > 2 && className.charAt(0) == 'I' && Character.isUpperCase(className.charAt(1))) className = className.substring(1); } String packageName = createDefaultPackageName(project, className); className += counter; return packageName + "." + className; // $NON-NLS-1$ }