use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ProjectSourceSyntacticAnalyzer method reportOutdating.
/**
* Reports that the contents of the provided folder has changed and so
* it's stored information became out of date.
* <p>
* Stores that every file in this folder is out of date for later
* <p>
*
* @param outdatedFolder
* the folder whose files seems to have changed
*/
public void reportOutdating(final IFolder outdatedFolder) {
final IPath folderPath = outdatedFolder.getProjectRelativePath();
final IPreferencesService service = Platform.getPreferencesService();
final boolean useOnTheFlyParsing = service.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null);
synchronized (this) {
syntacticallyOutdated = true;
for (Iterator<IFile> iterator = uptodateFiles.keySet().iterator(); iterator.hasNext(); ) {
IFile tempFile = iterator.next();
IPath filepath = tempFile.getProjectRelativePath();
if (folderPath.isPrefixOf(filepath)) {
sourceParser.getSemanticAnalyzer().reportOutdating(tempFile, useOnTheFlyParsing);
iterator.remove();
unsupportedConstructMap.remove(tempFile);
}
}
for (Iterator<IFile> iterator = highlySyntaxErroneousFiles.iterator(); iterator.hasNext(); ) {
IFile tempFile = iterator.next();
IPath filepath = tempFile.getProjectRelativePath();
if (folderPath.isPrefixOf(filepath)) {
iterator.remove();
}
}
}
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ProjectSourceSyntacticAnalyzer method reportOutdating.
/**
* Reports that the provided file has changed and so it's stored
* information became out of date.
* <p>
* Stores that this file is out of date for later usage
* <p>
*
* @param outdatedFile
* the file which seems to have changed
*/
public void reportOutdating(final IFile outdatedFile) {
final IPreferencesService service = Platform.getPreferencesService();
final boolean useOnTheFlyParsing = service.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null);
synchronized (this) {
syntacticallyOutdated = true;
if (uptodateFiles.containsKey(outdatedFile)) {
uptodateFiles.remove(outdatedFile);
unsupportedConstructMap.remove(outdatedFile);
}
if (highlySyntaxErroneousFiles.contains(outdatedFile)) {
highlySyntaxErroneousFiles.remove(outdatedFile);
}
sourceParser.getSemanticAnalyzer().reportOutdating(outdatedFile, useOnTheFlyParsing);
}
}
use of org.eclipse.core.runtime.preferences.IPreferencesService 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.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class RenameRefactoring method checkInitialConditions.
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException {
// for debugging
// ScopeHierarchyVisitor v = new ScopeHierarchyVisitor();
// module.accept(v);
// TITANDebugConsole.getConsole().newMessageStream().println(v.getScopeTreeAsHTMLPage());
RefactoringStatus result = new RefactoringStatus();
try {
pm.beginTask("Checking preconditions...", 2);
// PreferenceConstants.USEONTHEFLYPARSING
final IPreferencesService prefs = Platform.getPreferencesService();
if (!prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, false, null)) {
result.addFatalError(ONTHEFLYANALAYSISDISABLED);
}
// check that there are no ttcnpp files in the project
if (hasTtcnppFiles(file.getProject())) {
// FIXME actually all referencing and referenced projects need to be checked too !
result.addError(MessageFormat.format(PROJECTCONTAINSTTCNPPFILES, file.getProject()));
}
pm.worked(1);
// Check that there are no syntactic, semantic or mixed error markers in the project. Compilation error does not matter
IProject project = file.getProject();
if (projectHasOnTheFlyError(project)) {
result.addError(MessageFormat.format(PROJECTCONTAINSERRORS, project));
}
pm.worked(1);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
result.addFatalError(e.getMessage());
} finally {
pm.done();
}
return result;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService 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;
}
Aggregations