use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class AstRunnerJava method doAnalysis.
private final Module doAnalysis(IFile file, String code) {
TTCN3Analyzer ttcn3Analyzer = new TTCN3Analyzer();
if (file != null) {
logger.severe("Calling TTCN3 parser with " + file.getName() + " and " + null + "\n");
ttcn3Analyzer.parse(file, null);
} else if (code != null) {
logger.severe("Calling TTCN3 parser with null and " + code + "\n");
ttcn3Analyzer.parse(null, code);
} else
return null;
Module module = ttcn3Analyzer.getModule();
return module;
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class AstWalkerJava method doAnalysis.
private final Module doAnalysis(IFile file, String code) {
TTCN3Analyzer ttcn3Analyzer = new TTCN3Analyzer();
if (file != null) {
logger.severe("Calling TTCN3 parser with " + file.getName() + " and " + null + "\n");
ttcn3Analyzer.parse(file, null);
} else if (code != null) {
logger.severe("Calling TTCN3 parser with null and " + code + "\n");
ttcn3Analyzer.parse(null, code);
} else
return null;
Module module = ttcn3Analyzer.getModule();
return module;
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method execute.
public void execute() {
if (writeDebugInfo) {
TITANDebugConsole.println(String.format(format, header, simpleDateFormat.format(new Date())));
}
start = System.nanoTime();
final List<Module> startModules = collectStartModules(allModules);
final Map<Module, List<Module>> invertedImports = buildInvertedImportStructure(allModules, startModules);
computeAnalyzeOnlyDefinitionsFlag(allModules, startModules);
if (analyzeOnlyAssignments) {
final IPreferencesService preferenceService = Platform.getPreferencesService();
final boolean useIncrementalParsing = preferenceService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEINCREMENTALPARSING, false, null);
final Map<Module, List<AssignmentHandler>> result = collectBrokenParts(startModules, invertedImports, useIncrementalParsing);
if (writeDebugInfo && !isTooSlow()) {
writeDebugInfo(result);
}
collectRealBrokenParts(result, useIncrementalParsing);
}
if (writeDebugInfo && isTooSlow()) {
TITANDebugConsole.println(" Switching back to old selection format");
}
// if we need to use the old selection or the new selection method took too long
if (!analyzeOnlyAssignments || isTooSlow()) {
analyzeOnlyAssignments = false;
modulesToCheck.clear();
moduleAndBrokenAssignments.clear();
final List<Module> modules = collectBrokenModulesViaInvertedImports(startModules, invertedImports);
modulesToCheck.addAll(modules);
}
afterExecute();
end = System.nanoTime() - start;
if (writeDebugInfo) {
TITANDebugConsole.println(String.format(format, footer, simpleDateFormat.format(new Date())));
infoAfterExecute();
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method collectBrokenParts.
protected Map<Module, List<AssignmentHandler>> collectBrokenParts(final List<Module> startModules, final Map<Module, List<Module>> invertedImports, final boolean useIncrementalParsing) {
final List<Module> startModulesCopy = new ArrayList<Module>(startModules);
final Map<Module, List<AssignmentHandler>> moduleAndBrokenAssignments = new HashMap<Module, List<AssignmentHandler>>();
processStartModules(startModulesCopy, moduleAndBrokenAssignments);
for (int i = 0; i < startModulesCopy.size() && !isTooSlow(); ++i) {
final Module startModule = startModulesCopy.get(i);
List<AssignmentHandler> startAssignments;
if (moduleAndBrokenAssignments.containsKey(startModule)) {
startAssignments = moduleAndBrokenAssignments.get(startModule);
} else {
// <<<<<< getAssignments() used in collectBrokenModulesViaInvertedImports, too
startAssignments = getAssignmentsFrom(startModule);
moduleAndBrokenAssignments.put(startModule, startAssignments);
}
if (startAssignments.isEmpty()) {
continue;
}
final List<Module> whereStartModuleUsed = invertedImports.get(startModule);
// If not incremental parsing is used, also all importing modules shall be fully reanalyze
if (!useIncrementalParsing || (startModule instanceof TTCN3Module && ((TTCN3Module) startModule).getDefinitions().getLastCompilationTimeStamp() == null)) {
for (int j = 0; j < whereStartModuleUsed.size(); ++j) {
final Module dependentModule = whereStartModuleUsed.get(j);
// overwrites the dependentAssignments with the full list of assignments
final List<AssignmentHandler> dependentAssignments = getAssignmentsFrom(dependentModule);
moduleAndBrokenAssignments.put(dependentModule, dependentAssignments);
}
} else {
// incremental parsing + no name change
for (int j = 0; j < whereStartModuleUsed.size(); ++j) {
final Module dependentModule = whereStartModuleUsed.get(j);
List<AssignmentHandler> dependentAssignments;
if (moduleAndBrokenAssignments.containsKey(dependentModule)) {
dependentAssignments = moduleAndBrokenAssignments.get(dependentModule);
} else {
dependentAssignments = getAssignmentsFrom(dependentModule);
moduleAndBrokenAssignments.put(dependentModule, dependentAssignments);
}
// We have to separate broken and not broken definition, because of postcheck.
final List<AssignmentHandler> brokens = new ArrayList<AssignmentHandler>();
final List<AssignmentHandler> notBrokens = new ArrayList<AssignmentHandler>();
for (int s = 0; s < startAssignments.size(); ++s) {
final AssignmentHandler startAssignment = startAssignments.get(s);
if (startAssignment.getIsContagious()) {
for (int d = 0; d < dependentAssignments.size(); ++d) {
final AssignmentHandler dependentAssignment = dependentAssignments.get(d);
// only infection and contagion are checked
dependentAssignment.check(startAssignment);
if (dependentAssignment.getIsInfected()) {
if (!startModulesCopy.contains(dependentModule)) {
startModulesCopy.add(dependentModule);
}
if (!brokens.contains(dependentAssignment)) {
brokens.add(dependentAssignment);
}
}
}
}
}
for (int d = 0; d < dependentAssignments.size(); ++d) {
final AssignmentHandler dependentAssignment = dependentAssignments.get(d);
if (!dependentAssignment.getIsInfected()) {
notBrokens.add(dependentAssignment);
}
}
// Have to post check of local definition of modules.
// A definition can reference an other definition too.
checkLocalAssignments(brokens, notBrokens);
// so we have to delete it from moduleAndBrokenDefs.
if (!startModulesCopy.contains(dependentModule)) {
moduleAndBrokenAssignments.remove(dependentModule);
}
}
}
}
return moduleAndBrokenAssignments;
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method collectBrokenModulesViaInvertedImports.
protected List<Module> collectBrokenModulesViaInvertedImports(final List<Module> startModules, final Map<Module, List<Module>> invertedImports) {
final List<Module> startModulesCopy = new ArrayList<Module>(startModules);
final List<Module> result = new ArrayList<Module>();
final MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream();
if (writeDebugInfo) {
for (Module startModule : startModules) {
TITANDebugConsole.println(" ** Module " + startModule.getName() + " can not be skipped as it was not yet analyzed.", stream);
}
}
for (int s = 0; s < startModulesCopy.size(); ++s) {
final Module startModule = startModulesCopy.get(s);
if (!result.contains(startModule)) {
result.add(startModule);
}
final List<Module> whereStartModuleUsed = invertedImports.get(startModule);
for (int d = 0; d < whereStartModuleUsed.size(); ++d) {
final Module dependentModule = whereStartModuleUsed.get(d);
if (!startModulesCopy.contains(dependentModule)) {
startModulesCopy.add(dependentModule);
if (writeDebugInfo) {
TITANDebugConsole.println(" ** Module " + dependentModule.getName() + " can not be skipped as it depends on " + startModule.getName() + " which needs to be checked.", stream);
}
}
}
startModule.notCheckRoot();
final Assignments assignments = startModule.getAssignments();
for (int d = 0; d < assignments.getNofAssignments(); ++d) {
final Assignment assignment = assignments.getAssignmentByIndex(d);
assignment.notCheckRoot();
}
}
return result;
}
Aggregations