From 86e275f960d6a397c47e8cf41b8b9e3d7575d610 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Mon, 26 Mar 2007 14:07:02 +0000 Subject: [PATCH] Fix for 179170: NPE when opening C/C++ Projects view --- .../src/org/eclipse/cdt/core/CCorePlugin.java | 13 ++++++------- .../eclipse/cdt/internal/core/CContentTypes.java | 5 ++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 940d9e4e1af..be865101187 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -1030,20 +1030,19 @@ public class CCorePlugin extends Plugin { // } /** - * Helper function, returning the contenttype for a filename - * Same as:

+ * Helper function, returning the content type for a filename + * Same as:

 	 * 	getContentType(null, filename)
-	 * 
- * @param project - * @param name - * @return + *
+ * @param filename + * @return the content type found, or null */ public static IContentType getContentType(String filename) { return CContentTypes.getContentType(null, filename); } /** - * Returns the content type for a filename. The method respects project + * Returns the content type for a filename. The method respects * project specific content type definitions. The lookup prefers case- * sensitive matches over the others. * @param project a project with possible project specific settings. Can be null diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CContentTypes.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CContentTypes.java index f20d65e37f3..9ffe97e40a8 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CContentTypes.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CContentTypes.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2007 Wind River Systems, Inc. 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 @@ -39,6 +39,9 @@ public class CContentTypes { * Implementation for {@link CCorePlugin#getContentType(IProject, String)}. */ public static IContentType getContentType(IProject project, String filename) { + if (filename == null) { + return null; + } IContentTypeMatcher matcher= null; IScopeContext scopeCtx= null; boolean preferCpp= true;