From e8a9e67b8cd5023a26ce824c6d27b4e4d28c2910 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 24 Jan 2012 21:53:30 -0500 Subject: [PATCH 1/2] Bug 369583: [junit] Sessionless tests fail with NPE --- .../commands/TestMIBreakInsertCommand.java | 17 ++++++++++++---- .../TestMICommandConstructCommand.java | 20 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java index f4c416fa94f..d12153056ab 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Ericsson and others. + * Copyright (c) 2008, 2012 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,14 +7,18 @@ * * Contributors: * Ericsson - Initial Implementation + * Marc Khouzam (Ericsson) - Fix NPE (bug 369583) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.commands; import static org.junit.Assert.assertEquals; +import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; -import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControlDMContext; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.junit.Test; /** @@ -46,15 +50,20 @@ public class TestMIBreakInsertCommand { } private class TestContext implements IBreakpointsTargetDMContext { + private DsfSession session = null; + public TestContext() { + session = DsfSession.startSession(new DefaultDsfExecutor(TestsPlugin.PLUGIN_ID), TestsPlugin.PLUGIN_ID); + } + @Override public IDMContext[] getParents() { - return null; + return new IDMContext[] {new GDBControlDMContext(getSessionId(), "1")}; } @Override public String getSessionId() { - return null; + return session.getId(); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java index e3559fee57e..1d085f44105 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Ericsson and others. + * Copyright (c) 2008, 2012 Ericsson and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,14 +7,20 @@ * * Contributors: * Ericsson - Initial Implementation + * Marc Khouzam (Ericsson) - Fix NPE (bug 369583) *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.commands; import static org.junit.Assert.assertEquals; +import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; import org.eclipse.cdt.dsf.datamodel.IDMContext; +import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControlDMContext; import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.junit.Test; /** @@ -46,16 +52,21 @@ public class TestMICommandConstructCommand { result); } - private class TestContext implements IDMContext { + private class TestContext implements IBreakpointsTargetDMContext { + private DsfSession session = null; + public TestContext() { + session = DsfSession.startSession(new DefaultDsfExecutor(TestsPlugin.PLUGIN_ID), TestsPlugin.PLUGIN_ID); + } + @Override public IDMContext[] getParents() { - return null; + return new IDMContext[] {new GDBControlDMContext(getSessionId(), "1")}; } @Override public String getSessionId() { - return null; + return session.getId(); } @Override @@ -63,7 +74,6 @@ public class TestMICommandConstructCommand { public Object getAdapter(Class adapter) { return null; } - } } From a6ca3ea2353f3b2ef221296a45ee4f43481991ca Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Wed, 25 Jan 2012 11:20:39 -0500 Subject: [PATCH 2/2] bug 369693: Using a workspace root as include paths causes NPE in Project Explorer --- .../eclipse/cdt/internal/ui/cview/CViewLabelProvider.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java index 5608d8a5ef6..156a062bdfe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java @@ -111,11 +111,12 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider { String imageKey = null; if (element instanceof IncludeReferenceProxy) { IIncludeReference reference = ((IncludeReferenceProxy)element).getReference(); - IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath()); - if (container != null) { + IContainer containerInclude = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(reference.getPath()); + if (containerInclude != null) { ICProject cproject = reference.getCProject(); IProject project = (cproject != null) ? cproject.getProject() : null; - boolean isProjectRelative = container.getProject().equals(project); + IProject projectInclude = containerInclude.getProject(); + boolean isProjectRelative = projectInclude != null && projectInclude.equals(project); imageKey = LanguageSettingsImages.getImageKey(ICSettingEntry.INCLUDE_PATH, ICSettingEntry.VALUE_WORKSPACE_PATH, isProjectRelative); } else { imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;