Search in sources :

Example 21 with IPreferencesService

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();
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 22 with IPreferencesService

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 23 with IPreferencesService

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();
}
Also used : ProposalCollector(org.eclipse.titan.designer.editors.ProposalCollector) IFile(org.eclipse.core.resources.IFile) Scope(org.eclipse.titan.designer.AST.Scope) Reference(org.eclipse.titan.designer.AST.Reference) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) Module(org.eclipse.titan.designer.AST.Module) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType) IDocument(org.eclipse.jface.text.IDocument) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 24 with IPreferencesService

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;
}
Also used : ProblemTypePreference(org.eclipse.titanium.preferences.ProblemTypePreference) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 25 with IPreferencesService

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;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Iterator(java.util.Iterator) ISemanticTITANEditor(org.eclipse.titan.designer.editors.ISemanticTITANEditor) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)96 IFile (org.eclipse.core.resources.IFile)26 ArrayList (java.util.ArrayList)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)14 IProject (org.eclipse.core.resources.IProject)13 CoreException (org.eclipse.core.runtime.CoreException)13 Module (org.eclipse.titan.designer.AST.Module)11 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 List (java.util.List)10 File (java.io.File)8 TextSelection (org.eclipse.jface.text.TextSelection)8 Path (org.eclipse.core.runtime.Path)6 IContainer (org.eclipse.core.resources.IContainer)5 IMarker (org.eclipse.core.resources.IMarker)5 IPath (org.eclipse.core.runtime.IPath)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4