Skip to main content
summaryrefslogtreecommitdiffstats
blob: 76f3ef201bbbdf6958152e70579e38b0e68c8d2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * 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
 *
 * generated by Xtext 2.11.0
 */
package org.eclipse.osbp.xtext.oxtype.ui.quickfix;

import org.eclipse.osbp.xtext.oxtype.oxtype.OXImportDeclaration;
import org.eclipse.xtext.util.IAcceptor;
import org.eclipse.xtext.xbase.ui.quickfix.JavaTypeQuickfixes;
import org.eclipse.xtext.xtype.XImportDeclaration;
import org.eclipse.xtext.xtype.XImportSection;

@SuppressWarnings("restriction")
public class CustomJavaTypeQuickfixes extends JavaTypeQuickfixes {

	protected void parseImportSection(XImportSection importSection,
			IAcceptor<String> visiblePackages, IAcceptor<String> importedTypes) {
		for (XImportDeclaration importDeclaration : importSection
				.getImportDeclarations()) {
			if (!importDeclaration.isStatic()) {

				// do not use fqn imports
				if (importDeclaration instanceof OXImportDeclaration) {
					OXImportDeclaration oxImportDecl = (OXImportDeclaration) importDeclaration;
					if (oxImportDecl.isFqnImport()) {
						continue;
					}
				}

				if (importDeclaration.getImportedNamespace() != null) {
					String importedAsString = importDeclaration
							.getImportedNamespace();
					if (importDeclaration.isWildcard()) {
						importedAsString = importedAsString.substring(0,
								importedAsString.length() - 2);
						visiblePackages.accept(importedAsString);
					} else {
						importedTypes.accept(importedAsString);
					}
				} else {
					importedTypes.accept(importDeclaration
							.getImportedTypeName());
				}
			}
		}
	}
}

Back to the top