use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class ProjectHandlingLibrary method analyzeProject.
/**
* Starts the analysis of its project and waits until it finishes.
*/
public void analyzeProject() {
LOGGER.info("Analyzing project: " + project.getName());
ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(project);
WorkspaceJob semanticInfoCleanerJob = sourceParser.clearSemanticInformation();
try {
semanticInfoCleanerJob.join();
} catch (InterruptedException e1) {
ErrorReporter.logExceptionStackTrace("", e1);
}
GlobalParser.clearAllInformation();
LOGGER.info("Semantic analysis started on: " + project.getName());
WorkspaceJob job = sourceParser.analyzeAll();
for (int i = 0; i < 10 && job == null; ++i) {
try {
Thread.sleep(500);
job = sourceParser.analyzeAll();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("", e);
}
}
if (job != null) {
try {
job.join();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("", e);
}
} else {
LOGGER.severe("Couldn't analyze the project");
}
LOGGER.info("Semantic analysis finished on: " + project.getName());
try {
// Wait for the markers to show up
Thread.sleep(5000);
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("", e);
}
LOGGER.info("Project analyzed: " + project.getName());
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class ReferenceSearch method runAction.
/**
* Helper function used by FindReferences classes for TTCN-3, ASN.1 and
* TTCNPP editors
*/
public static void runAction(final IEditorPart targetEditor, final ISelection selection) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(FILENOTIDENTIFIABLE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
int offset;
if (selection instanceof TextSelection && !selection.isEmpty() && !"".equals(((TextSelection) selection).getText())) {
if (reportDebugInformation) {
TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
}
TextSelection tSelection = (TextSelection) selection;
offset = tSelection.getOffset() + tSelection.getLength();
} else {
offset = ((IEditorWithCarretOffset) targetEditor).getCarretOffset();
}
// find the module
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
if (ResourceExclusionHelper.isExcluded(file)) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(MessageFormat.format(EXCLUDEDFROMBUILD, file.getFullPath()));
return;
}
final Module module = projectSourceParser.containedModule(file);
if (module == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(MessageFormat.format(NOTFOUNDMODULE, file.getName()));
return;
}
final ReferenceFinder rf = new ReferenceFinder();
boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation);
if (!isDetected) {
return;
}
final ReferenceSearchQuery query = new ReferenceSearchQuery(rf, module, file.getProject());
for (ISearchQuery runningQuery : NewSearchUI.getQueries()) {
NewSearchUI.cancelQuery(runningQuery);
}
NewSearchUI.runQueryInBackground(query);
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class NewTTCN3ModuleCreationWizardPage method validatePage.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#validatePage()
*/
@Override
protected boolean validatePage() {
if (!super.validatePage()) {
return false;
}
final String extension = getContainerFullPath().append(getFileName()).getFileExtension();
if (extension == null) {
// test what will happen if we add the extension
IPath fullPath = getContainerFullPath().append(getFileName()).addFileExtension(GlobalParser.SUPPORTED_TTCN3_EXTENSIONS[1]);
// path is invalid if any prefix is occupied by a file
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
while (fullPath.segmentCount() > 1) {
if (root.getFile(fullPath).exists()) {
setErrorMessage(OCCUPIED);
return false;
}
fullPath = fullPath.removeLastSegments(1);
}
} else {
// test the extension
if (!GlobalParser.isSupportedTTCN3Extension(extension)) {
setErrorMessage(ERROR_MESSAGE);
return false;
}
}
// check modulename
final IPath path = getContainerFullPath();
if (hasLicense && path != null) {
final IFile file = createFileHandle(path.append(getFileName()));
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
if (projectSourceParser.getLastTimeChecked() == null) {
final WorkspaceJob job = projectSourceParser.analyzeAll();
if (job != null) {
try {
job.join();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
}
final String moduleName = getFileName();
final int dotIndex = moduleName.indexOf('.');
final String dotLessModuleName = dotIndex == -1 ? moduleName : moduleName.substring(0, dotIndex);
final Module module = projectSourceParser.getModuleByName(dotLessModuleName);
if (module != null) {
setErrorMessage("A module with the name " + moduleName + " already exists in the project " + file.getProject().getName());
return false;
}
}
return validateName();
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method handleModuleParameters.
/**
* Selects and reveals the selected module parameter.
*
* @param file
* The current file.
* @param offset
* The position of the cursor.
* @param document
* The document opened in the configuration file editor.
* @return True
*/
public boolean handleModuleParameters(final IFile file, final int offset, final IDocument document) {
ConfigReferenceParser refParser = new ConfigReferenceParser(false);
Reference reference = refParser.findReferenceForOpening(file, offset, document);
if (refParser.isModuleParameter()) {
if (reference == null) {
return false;
}
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
String exactModuleName = refParser.getExactModuleName();
ArrayList<Assignment> foundAssignments = new ArrayList<Assignment>();
if (exactModuleName != null) {
Module module = projectSourceParser.getModuleByName(exactModuleName);
if (module != null) {
Assignments assignments = module.getAssignments();
for (int i = 0; i < assignments.getNofAssignments(); i++) {
Assignment assignment = assignments.getAssignmentByIndex(i);
if (assignment.getIdentifier().getDisplayName().equals(reference.getId().getDisplayName())) {
foundAssignments.add(assignment);
}
}
}
} else {
for (String moduleName : projectSourceParser.getKnownModuleNames()) {
Module module = projectSourceParser.getModuleByName(moduleName);
if (module != null) {
Assignments assignments = module.getAssignments();
for (int i = 0; i < assignments.getNofAssignments(); i++) {
Assignment assignment = assignments.getAssignmentByIndex(i);
if (assignment.getIdentifier().getDisplayName().equals(reference.getId().getDisplayName())) {
foundAssignments.add(assignment);
}
}
}
}
}
if (foundAssignments.isEmpty()) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOTMODULEPARDECLARATION);
return false;
}
// List<DeclarationCollectionHelper> collected = declarationCollector.getCollected();
// DeclarationCollectionHelper declaration = null;
Assignment assignment = null;
if (foundAssignments.size() == 1) {
assignment = foundAssignments.get(0);
} else {
Assignment result = openCollectionListDialog(foundAssignments);
if (result != null) {
assignment = result;
}
}
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
for (Assignment tempAssignment : foundAssignments) {
Location location = tempAssignment.getLocation();
TITANDebugConsole.println("Module parameter: " + location.getFile() + ":" + location.getOffset() + "-" + location.getEndOffset());
}
}
if (assignment != null) {
Location location = assignment.getLocation();
selectAndRevealRegion((IFile) location.getFile(), location.getOffset(), location.getEndOffset(), true);
}
return true;
}
return false;
}
use of org.eclipse.titan.designer.parsers.ProjectSourceParser in project titan.EclipsePlug-ins by eclipse.
the class ReconcilingStrategy method analyze.
void analyze() {
final IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
return;
}
IProject project = file.getProject();
if (project == null) {
return;
}
ProjectConfigurationParser projectConfigurationParser = GlobalParser.getConfigSourceParser(project);
projectConfigurationParser.reportOutdating(file);
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
projectSourceParser.analyzeAll();
}
Aggregations