blob: 4f411024779d8d05d343065de3c8de016731f510 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*
* This copyright notice shows up in the generated Java code
*
*/
package org.eclipse.osbp.xtext.oxtype.scoping
import com.google.common.collect.Lists
import java.util.List
import org.eclipse.osbp.xtext.oxtype.oxtype.OXImportDeclaration
import org.eclipse.xtext.scoping.impl.ImportNormalizer
import org.eclipse.xtext.xtype.XImportDeclaration
import org.eclipse.xtext.xtype.XImportSection
import org.eclipse.xtext.xbase.scoping.XImportSectionNamespaceScopeProvider
@SuppressWarnings("restriction")
class OXImportSectionNamespaceScopeProvider extends XImportSectionNamespaceScopeProvider{
override List<ImportNormalizer> getImportedNamespaceResolvers(XImportSection importSection, boolean ignoreCase) {
val List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations();
val List<ImportNormalizer> result = Lists.newArrayListWithExpectedSize(importDeclarations.size());
for (XImportDeclaration imp : importDeclarations) {
if (!imp.isStatic()) {
val OXImportDeclaration decl = imp as OXImportDeclaration;
var String value = decl.getImportedFullyQualifiedName();
if (value === null)
value = imp.getImportedNamespace();
if (value === null)
value = imp.getImportedTypeName();
val ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase);
if (resolver !== null)
result.add(resolver);
}
}
return result;
}
}