Java tutorial
/** * <copyright> * * Copyright (c) 2015 PlugBee. All rights reserved. * * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Amine Lajmi - Initial API and implementation * * </copyright> */ package org.dslforge.xtext.common.scoping; import java.util.Collections; import java.util.List; import org.eclipse.xtext.resource.IContainer; import org.eclipse.xtext.resource.IResourceDescription; import org.eclipse.xtext.resource.IResourceDescriptions; import org.eclipse.xtext.resource.containers.IAllContainersState; import org.eclipse.xtext.resource.containers.IContainerState; import org.eclipse.xtext.resource.containers.StateBasedContainerManager; import com.google.common.collect.Lists; /** * * @author Amine Lajmi * */ public class BasicTextContainerManager extends StateBasedContainerManager { private IResourceDescription description; @Override public List<IContainer> getVisibleContainers(IResourceDescription desc, IResourceDescriptions resourceDescriptions) { description = desc; return super.getVisibleContainers(desc, resourceDescriptions); } protected List<IContainer> getVisibleContainers(List<String> handles, IResourceDescriptions resourceDescriptions) { if (handles.isEmpty()) return Collections.emptyList(); List<IContainer> result = Lists.newArrayListWithExpectedSize(handles.size() + 1); String handle = internalGetContainerHandle(description, resourceDescriptions); IContainer container = newContainer(handle, resourceDescriptions); result.add(container); return result; } protected IContainer newContainer(String handle, IResourceDescriptions resourceDescriptions) { IAllContainersState state = getState(resourceDescriptions); IContainerState containerState = new BasicTextContainerState(handle, state); BasicTextContainer result = new BasicTextContainer(resourceDescriptions, containerState); return result; } }