blob: cd36aecd1afe8610332aa68573396d4e01744939 [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2007, 2019 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;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.statet.ecommons.text.IMarkerPositionResolver;
import org.eclipse.statet.ecommons.text.ui.AnnotationMarkerPositionResolver;
import org.eclipse.statet.ltk.core.LTK;
import org.eclipse.statet.ltk.core.WorkingContext;
import org.eclipse.statet.ltk.model.core.SourceDocumentRunnable;
import org.eclipse.statet.ltk.model.core.elements.ISourceUnit;
import org.eclipse.statet.ltk.model.core.elements.ISourceUnitModelInfo;
import org.eclipse.statet.ltk.model.core.elements.IWorkspaceSourceUnit;
import org.eclipse.statet.ltk.model.core.impl.GenericSourceUnitWorkingCopy2;
import org.eclipse.statet.ltk.model.core.impl.IWorkingBuffer;
import org.eclipse.statet.ltk.model.core.impl.SourceUnitModelContainer;
public abstract class GenericEditorWorkspaceSourceUnitWorkingCopy2<M extends SourceUnitModelContainer<? extends ISourceUnit, ? extends ISourceUnitModelInfo>>
extends GenericSourceUnitWorkingCopy2<M>
implements IWorkspaceSourceUnit {
public GenericEditorWorkspaceSourceUnitWorkingCopy2(final IWorkspaceSourceUnit from) {
super(from);
}
@Override
public WorkingContext getWorkingContext() {
return LTK.EDITOR_CONTEXT;
}
@Override
public IResource getResource() {
return ((IWorkspaceSourceUnit) getUnderlyingUnit()).getResource();
}
@Override
public IMarkerPositionResolver getMarkerPositionResolver() {
return AnnotationMarkerPositionResolver.createIfRequired(getResource());
}
@Override
protected IWorkingBuffer createWorkingBuffer(final SubMonitor m) {
return new FileBufferWorkingBuffer(this);
}
@Override
public void syncExec(final SourceDocumentRunnable runnable) throws InvocationTargetException {
FileBufferWorkingBuffer.syncExec(runnable);
}
}