use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ExternalTitanAction method getTITANActionFlags.
/**
* Checks the flags that can be used to configure the behavior of the
* compiler when called by the external TITAN actions.
*
* @return the flags
*/
protected final String getTITANActionFlags() {
final StringBuilder builder = new StringBuilder();
final IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.TITANACTIONS_DEFAULT_AS_OMIT, false, null)) {
builder.append('d');
}
return builder.toString();
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class Configuration method getReconciler.
@Override
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
if (reconciler == null) {
ReconcilingStrategy strategy = new ReconcilingStrategy();
strategy.setEditor(editor);
strategy.analyze(true);
editor.setReconciler(strategy);
reconciler = new MonoReconciler(strategy, false);
reconciler.setProgressMonitor(new NullProgressMonitor());
IPreferencesService prefs = Platform.getPreferencesService();
int timeout = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.RECONCILERTIMEOUT, 1, null);
reconciler.setDelay(timeout * 1000);
}
return reconciler;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ContentAssistProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
IDocument doc = viewer.getDocument();
IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
ASN1ReferenceParser refParser = new ASN1ReferenceParser();
Reference ref = refParser.findReferenceForCompletion(file, offset, doc);
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
TITANDebugConsole.println("parsed the reference: " + ref);
}
if (ref == null || ref.getSubreferences().isEmpty()) {
return new ICompletionProposal[] {};
}
Scope scope = null;
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
Module tempModule = projectSourceParser.containedModule(file);
if (tempModule != null) {
scope = tempModule.getSmallestEnclosingScope(refParser.getReplacementOffset());
ref.setMyScope(scope);
ref.detectModid();
}
TemplateContextType contextType = new TemplateContextType(ASN1CodeSkeletons.CONTEXT_IDENTIFIER, ASN1CodeSkeletons.CONTEXT_NAME);
ProposalCollector propCollector = new ProposalCollector(Identifier_type.ID_ASN, ASN1CodeSkeletons.CONTEXT_IDENTIFIER, contextType, doc, ref, refParser.getReplacementOffset());
if (scope != null) {
scope.addProposal(propCollector);
propCollector.sortTillMarked();
propCollector.markPosition();
}
if (ref.getSubreferences().size() != 1) {
return propCollector.getCompletitions();
}
if (scope == null) {
propCollector.addProposal(CodeScanner.TAGS, null, KEYWORD);
} else {
ASN1CodeSkeletons.addSkeletonProposals(doc, refParser.getReplacementOffset(), propCollector);
}
propCollector.sortTillMarked();
propCollector.markPosition();
propCollector.addProposal(CodeScanner.VERBS, null, KEYWORD);
propCollector.addProposal(CodeScanner.COMPARE_TYPES, null, KEYWORD);
propCollector.addProposal(CodeScanner.STATUS_TYPE, null, KEYWORD);
propCollector.addProposal(CodeScanner.KEYWORDS, null, KEYWORD);
propCollector.addProposal(CodeScanner.STORAGE, null, KEYWORD);
propCollector.addProposal(CodeScanner.MODIFIER, null, KEYWORD);
propCollector.addProposal(CodeScanner.ACCESS_TYPE, null, KEYWORD);
propCollector.sortTillMarked();
String sortingpolicy = Activator.getDefault().getPreferenceStore().getString(PreferenceConstants.CONTENTASSISTANT_PROPOSAL_SORTING);
if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
propCollector.sortAll();
}
return propCollector.getCompletitions();
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class AnalyzerBuilder method adaptPreferences.
public AnalyzerBuilder adaptPreferences() {
if (exhausted) {
throw new IllegalStateException("One must not use the builder after build() method is called");
}
actions.clear();
projectActions.clear();
final IPreferencesService prefs = Platform.getPreferencesService();
for (final ProblemTypePreference prefType : ProblemTypePreference.values()) {
final String prefName = prefType.getPreferenceName();
final String warnLevel = prefs.getString(Activator.PLUGIN_ID, prefName, GeneralConstants.IGNORE, null);
if (!GeneralConstants.IGNORE.equals(warnLevel)) {
addPreferenceProblem(prefType);
}
}
return this;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ProjectSourceParser method analyzeAllOnlySyntactically.
/**
* Analyzes all of the files which are in the project, but only
* syntactically.
* <ul>
* <li>the files possibly needed to analyze are collected first
* <li>those files, which are known to be up-to-date are filtered from
* this list
* <li>the files left in the list are analyzed in a new workspace job
* </ul>
*
* @return the WorkspaceJob in which the operation is running
*/
public WorkspaceJob analyzeAllOnlySyntactically() {
IPreferencesService prefs = Platform.getPreferencesService();
if (!prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
return null;
}
final WorkspaceJob op = new WorkspaceJob(SOURCE_ANALYSING) {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
IStatus result = Status.OK_STATUS;
if (!project.isAccessible() || !TITANNature.hasTITANNature(project)) {
syntaxAnalyzersRunning.decrementAndGet();
return Status.CANCEL_STATUS;
}
if (!LicenseValidator.check()) {
syntaxAnalyzersRunning.decrementAndGet();
return Status.CANCEL_STATUS;
}
if (monitor.isCanceled()) {
syntaxAnalyzersRunning.decrementAndGet();
return Status.CANCEL_STATUS;
}
final int priority = getThread().getPriority();
try {
getThread().setPriority(Thread.MIN_PRIORITY);
long absoluteStart = System.nanoTime();
IPreferencesService preferenceService = Platform.getPreferencesService();
String compilerOption = preferenceService.getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.COMPILERMARKERSAFTERANALYZATION, PreferenceConstantValues.COMPILEROPTIONOUTDATE, null);
if (PreferenceConstantValues.COMPILEROPTIONREMOVE.equals(compilerOption)) {
ParserMarkerSupport.removeAllCompilerMarkers(project);
} else if (PreferenceConstantValues.COMPILEROPTIONOUTDATE.equals(compilerOption)) {
for (Iterator<IFile> iterator = EditorTracker.keyset().iterator(); iterator.hasNext(); ) {
IFile file = iterator.next();
if (file.getProject() == project) {
ISemanticTITANEditor editor = EditorTracker.getEditor(file).get(0);
MarkerHandler.deprecateMarkers(editor, ParserMarkerSupport.getAllCompilerMarkers(project));
}
}
}
syntacticAnalyzer.internalDoAnalyzeSyntactically2(monitor);
boolean reportDebugInformation = preferenceService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
if (reportDebugInformation) {
// MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream(); //only once called
TITANDebugConsole.println("The whole syntax only analysis block took " + (System.nanoTime() - absoluteStart) * (1e-9) + " seconds to complete");
}
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
} finally {
syntaxAnalyzersRunning.decrementAndGet();
getThread().setPriority(priority);
}
return result;
}
};
op.setPriority(Job.LONG);
IPreferencesService preferenceService = Platform.getPreferencesService();
if (GeneralConstants.DEBUG && preferenceService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
op.setSystem(false);
op.setUser(true);
} else {
op.setSystem(true);
op.setUser(false);
}
op.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
op.setRule(getSchedulingRule());
if (syntaxAnalyzersRunning.get() > 0) {
if (lastSyntaxAnalyzes != null && lastSyntaxAnalyzes.getState() != Job.RUNNING) {
lastSyntaxAnalyzes.cancel();
}
}
op.schedule();
lastSyntaxAnalyzes = op;
syntaxAnalyzersRunning.incrementAndGet();
return op;
}
Aggregations