gt: 							if (categorizedProblems == null) continue;
context: /*******************************************************************************
   * Copyright (c) 2000, 2015 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
   * http://www.eclipse.org/legal/epl-v10.html
   *
   * Contributors:
   *     IBM Corporation - initial API and implementation
   *     Alex Smirnoff (alexsmr@sympatico.ca) - part of the changes to support Java-like extension
   *                                                            (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460)
   *******************************************************************************/
  package org.eclipse.wst.jsdt.internal.core;
  
  import java.net.URI;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.eclipse.core.resources.IContainer;
  import org.eclipse.core.resources.IFile;
  import org.eclipse.core.resources.IMarker;
  import org.eclipse.core.resources.IResource;
  import org.eclipse.core.runtime.IPath;
  import org.eclipse.core.runtime.IProgressMonitor;
  import org.eclipse.core.runtime.IStatus;
  import org.eclipse.core.runtime.Path;
  import org.eclipse.core.runtime.PerformanceStats;
  import org.eclipse.wst.jsdt.core.CompletionRequestor;
  import org.eclipse.wst.jsdt.core.Flags;
  import org.eclipse.wst.jsdt.core.IBuffer;
  import org.eclipse.wst.jsdt.core.IBufferFactory;
  import org.eclipse.wst.jsdt.core.IField;
  import org.eclipse.wst.jsdt.core.IFunction;
  import org.eclipse.wst.jsdt.core.IImportContainer;
  import org.eclipse.wst.jsdt.core.IImportDeclaration;
  import org.eclipse.wst.jsdt.core.IJavaScriptElement;
  import org.eclipse.wst.jsdt.core.IJavaScriptModelStatusConstants;
  import org.eclipse.wst.jsdt.core.IJavaScriptProject;
  import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
  import org.eclipse.wst.jsdt.core.IMember;
  import org.eclipse.wst.jsdt.core.IPackageFragment;
  import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
  import org.eclipse.wst.jsdt.core.IProblemRequestor;
  import org.eclipse.wst.jsdt.core.ISourceRange;
  import org.eclipse.wst.jsdt.core.IType;
  import org.eclipse.wst.jsdt.core.ITypeRoot;
  import org.eclipse.wst.jsdt.core.JavaScriptConventions;
  import org.eclipse.wst.jsdt.core.JavaScriptCore;
  import org.eclipse.wst.jsdt.core.JavaScriptModelException;
  import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
  import org.eclipse.wst.jsdt.core.LibrarySuperType;
  import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
  import org.eclipse.wst.jsdt.core.compiler.CategorizedProblem;
  import org.eclipse.wst.jsdt.core.compiler.CharOperation;
  import org.eclipse.wst.jsdt.core.dom.AST;
  import org.eclipse.wst.jsdt.internal.compiler.IProblemFactory;
  import org.eclipse.wst.jsdt.internal.compiler.SourceElementParser;
  import org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration;
  import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
  import org.eclipse.wst.jsdt.internal.compiler.problem.DefaultProblemFactory;
  import org.eclipse.wst.jsdt.internal.compiler.util.SuffixConstants;
  import org.eclipse.wst.jsdt.internal.core.util.MementoTokenizer;
  import org.eclipse.wst.jsdt.internal.core.util.Messages;
  import org.eclipse.wst.jsdt.internal.core.util.Util;
  
  /**
   * @see IJavaScriptUnit
   */
  public class CompilationUnit extends Openable implements IJavaScriptUnit, org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit, SuffixConstants, IVirtualParent {
  	/**
  	 * Internal synonynm for deprecated constant AST.JSL2
  	 * to alleviate deprecation warnings.
  	 * @deprecated
  	 */
  	/*package*/ static final int JLS2_INTERNAL = AST.JLS2;
  
  	private static final IImportDeclaration[] NO_IMPORTS = new IImportDeclaration[0];
  	protected String name;
  	public WorkingCopyOwner owner;
  	public String superTypeName;
  	
  	/**
  	 * <p>
  	 * <code>true</code> if currently making this unit consistent,
  	 * <code>false</code> otherwise.
  	 * </p>
  	 * <p>
  	 * Used to prevent
  	 * {@link #makeConsistent(int, boolean, int, HashMap, IProgressMonitor)}
  	 * from being called in an infinite loop.
  	 * </p>
  	 * 
  	 * @see #makeConsistent(int, boolean, int, HashMap, IProgressMonitor)
  	 */
  	private volatile boolean fIsMakingConsistent;
  
  	/**
  	 * Constructs a handle to a compilation unit with the given name in the
  	 * specified package for the specified owner
  	 */
  	public CompilationUnit(PackageFragment parent, String name,String superTypeName, WorkingCopyOwner owner) {
  		super(parent);
  		this.name = name;
  		this.owner = owner;
  		this.superTypeName = superTypeName;
  		this.fIsMakingConsistent = false;
  	}
  	
  	public CompilationUnit(PackageFragment parent, String name, WorkingCopyOwner owner) {
  		this(parent,name,null,owner);
  	}
  	
  	/*
  	 * @see IJavaScriptUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor)
  	 */
  	public void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaScriptModelException {
  		JavaModelManager manager = JavaModelManager.getJavaModelManager();
  		JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager.getPerWorkingCopyInfo(this, false/*don't create*/, true /*record usage*/, null/*no problem requestor needed*/);
  		if (perWorkingCopyInfo == null) {
  			// close cu and its children
  			close();
  	
  			BecomeWorkingCopyOperation operation = new BecomeWorkingCopyOperation(this, problemRequestor);
  			operation.runOperation(monitor);
  		}
  	}
  	/*
  	 * @see IJavaScriptUnit#becomeWorkingCopy(IProgressMonitor)
  	 */
  	public void becomeWorkingCopy(IProgressMonitor monitor) throws JavaScriptModelException {
  		IProblemRequestor requestor = this.owner == null ? null : this.owner.getProblemRequestor(this);
  		becomeWorkingCopy(requestor, monitor);
  	}
  	protected boolean buildStructure(OpenableElementInfo info, final IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaScriptModelException {
  	
  		// check if this compilation unit can be opened
  		if (!isWorkingCopy()) { // no check is done on root kind or exclusion pattern for working copies
  			IStatus status = validateCompilationUnit(underlyingResource);
  			if (!status.isOK()) throw newJavaModelException(status);
  		}
  	
  		// prevents reopening of non-primary working copies (they are closed when they are discarded and should not be reopened)
  		if (!isPrimary() && getPerWorkingCopyInfo() == null) {
  			throw newNotPresentException();
  		}
  	
  		CompilationUnitElementInfo unitInfo = (CompilationUnitElementInfo) info;
  	
  		// get buffer contents
  		IBuffer buffer = getBufferManager().getBuffer(CompilationUnit.this);
  		if (buffer == null) {
  			buffer = openBuffer(pm, unitInfo); // open buffer independently from the info, since we are building the info
  		}
  		final char[] contents;
  		if (buffer == null) {
  			contents = CharOperation.NO_CHAR ;
  		} else {
  			char[] characters = buffer.getCharacters();
  			contents = characters == null ? CharOperation.NO_CHAR : characters;
  		}
  	
  		// generate structure and compute syntax problems if needed
  		CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements);
  		JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = getPerWorkingCopyInfo();
  		IJavaScriptProject project = getJavaScriptProject();
  	
  		boolean createAST;
  		boolean resolveBindings;
  		int reconcileFlags;
  		HashMap problems;
  		if (info instanceof ASTHolderCUInfo) {
  			ASTHolderCUInfo astHolder = (ASTHolderCUInfo) info;
  			createAST = astHolder.astLevel != NO_AST;
  			resolveBindings = astHolder.resolveBindings;
  			reconcileFlags = astHolder.reconcileFlags;
  			problems = astHolder.problems;
  		} else {
  			createAST = false;
  			resolveBindings = false;
  			reconcileFlags = 0;
  			problems = null;
  		}
  	
  		boolean computeProblems = perWorkingCopyInfo != null && perWorkingCopyInfo.isActive() && project != null && JavaProject.hasJavaNature(project.getProject());
  		IProblemFactory problemFactory = new DefaultProblemFactory();
  		Map options = project == null ? JavaScriptCore.getOptions() : project.getOptions(true);
  		if (!computeProblems) {
  			// disable task tags checking to speed up parsing
  			options.put(JavaScriptCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$
  		}
  		SourceElementParser parser = new SourceElementParser(
  			requestor,
  			problemFactory,
  			new CompilerOptions(options),
  			true/*report local declarations*/,
  			!createAST /*optimize string literals only if not creating a DOM AST*/);
  		parser.reportOnlyOneSyntaxError = !computeProblems;
  		parser.setMethodsFullRecovery(true);
  		parser.setStatementsRecovery((reconcileFlags & IJavaScriptUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
  	
  		requestor.parser = parser;
  		CompilationUnitDeclaration unit = parser.parseCompilationUnit(
  			new org.eclipse.wst.jsdt.internal.compiler.env.ICompilationUnit() {
  				public char[] getContents() {
  					return contents;
  				}
  				public char[] getMainTypeName() {
  					return CompilationUnit.this.getMainTypeName();
  				}
  				public char[][] getPackageName() {
  					return CompilationUnit.this.getPackageName();
  				}
  				public char[] getFileName() {
  					return CompilationUnit.this.getFileName();
  				}
  				public LibrarySuperType getCommonSuperType() {
  					return CompilationUnit.this.getCommonSuperType();
  				}
  				public String getInferenceID() {
  					return CompilationUnit.this.getInferenceID();
  				}
  	
  	
  			},
  			true /*full parse to find local elements*/);
  	
  		// update timestamp (might be IResource.NULL_STAMP if original does not exist)
  		if (underlyingResource == null) {
  			underlyingResource = getResource();
  		}
  		// underlying resource is null in the case of a working copy on a class file in a jar
  		if (underlyingResource != null)
  			unitInfo.timestamp = ((IFile)underlyingResource).getModificationStamp();
  	
  		// compute other problems if needed
  		CompilationUnitDeclaration compilationUnitDeclaration = null;
  		try {
  			if (computeProblems) {
  				if (problems == null) {
  					// report problems to the problem requestor
  					problems = new HashMap();
  					compilationUnitDeclaration = CompilationUnitProblemFinder.process(unit, this, contents, parser, this.owner, problems, createAST, reconcileFlags, pm);
  					try {
  						perWorkingCopyInfo.beginReporting();
  						for (Iterator iteraror = problems.values().iterator(); iteraror.hasNext();) {
  							CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next();
  