Search in sources :

Example 1 with Module

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;
}
Also used : Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) TTCN3Analyzer(org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3Analyzer)

Example 2 with 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;
}
Also used : TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) Module(org.eclipse.titan.designer.AST.Module) TTCN3Analyzer(org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3Analyzer)

Example 3 with 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();
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) Date(java.util.Date) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 4 with Module

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;
}
Also used : TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)

Example 5 with Module

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;
}
Also used : Undefined_Assignment(org.eclipse.titan.designer.AST.ASN1.Undefined_Assignment) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ArrayList(java.util.ArrayList) Assignments(org.eclipse.titan.designer.AST.Assignments) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)

Aggregations

Module (org.eclipse.titan.designer.AST.Module)130 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)51 ArrayList (java.util.ArrayList)37 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)36 IFile (org.eclipse.core.resources.IFile)32 Assignment (org.eclipse.titan.designer.AST.Assignment)22 Identifier (org.eclipse.titan.designer.AST.Identifier)21 Location (org.eclipse.titan.designer.AST.Location)16 Reference (org.eclipse.titan.designer.AST.Reference)16 ImportModule (org.eclipse.titan.designer.AST.TTCN3.definitions.ImportModule)16 HashMap (java.util.HashMap)14 List (java.util.List)13 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)11 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)11 IProject (org.eclipse.core.resources.IProject)10 IResource (org.eclipse.core.resources.IResource)10 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)10 Assignments (org.eclipse.titan.designer.AST.Assignments)9 Scope (org.eclipse.titan.designer.AST.Scope)9 TextSelection (org.eclipse.jface.text.TextSelection)8