Search in sources :

Example 1 with Ttcn3FileReparser

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

the class ProjectSourceSyntacticAnalyzer method updateSyntax.

/**
 * The entry point of incremental parsing.
 * <p>
 * Handles the data storages, calls the module level incremental parser
 * on the file, and if everything fails does a full parsing to correct
 * possibly invalid states.
 *
 * @param file
 *                the edited file
 * @param reparser
 *                the parser doing the incremental parsing.
 */
public void updateSyntax(final IFile file, final TTCN3ReparseUpdater reparser) {
    if (uptodateFiles.containsKey(file)) {
        Module module = sourceParser.getSemanticAnalyzer().getModulebyFile(file);
        sourceParser.getSemanticAnalyzer().reportSemanticOutdating(file);
        if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
            try {
                reparser.setUnsupportedConstructs(unsupportedConstructMap);
                try {
                    ((TTCN3Module) module).updateSyntax(reparser, sourceParser);
                    reparser.updateLocation(((TTCN3Module) module).getLocation());
                } catch (ReParseException e) {
                    syntacticallyOutdated = true;
                    uptodateFiles.remove(file);
                    sourceParser.getSemanticAnalyzer().reportSemanticOutdating(file);
                    String oldModuleName = fileMap.get(file);
                    if (oldModuleName != null) {
                        sourceParser.getSemanticAnalyzer().removeModule(oldModuleName);
                        fileMap.remove(file);
                    }
                    unsupportedConstructMap.remove(file);
                    reparser.maxDamage();
                    ITtcn3FileReparser r = new Ttcn3FileReparser(reparser, file, sourceParser, fileMap, uptodateFiles, highlySyntaxErroneousFiles);
                    syntacticallyOutdated = r.parse();
                }
                MarkerHandler.removeAllOnTheFlySyntacticMarkedMarkers(file);
                // update the position of the markers located after the damaged region
                MarkerHandler.updateMarkers(file, reparser.getFirstLine(), reparser.getLineShift(), reparser.getDamageEnd(), reparser.getShift());
            } catch (Exception e) {
                // This catch is extremely important, as
                // it is supposed to protect the project
                // parser, from whatever might go wrong
                // inside the analysis.
                ErrorReporter.logExceptionStackTrace(e);
            }
        } else {
            reportOutdating(file);
        }
    } else if (highlySyntaxErroneousFiles.contains(file)) {
        reportOutdating(file);
    } else {
        MarkerHandler.markAllMarkersForRemoval(file);
        TemporalParseData temp = fileBasedTTCN3Analysis(file);
        postFileBasedGeneralAnalysis(temp);
    }
    reparser.reportSyntaxErrors();
}
Also used : ITtcn3FileReparser(org.eclipse.titan.designer.parsers.ttcn3parser.ITtcn3FileReparser) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) Ttcn3FileReparser(org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3FileReparser) ITtcn3FileReparser(org.eclipse.titan.designer.parsers.ttcn3parser.ITtcn3FileReparser) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) Module(org.eclipse.titan.designer.AST.Module) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException) CoreException(org.eclipse.core.runtime.CoreException) FileNotFoundException(java.io.FileNotFoundException) ReParseException(org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 CoreException (org.eclipse.core.runtime.CoreException)1 Module (org.eclipse.titan.designer.AST.Module)1 TTCN3Module (org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module)1 ITtcn3FileReparser (org.eclipse.titan.designer.parsers.ttcn3parser.ITtcn3FileReparser)1 ReParseException (org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException)1 Ttcn3FileReparser (org.eclipse.titan.designer.parsers.ttcn3parser.Ttcn3FileReparser)1