blob: 903f738f5b5a2c071f406f948992c9d93a5ededc [file] [log] [blame]
/*=============================================================================#
# 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.model.core;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.statet.ltk.core.WorkingContext;
import org.eclipse.statet.ltk.model.core.elements.ISourceUnit;
/**
* Manages shared instances of source units.
*/
public interface ISourceUnitManager {
/**
* Returns the source unit for the given object in the given LTK model and working context.
*
* The supported object types depends on the model and working context. Typically for
* the workspace context it is IFile, for the editor context an existing source unit
* (a working copy is created) or IFileStore (URI).
* The returned source unit is already connected. If it is a working copy of an existing source
* unit (if <code>from</code> was instance of ISourceUnit), the parent is disconnected.
*
* @param modelTypeId the model type id
* @param context the working context
* @param from the object to get the source unit for
* @param create whether a new source unit object should be created, if it does not yet exists
* @param monitor
* @return the source unit or <code>null</code>
*/
ISourceUnit getSourceUnit(String modelTypeId, WorkingContext context, Object from,
boolean create, IProgressMonitor monitor);
ISourceUnit getSourceUnit(WorkingContext context, Object from, IContentType contentType,
boolean create, IProgressMonitor monitor);
List<ISourceUnit> getOpenSourceUnits(String modelTypeId, WorkingContext context);
List<ISourceUnit> getOpenSourceUnits(List<String> modelTypeIds, WorkingContext context);
List<ISourceUnit> getOpenSourceUnits(List<String> modelTypeIds, WorkingContext context,
Object from);
}