1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Fixes a NPE, bug 215768.

This commit is contained in:
Markus Schorn 2008-01-18 12:58:55 +00:00
parent 61806eb27f
commit d41fb1782b

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2005 IBM Corporation and others. * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
@ -49,7 +50,7 @@ public class ParserUtil
return scannerLogService; return scannerLogService;
} }
public static char [] findWorkingCopyBuffer( String path, Iterator workingCopies ) public static char [] findWorkingCopyBuffer( String path, Iterator<IWorkingCopy> workingCopies )
{ {
IResource resultingResource = getResourceForFilename(path); IResource resultingResource = getResourceForFilename(path);
@ -63,7 +64,7 @@ public class ParserUtil
return null; return null;
} }
public static CodeReader createReader( String finalPath, Iterator workingCopies ) public static CodeReader createReader( String finalPath, Iterator<IWorkingCopy> workingCopies )
{ {
// check to see if the file which this path points to points to an // check to see if the file which this path points to points to an
// IResource in the workspace // IResource in the workspace
@ -153,15 +154,13 @@ public class ParserUtil
* @param workingCopies * @param workingCopies
* @return * @return
*/ */
protected static char[] findWorkingCopy(IResource resultingResource, Iterator workingCopies) { protected static char[] findWorkingCopy(IResource resultingResource, Iterator<IWorkingCopy> workingCopies) {
if( parserLogService.isTracing() ) if( parserLogService.isTracing() )
parserLogService.traceLog( "Attempting to find the working copy for " + resultingResource.getName() ); //$NON-NLS-1$ parserLogService.traceLog( "Attempting to find the working copy for " + resultingResource.getName() ); //$NON-NLS-1$
while( workingCopies.hasNext() ) while( workingCopies.hasNext() )
{ {
Object next = workingCopies.next(); IWorkingCopy copy = workingCopies.next();
if( !( next instanceof IWorkingCopy)) continue; if (resultingResource.equals(copy.getResource()))
IWorkingCopy copy = (IWorkingCopy) next;
if( copy.getResource().equals(resultingResource ))
{ {
if( parserLogService.isTracing() ) if( parserLogService.isTracing() )
parserLogService.traceLog( "Working copy found!!" ); //$NON-NLS-1$ parserLogService.traceLog( "Working copy found!!" ); //$NON-NLS-1$