/** Populate current module fields with data from dependent modules. */ protected void initDependencies() { // Reduce iterators over dependencies for // compilation issue with lazy loading for (CompiledDependency dependency : this.getDependencies()) { // commented as there is no need to add each datatype to upper // module. // as now it`s will be impossible to validate from which module the // datatype is. // // addTypes(dependency); addDependencyTypes(dependency); addMethods(dependency); // Populate current module fields with data from dependent modules. // Requered // for data tables inheriting from dependend modules. addDataTables(dependency.getCompiledOpenClass()); // Required for // data tables. } }
protected void addTestSuiteMethodsFromDependencies() { for (CompiledDependency dependency : this.getDependencies()) { for (IOpenMethod depMethod : dependency.getCompiledOpenClass().getOpenClassWithErrors().getMethods()) { if (depMethod instanceof TestSuiteMethod) { TestSuiteMethod testSuiteMethod = (TestSuiteMethod) depMethod; try { // Workaround for set dependency names in method while // compile if (testSuiteMethod.getModuleName() == null) { testSuiteMethod.setModuleName(dependency.getDependencyName()); } TestSuiteMethod newTestSuiteMethod = createNewTestSuiteMethod(testSuiteMethod); addMethod(newTestSuiteMethod); } catch (OpenlNotCheckedException e) { if (Log.isDebugEnabled()) { Log.debug(e.getMessage(), e); } addError(e); } } } } }
@Override public void addError(Throwable error) { if (error instanceof DuplicatedMethodException || error instanceof DuplicatedVarException || error instanceof DuplicatedTableException || error instanceof SyntaxNodeException) { if (VirtualSourceCodeModule.SOURCE_URI.equals(metaInfo.getSourceUrl())) { // Avoid duplication of error messages. This error was defined // in dependent module already. for (CompiledDependency dependency : getDependencies()) { List<OpenLMessage> errors = OpenLMessagesUtils.filterMessagesBySeverity( dependency.getCompiledOpenClass().getMessages(), Severity.ERROR); for (OpenLMessage message : errors) { if (message.getSummary() != null && message.getSummary().equals(error.getMessage())) { return; } } } } } super.addError(error); }
private void addDataTables(CompiledOpenClass dependency) { IOpenClass openClass = dependency.getOpenClassWithErrors(); Map<String, IOpenField> fieldsMap = openClass.getFields(); Set<String> tableUrls = new HashSet<String>(); Map<String, IOpenField> fields = getFields(); for (IOpenField openField : fields.values()) { if (openField instanceof DataOpenField) { tableUrls.add(((DataOpenField) openField).getTableUri()); } } for (String key : fieldsMap.keySet()) { IOpenField field = fieldsMap.get(key); if (field instanceof DataOpenField) { DataOpenField dataOpenField = (DataOpenField) field; try { String tableUrl = dataOpenField.getTableUri(); // Test tables are added both as methods and variables. if (!tableUrls.contains(tableUrl) && !duplicatedMethodUrls.contains(tableUrl)) { boolean containsInDependency = false; if (VirtualSourceCodeModule.SOURCE_URI.equals(metaInfo.getSourceUrl())) { for (CompiledDependency d : getDependencies()) { IOpenClass dependentModuleClass = d.getCompiledOpenClass().getOpenClassWithErrors(); if (dependentModuleClass instanceof XlsModuleOpenClass) { if (((XlsModuleOpenClass) dependentModuleClass) .duplicatedMethodUrls.contains(tableUrl)) { containsInDependency = true; break; } } } } if (!containsInDependency) { addField(field); tableUrls.add(tableUrl); } } } catch (OpenlNotCheckedException e) { SyntaxNodeException error = SyntaxNodeExceptionUtils.createError( e.getMessage(), e, dataOpenField.getTable().getTableSyntaxNode()); addError(error); } } } if (openClass instanceof XlsModuleOpenClass) { XlsModuleOpenClass xlsModuleOpenClass = (XlsModuleOpenClass) openClass; if (xlsModuleOpenClass.getDataBase() != null) { for (ITable table : xlsModuleOpenClass.getDataBase().getTables()) { if (XlsNodeTypes.XLS_DATA.toString().equals(table.getTableSyntaxNode().getType())) { try { getDataBase().registerTable(table); } catch (DuplicatedTableException e) { addError(e); } catch (OpenlNotCheckedException e) { addError(e); } } } } } }