List of usage examples for org.eclipse.jdt.internal.core JavaModelManager VERBOSE
boolean VERBOSE
To view the source code for org.eclipse.jdt.internal.core JavaModelManager VERBOSE.
Click Source Link
From source file:net.sf.j2s.core.builder.AbstractImageBuilder.java
License:Open Source License
/** * Creates a marker from each problem and adds it to the resource. * The marker is as follows:/* www. jav a 2 s . co m*/ * - its type is T_PROBLEM * - its plugin ID is the JavaBuilder's plugin ID * - its message is the problem's message * - its priority reflects the severity of the problem * - its range is the problem's range * - it has an extra attribute "ID" which holds the problem's id * - it's {@link IMarker#SOURCE_ID} attribute is positioned to {@link JavaBuilder#SOURCE_ID} if * the problem was generated by JDT; else the {@link IMarker#SOURCE_ID} attribute is * carried from the problem to the marker in extra attributes, if present. */ protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException { if (sourceFile == null || problems == null || problems.length == 0) return; // once a classpath error is found, ignore all other problems for this project so the user can see the main error // but still try to compile as many source files as possible to help the case when the base libraries are in source if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants .managedMarkerTypes(); problems: for (int i = 0, l = problems.length; i < l; i++) { CategorizedProblem problem = problems[i]; int id = problem.getID(); // we may use a different resource for certain problems such as IProblem.MissingNonNullByDefaultAnnotationOnPackage // but at the start of the next problem we should reset it to the source file's resource IResource resource = sourceFile.resource; // handle missing classfile situation if (id == IProblem.IsClassPathCorrect) { String missingClassfileName = problem.getArguments()[0]; if (JavaBuilder.DEBUG) System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); boolean isInvalidClasspathError = JavaCore.ERROR .equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)); // insert extra classpath problem, and make it the only problem for this project (optional) if (isInvalidClasspathError && JavaCore.ABORT.equals( this.javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) { JavaBuilder.removeProblemsAndTasksFor(this.javaBuilder.currentProject); // make this the only problem for this project this.keepStoringProblemMarkers = false; } IMarker marker = this.javaBuilder.currentProject .createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID }, new Object[] { Messages.bind(Messages.build_incompleteClassPath, missingClassfileName), new Integer(isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID }); // even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending // IsClassPathCorrect problem gets recorded since it may help locate the offending reference } String markerType = problem.getMarkerType(); boolean managedProblem = false; if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType) || (managedProblem = managedMarkerTypes.contains(markerType))) { if (id == IProblem.MissingNonNullByDefaultAnnotationOnPackage && !(CharOperation.equals(sourceFile.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME))) { // for this kind of problem, marker needs to be created on the package instead of on the source file // see bug 372012 char[] fileName = sourceFile.getFileName(); int pkgEnd = CharOperation.lastIndexOf('/', fileName); if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); PackageFragment pkg = null; if (pkgEnd != -1) pkg = (PackageFragment) Util.getPackageFragment(sourceFile.getFileName(), pkgEnd, -1 /*no jar separator for java files*/); if (pkg != null) { try { IMarker[] existingMarkers = pkg.resource().findMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); int len = existingMarkers.length; for (int j = 0; j < len; j++) { if (((Integer) existingMarkers[j].getAttribute(IJavaModelMarker.ID)) .intValue() == IProblem.MissingNonNullByDefaultAnnotationOnPackage) { continue problems; // marker already present } } } catch (CoreException e) { // marker retrieval failed, cannot do much if (JavaModelManager.VERBOSE) { e.printStackTrace(); } } IResource tempRes = pkg.resource(); if (tempRes != null) { resource = tempRes; } } } IMarker marker = resource.createMarker(markerType); String[] attributeNames = JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES; int standardLength = attributeNames.length; String[] allNames = attributeNames; int managedLength = managedProblem ? 0 : 1; String[] extraAttributeNames = problem.getExtraMarkerAttributeNames(); int extraLength = extraAttributeNames == null ? 0 : extraAttributeNames.length; if (managedLength > 0 || extraLength > 0) { allNames = new String[standardLength + managedLength + extraLength]; System.arraycopy(attributeNames, 0, allNames, 0, standardLength); if (managedLength > 0) allNames[standardLength] = IMarker.SOURCE_ID; System.arraycopy(extraAttributeNames, 0, allNames, standardLength + managedLength, extraLength); } Object[] allValues = new Object[allNames.length]; // standard attributes int index = 0; allValues[index++] = problem.getMessage(); // message allValues[index++] = problem.isError() ? S_ERROR : S_WARNING; // severity allValues[index++] = new Integer(id); // ID allValues[index++] = new Integer(problem.getSourceStart()); // start allValues[index++] = new Integer(problem.getSourceEnd() + 1); // end allValues[index++] = new Integer(problem.getSourceLineNumber()); // line allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments allValues[index++] = new Integer(problem.getCategoryID()); // category ID // SOURCE_ID attribute for JDT problems if (managedLength > 0) allValues[index++] = JavaBuilder.SOURCE_ID; // optional extra attributes if (extraLength > 0) System.arraycopy(problem.getExtraMarkerAttributeValues(), 0, allValues, index, extraLength); marker.setAttributes(allNames, allValues); if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file } } }
From source file:org.eclipse.ajdt.core.reconcile.AJReconcileWorkingCopyOperation.java
License:Open Source License
/** * Report working copy problems to a given requestor. * * @param workingCopy/*from ww w . j a v a 2 s. co m*/ * @param problemRequestor */ private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) { try { problemRequestor.beginReporting(); for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext();) { CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next(); if (categorizedProblems == null) continue; for (int i = 0, length = categorizedProblems.length; i < length; i++) { CategorizedProblem problem = categorizedProblems[i]; if (JavaModelManager.VERBOSE) { AJLog.log(AJLog.PARSER, "PROBLEM FOUND while reconciling : " + //$NON-NLS-1$ problem.getMessage()); } if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break; problemRequestor.acceptProblem(problem); } } } finally { problemRequestor.endReporting(); } }
From source file:org.eclipse.jdt.internal.core.CompilationUnit.java
License:Open Source License
/** * @see IWorkingCopy#destroy()//from w w w. ja v a 2 s . c om * @deprecated */ public void destroy() { try { discardWorkingCopy(); } catch (JavaModelException e) { if (JavaModelManager.VERBOSE) e.printStackTrace(); } }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
/** * Configure the plugin with respect to option settings defined in ".options" file *//* www . j a v a2s.co m*/ public void configurePluginDebugOptions() { if (JavaCore.getPlugin().isDebugging()) { String option = Platform.getDebugOption(BUFFER_MANAGER_DEBUG); if (option != null) BufferManager.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(BUILDER_DEBUG); if (option != null) JavaBuilder.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(COMPILER_DEBUG); if (option != null) Compiler.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(BUILDER_STATS_DEBUG); if (option != null) JavaBuilder.SHOW_STATS = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(COMPLETION_DEBUG); if (option != null) CompletionEngine.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(CP_RESOLVE_DEBUG); if (option != null) JavaModelManager.CP_RESOLVE_VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(CP_RESOLVE_ADVANCED_DEBUG); if (option != null) JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(CP_RESOLVE_FAILURE_DEBUG); if (option != null) JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(DELTA_DEBUG); if (option != null) DeltaProcessor.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(DELTA_DEBUG_VERBOSE); if (option != null) DeltaProcessor.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(HIERARCHY_DEBUG); if (option != null) TypeHierarchy.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(INDEX_MANAGER_DEBUG); if (option != null) JobManager.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(INDEX_MANAGER_ADVANCED_DEBUG); if (option != null) IndexManager.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(JAVAMODEL_DEBUG); if (option != null) JavaModelManager.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(JAVAMODELCACHE_DEBUG); if (option != null) JavaModelCache.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(POST_ACTION_DEBUG); if (option != null) JavaModelOperation.POST_ACTION_VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(RESOLUTION_DEBUG); if (option != null) NameLookup.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(SEARCH_DEBUG); if (option != null) BasicSearchEngine.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(SELECTION_DEBUG); if (option != null) SelectionEngine.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(ZIP_ACCESS_DEBUG); if (option != null) JavaModelManager.ZIP_ACCESS_VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(SOURCE_MAPPER_DEBUG_VERBOSE); if (option != null) SourceMapper.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(FORMATTER_DEBUG); if (option != null) DefaultCodeFormatter.DEBUG = option.equalsIgnoreCase(TRUE); } // configure performance options if (PerformanceStats.ENABLED) { CompletionEngine.PERF = PerformanceStats.isEnabled(COMPLETION_PERF); SelectionEngine.PERF = PerformanceStats.isEnabled(SELECTION_PERF); DeltaProcessor.PERF = PerformanceStats.isEnabled(DELTA_LISTENER_PERF); JavaModelManager.PERF_VARIABLE_INITIALIZER = PerformanceStats.isEnabled(VARIABLE_INITIALIZER_PERF); JavaModelManager.PERF_CONTAINER_INITIALIZER = PerformanceStats.isEnabled(CONTAINER_INITIALIZER_PERF); ReconcileWorkingCopyOperation.PERF = PerformanceStats.isEnabled(RECONCILE_PERF); } }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
/** * Record a new marker denoting a classpath problem */// w ww . java 2 s . c o m public void createClasspathProblemMarker(IJavaModelStatus status) { IMarker marker = null; int severity; String[] arguments = CharOperation.NO_STRINGS; boolean isCycleProblem = false, isClasspathFileFormatProblem = false, isOutputOverlapping = false; switch (status.getCode()) { case IJavaModelStatusConstants.CLASSPATH_CYCLE: isCycleProblem = true; if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) { severity = IMarker.SEVERITY_ERROR; } else { severity = IMarker.SEVERITY_WARNING; } break; case IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT: isClasspathFileFormatProblem = true; severity = IMarker.SEVERITY_ERROR; break; case IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL: String setting = getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true); if (JavaCore.ERROR.equals(setting)) { severity = IMarker.SEVERITY_ERROR; } else if (JavaCore.WARNING.equals(setting)) { severity = IMarker.SEVERITY_WARNING; } else { return; // setting == IGNORE } break; case IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE: isOutputOverlapping = true; setting = getOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, true); if (JavaCore.ERROR.equals(setting)) { severity = IMarker.SEVERITY_ERROR; } else if (JavaCore.WARNING.equals(setting)) { severity = IMarker.SEVERITY_WARNING; } else { return; // setting == IGNORE } break; default: IPath path = status.getPath(); if (path != null) arguments = new String[] { path.toString() }; if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)) && status.getSeverity() != IStatus.WARNING) { severity = IMarker.SEVERITY_ERROR; } else { severity = IMarker.SEVERITY_WARNING; } break; } try { marker = this.project.createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IMarker.LOCATION, IJavaModelMarker.CYCLE_DETECTED, IJavaModelMarker.CLASSPATH_FILE_FORMAT, IJavaModelMarker.OUTPUT_OVERLAPPING_SOURCE, IJavaModelMarker.ID, IJavaModelMarker.ARGUMENTS, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID, }, new Object[] { status.getMessage(), new Integer(severity), Messages.classpath_buildPath, isCycleProblem ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$ isClasspathFileFormatProblem ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$ isOutputOverlapping ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$ new Integer(status.getCode()), Util.getProblemArgumentsForMarker(arguments), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID, }); } catch (CoreException e) { // could not create marker: cannot do much if (JavaModelManager.VERBOSE) { e.printStackTrace(); } } }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
/** * Remove all markers denoting classpath problems */ //TODO (philippe) should improve to use a bitmask instead of booleans (CYCLE, FORMAT, VALID) protected void flushClasspathProblemMarkers(boolean flushCycleMarkers, boolean flushClasspathFormatMarkers, boolean flushOverlappingOutputMarkers) { try {//w w w . jav a 2 s. com if (this.project.isAccessible()) { IMarker[] markers = this.project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); for (int i = 0, length = markers.length; i < length; i++) { IMarker marker = markers[i]; if (flushCycleMarkers && flushClasspathFormatMarkers && flushOverlappingOutputMarkers) { marker.delete(); } else { String cycleAttr = (String) marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED); String classpathFileFormatAttr = (String) marker .getAttribute(IJavaModelMarker.CLASSPATH_FILE_FORMAT); String overlappingOutputAttr = (String) marker .getAttribute(IJavaModelMarker.OUTPUT_OVERLAPPING_SOURCE); if ((flushCycleMarkers == (cycleAttr != null && cycleAttr.equals("true"))) //$NON-NLS-1$ && (flushOverlappingOutputMarkers == (overlappingOutputAttr != null && overlappingOutputAttr.equals("true"))) //$NON-NLS-1$ && (flushClasspathFormatMarkers == (classpathFileFormatAttr != null && classpathFileFormatAttr.equals("true")))) { //$NON-NLS-1$ marker.delete(); } } } } } catch (CoreException e) { // could not flush markers: not much we can do if (JavaModelManager.VERBOSE) { e.printStackTrace(); } } }
From source file:org.eclipse.objectteams.otdt.tests.AbstractJavaModelTests.java
License:Open Source License
protected void setUp() throws Exception { //{ObjectTeams: if (_usePerformanceMeter) //}//from ww w. j a v a 2 s. co m super.setUp(); if (NameLookup.VERBOSE || BasicSearchEngine.VERBOSE || JavaModelManager.VERBOSE) { System.out.println("--------------------------------------------------------------------------------"); System.out.println("Running test " + getName() + "..."); } }