| /*=============================================================================# |
| # Copyright (c) 2009, 2020 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.ltk.ui.sourceediting; |
| |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.jface.text.IDocument; |
| import org.eclipse.jface.text.IRegion; |
| import org.eclipse.jface.text.reconciler.DirtyRegion; |
| import org.eclipse.jface.text.reconciler.IReconcilingStrategy; |
| import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension; |
| |
| import org.eclipse.statet.ltk.model.core.ModelManager; |
| import org.eclipse.statet.ltk.model.core.element.SourceUnit; |
| import org.eclipse.statet.ltk.ui.sourceediting.EcoReconciler2.ISourceUnitStrategy; |
| |
| |
| public class SourceUnitReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension, ISourceUnitStrategy { |
| |
| |
| private SourceUnit input; |
| |
| private final int flags; |
| |
| private IProgressMonitor monitor; |
| |
| |
| public SourceUnitReconcilingStrategy() { |
| this(ModelManager.MODEL_DEPENDENCIES | ModelManager.RECONCILE); |
| } |
| |
| public SourceUnitReconcilingStrategy(final int flags) { |
| this.flags= flags; |
| } |
| |
| |
| @Override |
| public void initialReconcile() { |
| reconcile(); |
| } |
| |
| @Override |
| public void setDocument(final IDocument document) { |
| } |
| |
| @Override |
| public void setInput(final SourceUnit input) { |
| this.input= input; |
| } |
| |
| @Override |
| public void reconcile(final IRegion partition) { |
| reconcile(); |
| } |
| |
| @Override |
| public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) { |
| reconcile(); |
| } |
| |
| @Override |
| public void setProgressMonitor(final IProgressMonitor monitor) { |
| this.monitor= monitor; |
| } |
| |
| |
| protected void reconcile() { |
| final SourceUnit su= this.input; |
| if (this.monitor.isCanceled()) { |
| return; |
| } |
| su.getModelInfo(null, this.flags, this.monitor); |
| } |
| |
| } |