View | Details | Raw Unified | Return to bug 311048
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java (-46 / +51 lines)
Lines 140-159 Link Here
140
		};
140
		};
141
	}
141
	}
142
142
143
	/*
144
	 * Can return null if the process was aborted or canceled 
145
	 */
143
	public static CompilationUnitDeclaration process(
146
	public static CompilationUnitDeclaration process(
144
		CompilationUnit unitElement,
147
			CompilationUnit unitElement,
145
		SourceElementParser parser,
148
			SourceElementParser parser,
146
		WorkingCopyOwner workingCopyOwner,
149
			WorkingCopyOwner workingCopyOwner,
147
		HashMap problems,
150
			HashMap problems,
148
		boolean creatingAST,
151
			boolean creatingAST,
149
		int reconcileFlags,
152
			int reconcileFlags,
150
		IProgressMonitor monitor)
153
			IProgressMonitor monitor)
151
		throws JavaModelException {
154
		throws JavaModelException {
152
155
153
		JavaProject project = (JavaProject) unitElement.getJavaProject();
156
		JavaProject project = (JavaProject) unitElement.getJavaProject();
154
		CancelableNameEnvironment environment = null;
157
		CancelableNameEnvironment environment = null;
155
		CancelableProblemFactory problemFactory = null;
158
		CancelableProblemFactory problemFactory = null;
156
		CompilationUnitProblemFinder problemFinder = null;
159
		CompilationUnitProblemFinder problemFinder = null;
160
		CompilationUnitDeclaration unit = null;
157
		try {
161
		try {
158
			environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor);
162
			environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor);
159
			problemFactory = new CancelableProblemFactory(monitor);
163
			problemFactory = new CancelableProblemFactory(monitor);
Lines 170-179 Link Here
170
			if (ignoreMethodBodies) {
174
			if (ignoreMethodBodies) {
171
				analyzeAndGenerateCode = false;
175
				analyzeAndGenerateCode = false;
172
			}
176
			}
173
			CompilationUnitDeclaration unit = null;
177
			try {
174
			if (parser != null) {
178
				if (parser != null) {
175
				problemFinder.parser = parser;
179
					problemFinder.parser = parser;
176
				try {
177
					unit = parser.parseCompilationUnit(unitElement, true/*full parse*/, monitor);
180
					unit = parser.parseCompilationUnit(unitElement, true/*full parse*/, monitor);
178
					problemFinder.resolve(
181
					problemFinder.resolve(
179
						unit,
182
						unit,
Lines 181-217 Link Here
181
						true, // verify methods
184
						true, // verify methods
182
						analyzeAndGenerateCode, // analyze code
185
						analyzeAndGenerateCode, // analyze code
183
						analyzeAndGenerateCode); // generate code
186
						analyzeAndGenerateCode); // generate code
184
				} catch (AbortCompilation e) {
187
				} else {
185
					problemFinder.handleInternalException(e, unit);
188
					unit =
189
						problemFinder.resolve(
190
							unitElement,
191
							true, // verify methods
192
							analyzeAndGenerateCode, // analyze code
193
							analyzeAndGenerateCode); // generate code
186
				}
194
				}
187
			} else {
195
			} catch (AbortCompilation e) {
188
				unit =
196
				problemFinder.handleInternalException(e, unit);
189
					problemFinder.resolve(
190
						unitElement,
191
						true, // verify methods
192
						analyzeAndGenerateCode, // analyze code
193
						analyzeAndGenerateCode); // generate code
194
			}
197
			}
195
			CompilationResult unitResult = unit.compilationResult;
198
			if (unit != null) {
196
			CategorizedProblem[] unitProblems = unitResult.getProblems();
199
				CompilationResult unitResult = unit.compilationResult;
197
			int length = unitProblems == null ? 0 : unitProblems.length;
200
				CategorizedProblem[] unitProblems = unitResult.getProblems();
198
			if (length > 0) {
201
				int length = unitProblems == null ? 0 : unitProblems.length;
199
				CategorizedProblem[] categorizedProblems = new CategorizedProblem[length];
202
				if (length > 0) {
200
				System.arraycopy(unitProblems, 0, categorizedProblems, 0, length);
203
					CategorizedProblem[] categorizedProblems = new CategorizedProblem[length];
201
				problems.put(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, categorizedProblems);
204
					System.arraycopy(unitProblems, 0, categorizedProblems, 0, length);
202
			}
205
					problems.put(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, categorizedProblems);
203
			unitProblems = unitResult.getTasks();
206
				}
204
			length = unitProblems == null ? 0 : unitProblems.length;
207
				unitProblems = unitResult.getTasks();
205
			if (length > 0) {
208
				length = unitProblems == null ? 0 : unitProblems.length;
206
				CategorizedProblem[] categorizedProblems = new CategorizedProblem[length];
209
				if (length > 0) {
207
				System.arraycopy(unitProblems, 0, categorizedProblems, 0, length);
210
					CategorizedProblem[] categorizedProblems = new CategorizedProblem[length];
208
				problems.put(IJavaModelMarker.TASK_MARKER, categorizedProblems);
211
					System.arraycopy(unitProblems, 0, categorizedProblems, 0, length);
209
			}
212
					problems.put(IJavaModelMarker.TASK_MARKER, categorizedProblems);
210
			if (NameLookup.VERBOSE) {
213
				}
211
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
214
				if (NameLookup.VERBOSE) {
212
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
215
					System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
216
					System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
217
				}
213
			}
218
			}
214
			return unit;
215
		} catch (OperationCanceledException e) {
219
		} catch (OperationCanceledException e) {
216
			// catch this exception so as to not enter the catch(RuntimeException e) below
220
			// catch this exception so as to not enter the catch(RuntimeException e) below
217
			throw e;
221
			throw e;
Lines 236-251 Link Here
236
			if (problemFinder != null && !creatingAST)
240
			if (problemFinder != null && !creatingAST)
237
				problemFinder.lookupEnvironment.reset();
241
				problemFinder.lookupEnvironment.reset();
238
		}
242
		}
243
		return unit;
239
	}
244
	}
240
245
241
	public static CompilationUnitDeclaration process(
246
	public static CompilationUnitDeclaration process(
242
		CompilationUnit unitElement,
247
			CompilationUnit unitElement,
243
		WorkingCopyOwner workingCopyOwner,
248
			WorkingCopyOwner workingCopyOwner,
244
		HashMap problems,
249
			HashMap problems,
245
		boolean creatingAST,
250
			boolean creatingAST,
246
		int reconcileFlags,
251
			int reconcileFlags,
247
		IProgressMonitor monitor)
252
			IProgressMonitor monitor)
248
		throws JavaModelException {
253
			throws JavaModelException {
249
254
250
		return process(unitElement, null/*use default Parser*/, workingCopyOwner, problems, creatingAST, reconcileFlags, monitor);
255
		return process(unitElement, null/*use default Parser*/, workingCopyOwner, problems, creatingAST, reconcileFlags, monitor);
251
	}
256
	}

Return to bug 311048