Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 246650
Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/PackageBinding.java (-1 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-22 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
import java.util.List;
15
import java.util.List;
16
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
16
import org.eclipse.jdt.core.ICompilationUnit;
19
import org.eclipse.jdt.core.ICompilationUnit;
17
import org.eclipse.jdt.core.IJavaElement;
20
import org.eclipse.jdt.core.IJavaElement;
18
import org.eclipse.jdt.core.IPackageFragment;
21
import org.eclipse.jdt.core.IPackageFragment;
19
import org.eclipse.jdt.core.IPackageFragmentRoot;
22
import org.eclipse.jdt.core.IPackageFragmentRoot;
23
import org.eclipse.jdt.core.JavaCore;
20
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.JavaModelException;
21
25
22
import org.eclipse.jdt.core.compiler.CharOperation;
26
import org.eclipse.jdt.core.compiler.CharOperation;
Lines 191-200 Link Here
191
	public IJavaElement getJavaElement() {
195
	public IJavaElement getJavaElement() {
192
		INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; // a package binding always has a LooupEnvironment set
196
		INameEnvironment nameEnvironment = this.binding.environment.nameEnvironment; // a package binding always has a LooupEnvironment set
193
		if (!(nameEnvironment instanceof SearchableEnvironment)) return null;
197
		if (!(nameEnvironment instanceof SearchableEnvironment)) return null;
198
		// this is not true in standalone DOM/AST
194
		NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup;
199
		NameLookup nameLookup = ((SearchableEnvironment) nameEnvironment).nameLookup;
195
		if (nameLookup == null) return null;
200
		if (nameLookup == null) return null;
196
		IJavaElement[] pkgs = nameLookup.findPackageFragments(getName(), false/*exact match*/);
201
		IJavaElement[] pkgs = nameLookup.findPackageFragments(getName(), false/*exact match*/);
197
		if (pkgs == null) return null;
202
		if (pkgs == null) return null;
203
		if (pkgs.length == 0) {
204
			// add additional tracing as this should not happen
205
			org.eclipse.jdt.internal.core.util.Util.log(
206
				new Status(
207
						IStatus.WARNING,
208
						JavaCore.PLUGIN_ID,
209
						"Searching for package " + getName() + " returns an empty array")); //$NON-NLS-1$ //$NON-NLS-2$
210
			return null;
211
		}
198
		return pkgs[0];
212
		return pkgs[0];
199
	}
213
	}
200
214

Return to bug 246650