| /*=============================================================================# |
| # Copyright (c) 2008, 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.internal.r.core.sourcemodel; |
| |
| import java.util.Collections; |
| import java.util.LinkedHashMap; |
| import java.util.Map; |
| |
| import org.eclipse.statet.ltk.ast.core.AstInfo; |
| import org.eclipse.statet.ltk.model.core.impl.AbstractSourceModelInfo; |
| import org.eclipse.statet.r.core.model.IRFrame; |
| import org.eclipse.statet.r.core.model.IRFrameInSource; |
| import org.eclipse.statet.r.core.model.IRLangSourceElement; |
| import org.eclipse.statet.r.core.model.IRModelInfo; |
| |
| |
| public class RSourceModelInfo extends AbstractSourceModelInfo implements IRModelInfo { |
| |
| |
| final BuildSourceFrame topFrame; |
| final LinkedHashMap<String, BuildSourceFrame> localFrames; |
| private final Map<String, BuildSourceFrame> protectedLocalFrames; |
| |
| final PackageReferences packageRefs; |
| final Map<String, BuildSourceFrame> namespaceFrames; |
| private final Map<String, BuildSourceFrame> protectedNamespaceFrames; |
| |
| private final IRLangSourceElement sourceElement; |
| |
| |
| RSourceModelInfo(final AstInfo ast, |
| final LinkedHashMap<String, BuildSourceFrame> localFrames, |
| final BuildSourceFrame topFrame, |
| final PackageReferences packageRefs, |
| final Map<String, BuildSourceFrame> namespaceFrames, |
| final IRLangSourceElement unitElement) { |
| super(ast); |
| this.topFrame= topFrame; |
| this.localFrames= localFrames; |
| this.protectedLocalFrames= Collections.unmodifiableMap(localFrames); |
| this.packageRefs= packageRefs; |
| this.namespaceFrames= namespaceFrames; |
| this.protectedNamespaceFrames= Collections.unmodifiableMap(namespaceFrames); |
| this.sourceElement= unitElement; |
| } |
| |
| |
| @Override |
| public IRLangSourceElement getSourceElement() { |
| return this.sourceElement; |
| } |
| |
| @Override |
| public BuildSourceFrame getTopFrame() { |
| return this.topFrame; |
| } |
| |
| @Override |
| public final Map<String, ? extends IRFrameInSource> getSourceFrames() { |
| return this.protectedLocalFrames; |
| } |
| |
| @Override |
| public PackageReferences getReferencedPackages() { |
| return this.packageRefs; |
| } |
| |
| @Override |
| public final Map<String, ? extends IRFrame> getReferencedFrames() { |
| return this.protectedNamespaceFrames; |
| } |
| |
| } |