Search in sources :

Example 36 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();
        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 37 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class DocumentSetupParticipant method setup.

/*
	 * (non-Javadoc)
	 *
	 * @see
	 * org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.
	 * eclipse.jface.text.IDocument)
	 */
@Override
public void setup(final IDocument document) {
    EditorTracker.remove(editor);
    EditorTracker.put((IFile) editor.getEditorInput().getAdapter(IFile.class), editor);
    DocumentTracker.put((IFile) editor.getEditorInput().getAdapter(IFile.class), document);
    IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(), PartitionScanner.PARTITION_TYPES);
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        extension3.setDocumentPartitioner(PartitionScanner.ASN1_PARTITIONING, partitioner);
    } else {
        document.setDocumentPartitioner(partitioner);
    }
    partitioner.connect(document);
    document.addDocumentListener(new IDocumentListener() {

        @Override
        public void documentAboutToBeChanged(final DocumentEvent event) {
            GlobalIntervalHandler.putInterval(event.getDocument(), null);
        }

        @Override
        public void documentChanged(final DocumentEvent event) {
            IPreferencesService prefs = Platform.getPreferencesService();
            if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
                analyze(document, false);
            }
        }
    });
    analyze(document, true);
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 38 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class ConfigReferenceParser method findReferenceForOpening.

@Override
public Reference findReferenceForOpening(final IFile file, final int offset, final IDocument document) {
    Reference reference = null;
    int ofs = offset - 1;
    int endoffset = offset;
    if (-1 == offset) {
        return reference;
    }
    try {
        int tempOfs = referenceStartOffset(ofs, document);
        if (-1 == tempOfs) {
            return reference;
        }
        ofs = tempOfs + 1;
        char currentChar = document.getChar(endoffset);
        while (endoffset < document.getLength()) {
            if (!Character.isLetterOrDigit(currentChar) && currentChar != '*' && currentChar != '_' && currentChar != '.') {
                break;
            }
            currentChar = document.getChar(++endoffset);
        }
        if (!moduleParameter) {
            defineName = document.get(ofs, endoffset - ofs);
            return null;
        }
        String selected = document.get(ofs, endoffset - ofs);
        String parameter = selected;
        int dotIndex = selected.indexOf('.');
        if (dotIndex > 0) {
            String moduleName = selected.substring(0, dotIndex);
            if (!"*".equals(moduleName)) {
                exactModuleName = moduleName;
                IPreferencesService prefs = Platform.getPreferencesService();
                if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
                    TITANDebugConsole.println("Module: " + exactModuleName);
                }
            }
            parameter = selected.substring(dotIndex + 1);
        }
        TTCN3ReferenceAnalyzer refAnalyzer = new TTCN3ReferenceAnalyzer();
        reference = refAnalyzer.parse(file, parameter, reportErrors, document.getLineOfOffset(ofs) + 1, ofs);
    } catch (BadLocationException e) {
        ErrorReporter.logExceptionStackTrace(e);
    }
    return reference;
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) TTCN3ReferenceAnalyzer(org.eclipse.titan.designer.parsers.ttcn3parser.TTCN3ReferenceAnalyzer) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 39 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class InsertFieldRefactoring method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final 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.addError(ONTHEFLYANALAYSISDISABLED);
        }
        // project
        for (IProject project : projects) {
            if (hasTtcnppFiles(project)) {
                result.addError(MessageFormat.format(PROJECTCONTAINSTTCNPPFILES, project));
            }
        }
        pm.worked(1);
        // project
        for (IProject project : projects) {
            final IMarker[] markers = project.findMarkers(null, true, IResource.DEPTH_INFINITE);
            for (IMarker marker : markers) {
                if (IMarker.SEVERITY_ERROR == marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR)) {
                    result.addError(MessageFormat.format(PROJECTCONTAINSERRORS, project));
                    break;
                }
            }
        }
        pm.worked(1);
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        result.addFatalError(e.getMessage());
    } finally {
        pm.done();
    }
    return result;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IMarker(org.eclipse.core.resources.IMarker) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) IProject(org.eclipse.core.resources.IProject)

Example 40 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class ReconcilingStrategy method fullReconciliation.

private void fullReconciliation(final boolean isInitial) {
    actualCode = new StringBuilder(document.get());
    GlobalIntervalHandler.putInterval(document, null);
    IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
        analyze(isInitial);
    } else {
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                List<Position> positions = (new TTCN3FoldingSupport()).calculatePositions(document);
                editor.updateFoldingStructure(positions);
                editor.updateOutlinePage();
            }
        });
    }
}
Also used : List(java.util.List) TTCN3FoldingSupport(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3FoldingSupport) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

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