use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class InternalMakefileGenerator method addTTCN3Module.
/**
* Adds a file to the list of TTCN-3 files.
* <p/>
* The directory of the file must always point to a working directory,
* or a central storage directory.
*
* @param file the file to be added.
* @param directory in which this file can be found (null if the working
* directory of the actual project)
*/
public void addTTCN3Module(final IFile file, final String directory) {
ProjectSourceParser parser = GlobalParser.getProjectSourceParser(file.getProject());
String moduleName = parser.containedModuleName(file);
if (moduleName == null) {
if (file.isSynchronized(IResource.DEPTH_ZERO)) {
ErrorReporter.logWarning("file " + file.getFullPath().toOSString() + " is out-of sync with the file system");
} else {
ErrorReporter.logWarning("file " + file.getFullPath().toOSString() + " even tough it has ttcn extension is added as on other file since the on-the-fly analyzer was not able to find a valid module inside");
}
addOtherFiles(file, directory);
return;
}
final Identifier identifier = new Identifier(Identifier_type.ID_NAME, moduleName);
ModuleStruct module;
final IPath fileLocation = file.getLocation();
if (fileLocation == null) {
final String originalLocation = directory + File.separatorChar + file.getName();
module = new ModuleStruct(directory, originalLocation, file.getName(), identifier.getTtcnName());
} else {
final String originalLocation = fileLocation.toOSString();
module = new ModuleStruct(directory, originalLocation, fileLocation.lastSegment(), identifier.getTtcnName());
}
module.setRegular(fileLocation != null && "ttcn".equals(file.getFileExtension()) && file.getName().equals(moduleName + ".ttcn"));
ttcn3Modules.add(module);
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclarationHelper method findVisibleDeclarations.
public static DeclarationCollector findVisibleDeclarations(final IEditorPart targetEditor, final IReferenceParser referenceParser, final IDocument document, final int offset, final boolean reportErrors) {
final IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
if (reportErrors) {
ErrorReporter.parallelDisplayInStatusLine(targetEditor, NORECOGNISABLEFILE);
}
return null;
}
Reference reference = null;
referenceParser.setErrorReporting(reportErrors);
reference = referenceParser.findReferenceForOpening(file, offset, document);
if (reference == null) {
if (reportErrors) {
ErrorReporter.parallelDisplayInStatusLine(targetEditor, NORECOGNISABLEREFERENCE);
}
return null;
}
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
if (ResourceExclusionHelper.isExcluded(file)) {
ErrorReporter.parallelDisplayInStatusLine(targetEditor, MessageFormat.format(EXCLUDEDFROMBUILD, file.getFullPath()));
return null;
}
final Module tempModule = projectSourceParser.containedModule(file);
if (tempModule == null) {
if (reportErrors) {
ErrorReporter.parallelDisplayInStatusLine(targetEditor, MessageFormat.format(NOTFOUNDMODULE, file.getFullPath()));
}
return null;
}
final Scope scope = tempModule.getSmallestEnclosingScope(offset);
if (scope == null) {
if (reportErrors) {
ErrorReporter.parallelDisplayInStatusLine(targetEditor, NORECOGNISABLESCOPE);
}
return null;
}
reference.setMyScope(scope);
reference.detectModid();
if (reference.getId() == null) {
if (reportErrors) {
ErrorReporter.parallelDisplayInStatusLine(targetEditor, NORECOGNISABLEREFERENCE);
}
return null;
}
final DeclarationCollector declarationCollector = new DeclarationCollector(reference);
scope.addDeclaration(declarationCollector);
return declarationCollector;
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class FriendModule method check.
/**
* Does the semantic checking of this friend ship.
*
* @param timestamp
* the timestamp of the actual semantic check cycle
*/
public void check(final CompilationTimeStamp timestamp) {
if (lastCheckTimeStamp != null && !lastCheckTimeStamp.isLess(timestamp)) {
return;
}
final ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
if (parser == null || identifier == null) {
lastCheckTimeStamp = timestamp;
return;
}
final Module referredModule = parser.getModuleByName(identifier.getName());
if (referredModule == null) {
identifier.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTMISSINGFRIENDMODULE, GeneralConstants.WARNING, null), MessageFormat.format(MISSINGMODULE, identifier.getDisplayName()));
} else if (!module_type.TTCN3_MODULE.equals(referredModule.getModuletype())) {
identifier.getLocation().reportSemanticError(MessageFormat.format("The friend module `{0}'' must be a TTCN-3 module", identifier.getDisplayName()));
}
lastCheckTimeStamp = timestamp;
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class Imports method checkImports.
/**
* Checks the import hierarchies of this importation (and the ones in
* the imported module recursively).
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param referenceChain
* a chain of references used to find circularly imported
* modules.
* @param moduleStack
* the stack of modules visited so far, from the starting
* point.
*/
public void checkImports(final CompilationTimeStamp timestamp, final ModuleImportationChain referenceChain, final List<Module> moduleStack) {
if (null != lastImportCheckTimeStamp && !lastImportCheckTimeStamp.isLess(timestamp)) {
return;
}
lastImportCheckTimeStamp = timestamp;
if (null == project) {
return;
}
importedModules_map.clear();
singularImportedSymbols_map.clear();
pluralImportedSymbols.clear();
final ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
if (null == parser) {
return;
}
for (ImportModule importModule : importedModules_v) {
final Identifier identifier = importModule.getIdentifier();
if (null == identifier || null == identifier.getLocation()) {
continue;
}
final Module referredModule = parser.getModuleByName(identifier.getName());
if (null == referredModule) {
identifier.getLocation().reportSemanticError(MessageFormat.format(ImportModule.MISSINGMODULE, identifier.getDisplayName()));
continue;
} else if (!(referredModule instanceof ASN1Module)) {
identifier.getLocation().reportSemanticError(TTCN3IMPORT);
continue;
} else if (referredModule == module) {
identifier.getLocation().reportSemanticError(SELFIMPORT);
continue;
}
String name = identifier.getName();
if (importedModules_map.containsKey(name)) {
final Location importedLocation = importedModules_map.get(name).getIdentifier().getLocation();
importedLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEIMPORTFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEIMPORTREPEATED, identifier.getDisplayName()));
} else {
importedModules_map.put(name, importModule);
}
final Symbols symbols = importModule.getSymbols();
if (null == symbols) {
continue;
}
for (int i = 0; i < symbols.size(); i++) {
name = symbols.getNthElement(i).getName();
if (singularImportedSymbols_map.containsKey(name)) {
if (!referredModule.equals(singularImportedSymbols_map.get(name))) {
singularImportedSymbols_map.remove(name);
pluralImportedSymbols.add(name);
}
} else if (!pluralImportedSymbols.contains(name)) {
singularImportedSymbols_map.put(name, referredModule);
}
}
importModule.setUnhandledChange(false);
LoadBalancingUtilities.astNodeChecked();
}
for (ImportModule importModule : importedModules_v) {
// check the imports recursively
referenceChain.markState();
importModule.checkImports(timestamp, referenceChain, moduleStack);
referenceChain.previousState();
}
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class Export_Debug_AST_Action method run.
@Override
public void run(IAction action) {
if (!(selection instanceof IStructuredSelection)) {
return;
}
IStructuredSelection structSelection = (IStructuredSelection) selection;
List<IProject> projects = new ArrayList<IProject>();
for (Object selected : structSelection.toList()) {
if (!(selected instanceof IProject)) {
continue;
}
projects.add((IProject) selected);
}
for (IProject project : projects) {
Shell shell = Display.getCurrent().getActiveShell();
FileDialog d = new FileDialog(shell, SWT.SAVE);
d.setText("Export debug information of the AST");
d.setFilterExtensions(new String[] { "*.zip" });
d.setFilterPath(project.getLocation().toOSString());
d.setFileName("Debug_AST.zip");
String zipFilename = d.open();
try {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFilename));
ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
Set<String> names = parser.getKnownModuleNames();
for (String name : names) {
Module module = parser.getModuleByName(name);
exportDebugAST(out, module);
}
out.close();
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
}
Aggregations