Search in sources :

Example 16 with ProjectSourceParser

use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.

the class DocumentSetupParticipant method analyze.

void analyze(final IDocument document, final boolean isInitial) {
    final IFile editedFile = (IFile) editor.getEditorInput().getAdapter(IFile.class);
    if (editedFile == null || ResourceExclusionHelper.isExcluded(editedFile)) {
        return;
    }
    IProject project = editedFile.getProject();
    if (project == null) {
        return;
    }
    ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
    projectSourceParser.reportOutdating(editedFile);
    if (isInitial || !editor.isSemanticCheckingDelayed()) {
        projectSourceParser.analyzeAll();
    } else {
        projectSourceParser.reportSyntacticOutdatingOnly(editedFile);
        projectSourceParser.analyzeAllOnlySyntactically();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IProject(org.eclipse.core.resources.IProject) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 17 with ProjectSourceParser

use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.

the class OutlinePage method getModule.

private Module getModule() {
    final IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
    if (file == null) {
        return null;
    }
    ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(file.getProject());
    return sourceParser.containedModule(file);
}
Also used : IFile(org.eclipse.core.resources.IFile) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 18 with ProjectSourceParser

use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.

the class DefinitionFinder method getDefinitionsOfProject.

private List<Object> getDefinitionsOfProject(final IProject project) {
    final List<Object> result = new ArrayList<Object>();
    ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
    if (filter.showOnlyModules()) {
        result.addAll(parser.getModules());
    } else {
        for (Module module : parser.getModules()) {
            if (filter.filter(module)) {
                result.add(module);
            }
            for (Assignment ass : module.getAssignments()) {
                if (filter.filter(ass)) {
                    result.add(ass);
                }
            }
        }
    }
    return result;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ArrayList(java.util.ArrayList) Module(org.eclipse.titan.designer.AST.Module) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 19 with ProjectSourceParser

use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.

the class ChangeCreator method createFileChange.

private Change createFileChange(final IFile toVisit) {
    if (toVisit == null) {
        return null;
    }
    final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(toVisit.getProject());
    final Module module = sourceParser.containedModule(toVisit);
    if (module == null) {
        return null;
    }
    if (selection instanceof Def_Type) {
        final Def_Type df = (Def_Type) selection;
        type = df.getType(CompilationTimeStamp.getBaseTimestamp());
    }
    final DefinitionVisitor vis = new DefinitionVisitor(type);
    module.accept(vis);
    final NavigableSet<ILocateableNode> nodes = vis.getLocations();
    if (nodes.isEmpty()) {
        return null;
    }
    final TextFileChange tfc = new TextFileChange(toVisit.getName(), toVisit);
    final MultiTextEdit rootEdit = new MultiTextEdit();
    try {
        final WorkspaceJob job1 = calculateEditLocations(nodes, toVisit, rootEdit);
        job1.join();
    } catch (InterruptedException ie) {
        ErrorReporter.logExceptionStackTrace(ie);
    } catch (CoreException ce) {
        ErrorReporter.logError("InsertFieldRefactoring/CreateChange.createFileChange(): " + "CoreException while calculating edit locations. ");
        ErrorReporter.logExceptionStackTrace(ce);
    }
    if (!rootEdit.hasChildren()) {
        return null;
    }
    tfc.setEdit(rootEdit);
    return tfc;
}
Also used : Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) CoreException(org.eclipse.core.runtime.CoreException) ILocateableNode(org.eclipse.titan.designer.AST.ILocateableNode) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Module(org.eclipse.titan.designer.AST.Module) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit)

Example 20 with ProjectSourceParser

use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.

the class ChangeCreator method createFileChange.

private Change createFileChange(final IFile toVisit) {
    if (toVisit == null) {
        return null;
    }
    final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(toVisit.getProject());
    final Module module = sourceParser.containedModule(toVisit);
    if (module == null) {
        return null;
    }
    final DefinitionVisitor vis = new DefinitionVisitor();
    module.accept(vis);
    final List<FormalParameter> nodes = vis.getLocations();
    // Calculate edit locations
    final List<Location> locations = new ArrayList<Location>();
    try {
        final WorkspaceJob job1 = calculateEditLocations(nodes, toVisit, locations);
        job1.join();
    } catch (InterruptedException ie) {
        ErrorReporter.logExceptionStackTrace(ie);
    } catch (CoreException ce) {
        ErrorReporter.logError("LazyficationRefactoring: " + "CoreException while calculating edit locations in " + toVisit.getName() + ".");
        ErrorReporter.logExceptionStackTrace(ce);
    }
    if (locations.isEmpty()) {
        return null;
    }
    // Create a change for each edit location
    final TextFileChange tfc = new TextFileChange(toVisit.getName(), toVisit);
    final MultiTextEdit rootEdit = new MultiTextEdit();
    tfc.setEdit(rootEdit);
    for (Location l : locations) {
        rootEdit.addChild(new InsertEdit(l.getOffset(), "@lazy "));
    }
    return tfc;
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) InsertEdit(org.eclipse.text.edits.InsertEdit) ArrayList(java.util.ArrayList) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser) CoreException(org.eclipse.core.runtime.CoreException) Module(org.eclipse.titan.designer.AST.Module) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Location(org.eclipse.titan.designer.AST.Location)

Aggregations

ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)72 Module (org.eclipse.titan.designer.AST.Module)51 IFile (org.eclipse.core.resources.IFile)34 ArrayList (java.util.ArrayList)23 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)23 IProject (org.eclipse.core.resources.IProject)19 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)14 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)12 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)11 Identifier (org.eclipse.titan.designer.AST.Identifier)11 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)10 Location (org.eclipse.titan.designer.AST.Location)10 List (java.util.List)9 Reference (org.eclipse.titan.designer.AST.Reference)9 ImportModule (org.eclipse.titan.designer.AST.TTCN3.definitions.ImportModule)9 CoreException (org.eclipse.core.runtime.CoreException)8 TextSelection (org.eclipse.jface.text.TextSelection)8 TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)8 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7