1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 364920: NPE using call hierarchy

This commit is contained in:
Markus Schorn 2011-12-21 15:11:51 +01:00
parent c7803d38e9
commit 9e7125fb90

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -38,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding; import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
@ -325,7 +325,8 @@ public class CallHierarchyUI {
if (binding instanceof IVariable) { if (binding instanceof IVariable) {
try { try {
if (binding.getScope().getKind() == EScopeKind.eLocal) final IScope scope = binding.getScope();
if (scope != null && scope.getKind() == EScopeKind.eLocal)
return false; return false;
} catch (DOMException e) { } catch (DOMException e) {
} }
@ -382,8 +383,7 @@ public class CallHierarchyUI {
*/ */
static void clearHistory() { static void clearHistory() {
setHistoryEntries(new ICElement[0]); setHistoryEntries(new ICElement[0]);
for (Iterator<CHViewPart> iter= fLRUCallHierarchyViews.iterator(); iter.hasNext();) { for (CHViewPart part : fLRUCallHierarchyViews) {
CHViewPart part= iter.next();
part.setInput(null); part.setInput(null);
} }
} }
@ -396,8 +396,7 @@ public class CallHierarchyUI {
*/ */
private static CHViewPart findLRUCallHierarchyViewPart(IWorkbenchPage page) { private static CHViewPart findLRUCallHierarchyViewPart(IWorkbenchPage page) {
boolean viewFoundInPage= false; boolean viewFoundInPage= false;
for (Iterator<CHViewPart> iter= fLRUCallHierarchyViews.iterator(); iter.hasNext();) { for (CHViewPart view : fLRUCallHierarchyViews) {
CHViewPart view= iter.next();
if (page.equals(view.getSite().getPage())) { if (page.equals(view.getSite().getPage())) {
if (!view.isPinned()) { if (!view.isPinned()) {
return view; return view;
@ -408,8 +407,7 @@ public class CallHierarchyUI {
if (!viewFoundInPage) { if (!viewFoundInPage) {
// find unresolved views // find unresolved views
IViewReference[] viewReferences= page.getViewReferences(); IViewReference[] viewReferences= page.getViewReferences();
for (int i= 0; i < viewReferences.length; i++) { for (IViewReference curr : viewReferences) {
IViewReference curr= viewReferences[i];
if (CUIPlugin.ID_CALL_HIERARCHY.equals(curr.getId()) && page.equals(curr.getPage())) { if (CUIPlugin.ID_CALL_HIERARCHY.equals(curr.getId()) && page.equals(curr.getPage())) {
CHViewPart view= (CHViewPart)curr.getView(true); CHViewPart view= (CHViewPart)curr.getView(true);
if (view != null && !view.isPinned()) { if (view != null && !view.isPinned()) {