diff options
| author | Jay Arthanareeswaran | 2016-12-15 10:47:20 +0000 |
|---|---|---|
| committer | Jay Arthanareeswaran | 2016-12-15 10:47:20 +0000 |
| commit | a816d34b91b0e7949e1a4269cc46805fc0abc45d (patch) | |
| tree | 76613e517836cb9422beafadc7531256f99d5ad0 | |
| parent | 6631c70610dad3130e66a01544628963edbca4c8 (diff) | |
| download | eclipse.jdt.core-a816d34b91b0e7949e1a4269cc46805fc0abc45d.tar.gz eclipse.jdt.core-a816d34b91b0e7949e1a4269cc46805fc0abc45d.tar.xz eclipse.jdt.core-a816d34b91b0e7949e1a4269cc46805fc0abc45d.zip | |
Bug 449846 - [jdt] NPE inI20161215-0915
PackageExplorerContentProvider.getPackageFragmentRoots
Change-Id: I6a7405492041575cd78176b12ecc194ef146e780
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
6 files changed, 34 insertions, 59 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java index 0e2c59896a..5311235038 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java @@ -1745,7 +1745,7 @@ public class DeltaProcessor { JavaElementInfo info = (JavaElementInfo)element.getElementInfo(); switch (element.getElementType()) { case IJavaElement.JAVA_MODEL : - ((JavaModelInfo) info).nonJavaResources = null; + ((JavaModelInfo) info).setNonJavaResources(null); if (!ExternalFoldersManager.isInternalPathForExternalFolder(delta.getFullPath())) currentDelta().addResourceDelta(delta); return; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java index 3f020e214d..bab62d6a84 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation 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 @@ -21,11 +21,6 @@ import org.eclipse.core.resources.ResourcesPlugin; */ public class JavaModelInfo extends OpenableElementInfo { - /** - * A array with all the non-java projects contained by this model - */ - Object[] nonJavaResources; - /** * Compute the non-java resources contained in this java project. */ @@ -54,10 +49,11 @@ private Object[] computeNonJavaResources() { * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources() { - - if (this.nonJavaResources == null) { - this.nonJavaResources = computeNonJavaResources(); + Object[] resources = this.nonJavaResources; + if (resources == null) { + resources = computeNonJavaResources(); + this.nonJavaResources = resources; } - return this.nonJavaResources; + return resources; } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java index 12a20a40e2..21de2b3d24 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation 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 @@ -65,11 +65,6 @@ class JavaProjectElementInfo extends OpenableElementInfo { public Map rootToResolvedEntries; } - /** - * A array with all the non-java resources contained by this PackageFragment - */ - private Object[] nonJavaResources; - ProjectCache projectCache; /* @@ -238,11 +233,12 @@ class JavaProjectElementInfo extends OpenableElementInfo { * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(JavaProject project) { - - if (this.nonJavaResources == null) { - this.nonJavaResources = computeNonJavaResources(project); + Object[] resources = this.nonJavaResources; + if (resources == null) { + resources = computeNonJavaResources(project); + this.nonJavaResources = resources; } - return this.nonJavaResources; + return resources; } private void initializePackageNames(IPackageFragmentRoot root, HashSetOfArray fragmentsCache) { @@ -353,13 +349,4 @@ class JavaProjectElementInfo extends OpenableElementInfo { void resetCaches() { this.projectCache = null; } - - /** - * Set the fNonJavaResources to res value - */ - void setNonJavaResources(Object[] resources) { - - this.nonJavaResources = resources; - } - } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java index 6a7dc0c11c..5774763c4d 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation 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 @@ -29,6 +29,11 @@ public class OpenableElementInfo extends JavaElementInfo { */ protected boolean isStructureKnown = false; + /** + * A array with all the non-java resources contained by this element + */ + protected Object[] nonJavaResources; + public void addChild(IJavaElement child) { IJavaElement[] oldChildren = this.children; int length = oldChildren.length; @@ -86,4 +91,10 @@ public class OpenableElementInfo extends JavaElementInfo { public void setIsStructureKnown(boolean newIsStructureKnown) { this.isStructureKnown = newIsStructureKnown; } + /** + * Sets the nonJavaResources + */ + void setNonJavaResources(Object[] resources) { + this.nonJavaResources = resources; + } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java index ec159b69bc..2ffe2401f1 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation 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 @@ -19,11 +19,6 @@ import org.eclipse.jdt.core.JavaModelException; */ class PackageFragmentInfo extends OpenableElementInfo { - /** - * A array with all the non-java resources contained by this PackageFragment - */ - protected Object[] nonJavaResources; - /** * Create and initialize a new instance of the receiver */ @@ -39,25 +34,22 @@ boolean containsJavaResources() { * Returns an array of non-java resources contained in the receiver. */ Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) { - if (this.nonJavaResources == null) { + Object[] resources = this.nonJavaResources; + if (resources == null) { try { - this.nonJavaResources = + resources = PackageFragmentRootInfo.computeFolderNonJavaResources( rootHandle, (IContainer)underlyingResource, rootHandle.fullInclusionPatternChars(), rootHandle.fullExclusionPatternChars()); + } catch (JavaModelException e) { // root doesn't exist: consider package has no nonJavaResources - this.nonJavaResources = NO_NON_JAVA_RESOURCES; + resources = NO_NON_JAVA_RESOURCES; } + this.nonJavaResources = resources; } - return this.nonJavaResources; -} -/** - * Set the nonJavaResources to res value - */ -void setNonJavaResources(Object[] resources) { - this.nonJavaResources = resources; + return resources; } } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java index c523f1b682..b960b7e4b4 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation 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 @@ -37,11 +37,6 @@ class PackageFragmentRootInfo extends OpenableElementInfo { */ protected int rootKind= IPackageFragmentRoot.K_SOURCE; - /** - * A array with all the non-java resources contained by this PackageFragment - */ - protected Object[] nonJavaResources; - private boolean ignoreOptionalProblems; private boolean initialized; /** @@ -180,12 +175,6 @@ private static boolean isClasspathEntry(IPath path, IClasspathEntry[] resolvedCl return false; } /** - * Set the fNonJavaResources to res value - */ -void setNonJavaResources(Object[] resources) { - this.nonJavaResources = resources; -} -/** * Sets the kind of this root. */ protected void setRootKind(int newRootKind) { |
