Java Code Examples for org.eclipse.jdt.internal.core.util.Util#log()
The following examples show how to use
org.eclipse.jdt.internal.core.util.Util#log() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalFoldersManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void refreshReferences(IProject source, IProgressMonitor monitor) { IProject externalProject = getExternalFoldersProject(); if (source.equals(externalProject)) return; if (!JavaProject.hasJavaNature(source)) return; try { HashSet externalFolders = getExternalFolders(((JavaProject) JavaCore.create(source)).getResolvedClasspath()); if (externalFolders == null) return; runRefreshJob(externalFolders); } catch (CoreException e) { Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$ } return; }
Example 2
Source File: AbstractImageBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void recordParticipantResult(CompilationParticipantResult result) { // any added/changed/deleted generated files have already been taken care // just record the problems and dependencies - do not expect there to be many // must be called after we're finished with the compilation unit results but before incremental loop adds affected files CategorizedProblem[] problems = result.problems; if (problems != null && problems.length > 0) { // existing problems have already been removed so just add these as new problems this.notifier.updateProblemCounts(problems); try { storeProblemsFor(result.sourceFile, problems); } catch (CoreException e) { // must continue with compile loop so just log the CoreException Util.log(e, "JavaBuilder logging CompilationParticipant's CoreException to help debugging"); //$NON-NLS-1$ } } String[] dependencies = result.dependencies; if (dependencies != null) { ReferenceCollection refs = (ReferenceCollection) this.newState.references.get(result.sourceFile.typeLocator()); if (refs != null) refs.addDependencies(dependencies); } }
Example 3
Source File: NonJavaResource.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public IJarEntryResource[] getChildren() { if (this.resource instanceof IContainer) { IResource[] members; try { members = ((IContainer) this.resource).members(); } catch (CoreException e) { Util.log(e, "Could not retrieve children of " + this.resource.getFullPath()); //$NON-NLS-1$ return NO_CHILDREN; } int length = members.length; if (length == 0) return NO_CHILDREN; IJarEntryResource[] children = new IJarEntryResource[length]; for (int i = 0; i < length; i++) { children[i] = new NonJavaResource(this, members[i]); } return children; } return NO_CHILDREN; }
Example 4
Source File: JavaProject.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Record a shared persistent property onto a project. * Note that it is orthogonal to IResource persistent properties, and client code has to decide * which form of storage to use appropriately. Shared properties produce real resource files which * can be shared through a VCM onto a server. Persistent properties are not shareable. * <p> * Shared properties end up in resource files, and thus cannot be modified during * delta notifications (a CoreException would then be thrown). * * @param key String * @param value String * @see JavaProject#getSharedProperty(String key) * @throws CoreException */ public void setSharedProperty(String key, String value) throws CoreException { IFile rscFile = this.project.getFile(key); byte[] bytes = null; try { bytes = value.getBytes(org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8 } catch (UnsupportedEncodingException e) { Util.log(e, "Could not write .classpath with UTF-8 encoding "); //$NON-NLS-1$ // fallback to default bytes = value.getBytes(); } InputStream inputStream = new ByteArrayInputStream(bytes); // update the resource content if (rscFile.exists()) { if (rscFile.isReadOnly()) { // provide opportunity to checkout read-only .classpath file (23984) ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{rscFile}, IWorkspace.VALIDATE_PROMPT); } rscFile.setContents(inputStream, IResource.FORCE, null); } else { rscFile.create(inputStream, IResource.FORCE, null); } }
Example 5
Source File: InternalExtendedCompletionContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public IJavaElement getEnclosingElement() { try { if (!this.hasComputedEnclosingJavaElements) { computeEnclosingJavaElements(); } if (this.compilationUnit == null) return null; IJavaElement enclosingElement = this.compilationUnit.getElementAt(this.completionContext.offset); return enclosingElement == null ? this.compilationUnit : enclosingElement; } catch (JavaModelException e) { Util.log(e, "Cannot compute enclosing element"); //$NON-NLS-1$ return null; } }
Example 6
Source File: JavaModelCache.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private double getRatioForProperty(String propertyName) { String property = System.getProperty(propertyName); if (property != null) { try { return Double.parseDouble(property); } catch (NumberFormatException e) { // ignore Util.log(e, "Could not parse value for " + propertyName + ": " + property); //$NON-NLS-1$ //$NON-NLS-2$ } } return 1.0; }
Example 7
Source File: ExternalFoldersManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Map getFolders() { if (this.folders == null) { Map tempFolders = new HashMap(); IProject project = getExternalFoldersProject(); try { if (!project.isAccessible()) { if (project.exists()) { // workspace was moved (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252571 ) openExternalFoldersProject(project, null/*no progress*/); } else { // if project doesn't exist, do not open and recreate it as it means that there are no external folders return this.folders = Collections.synchronizedMap(tempFolders); } } IResource[] members = project.members(); for (int i = 0, length = members.length; i < length; i++) { IResource member = members[i]; if (member.getType() == IResource.FOLDER && member.isLinked() && member.getName().startsWith(LINKED_FOLDER_NAME)) { IPath externalFolderPath = member.getLocation(); tempFolders.put(externalFolderPath, member); } } } catch (CoreException e) { Util.log(e, "Exception while initializing external folders"); //$NON-NLS-1$ } this.folders = Collections.synchronizedMap(tempFolders); } return this.folders; }
Example 8
Source File: UserLibraryManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void removeUserLibrary(String libName) { synchronized (this.userLibraries) { IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences(); String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName; instancePreferences.remove(propertyName); try { instancePreferences.flush(); } catch (BackingStoreException e) { Util.log(e, "Exception while removing user library " + libName); //$NON-NLS-1$ } } // this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...)) }
Example 9
Source File: JavaBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void clean(IProgressMonitor monitor) throws CoreException { this.currentProject = getProject(); if (this.currentProject == null || !this.currentProject.isAccessible()) return; if (DEBUG) System.out.println("\nJavaBuilder: Cleaning " + this.currentProject.getName() //$NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ this.notifier = new BuildNotifier(monitor, this.currentProject); this.notifier.begin(); try { this.notifier.checkCancel(); initializeBuilder(CLEAN_BUILD, true); if (DEBUG) System.out.println("JavaBuilder: Clearing last state as part of clean : " + this.lastState); //$NON-NLS-1$ clearLastState(); removeProblemsAndTasksFor(this.currentProject); new BatchImageBuilder(this, false).cleanOutputFolders(false); } catch (CoreException e) { Util.log(e, "JavaBuilder handling CoreException while cleaning: " + this.currentProject.getName()); //$NON-NLS-1$ createInconsistentBuildMarker(e); } finally { this.notifier.done(); cleanup(); } if (DEBUG) System.out.println("JavaBuilder: Finished cleaning " + this.currentProject.getName() //$NON-NLS-1$ + " @ " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ }
Example 10
Source File: IncrementalImageBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void deleteGeneratedFiles(IFile[] deletedGeneratedFiles) { // delete generated files and recompile any affected source files try { for (int j = deletedGeneratedFiles.length; --j >= 0;) { IFile deletedFile = deletedGeneratedFiles[j]; if (deletedFile.exists()) continue; // only delete .class files for source files that were actually deleted SourceFile sourceFile = findSourceFile(deletedFile, false); String typeLocator = sourceFile.typeLocator(); int mdSegmentCount = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount(); IPath typePath = sourceFile.resource.getFullPath().removeFirstSegments(mdSegmentCount).removeFileExtension(); addDependentsOf(typePath, true); // add dependents of the source file since its now deleted this.previousSourceFiles = null; // existing source files did not see it as deleted since they were compiled before it was char[][] definedTypeNames = this.newState.getDefinedTypeNamesFor(typeLocator); if (definedTypeNames == null) { // defined a single type matching typePath removeClassFile(typePath, sourceFile.sourceLocation.binaryFolder); } else { if (definedTypeNames.length > 0) { // skip it if it failed to successfully define a type IPath packagePath = typePath.removeLastSegments(1); for (int d = 0, l = definedTypeNames.length; d < l; d++) removeClassFile(packagePath.append(new String(definedTypeNames[d])), sourceFile.sourceLocation.binaryFolder); } } this.newState.removeLocator(typeLocator); } } catch (CoreException e) { // must continue with compile loop so just log the CoreException Util.log(e, "JavaBuilder logging CompilationParticipant's CoreException to help debugging"); //$NON-NLS-1$ } }
Example 11
Source File: MethodBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see IMethodBinding#getParameterTypes() */ public ITypeBinding[] getParameterTypes() { if (this.parameterTypes != null) { return this.parameterTypes; } org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] parameters = this.binding.parameters; int length = parameters == null ? 0 : parameters.length; if (length == 0) { return this.parameterTypes = NO_TYPE_BINDINGS; } else { ITypeBinding[] paramTypes = new ITypeBinding[length]; for (int i = 0; i < length; i++) { final TypeBinding parameterBinding = parameters[i]; if (parameterBinding != null) { ITypeBinding typeBinding = this.resolver.getTypeBinding(parameterBinding); if (typeBinding == null) { return this.parameterTypes = NO_TYPE_BINDINGS; } paramTypes[i] = typeBinding; } else { // log error StringBuffer message = new StringBuffer("Report method binding where a parameter is null:\n"); //$NON-NLS-1$ message.append(toString()); Util.log(new IllegalArgumentException(), message.toString()); // report no binding since one or more parameter has no binding return this.parameterTypes = NO_TYPE_BINDINGS; } } return this.parameterTypes = paramTypes; } }
Example 12
Source File: JavaModelManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public AbstractAnnotationProcessorManager createAnnotationProcessorManager() { synchronized(this) { if (this.annotationProcessorManagerFactory == null) { IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID, ANNOTATION_PROCESSOR_MANAGER_EXTPOINT_ID); if (extension == null) return null; IExtension[] extensions = extension.getExtensions(); for(int i = 0; i < extensions.length; i++) { if (i > 0) { Util.log(null, "An annotation processor manager is already registered: ignoring " + extensions[i].getUniqueIdentifier()); //$NON-NLS-1$ break; } IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); for(int j = 0; j < configElements.length; j++) { final IConfigurationElement configElement = configElements[j]; if ("annotationProcessorManager".equals(configElement.getName())) { //$NON-NLS-1$ this.annotationProcessorManagerFactory = configElement; break; } } } } } if (this.annotationProcessorManagerFactory == null) { return null; } final AbstractAnnotationProcessorManager[] apm = new AbstractAnnotationProcessorManager[1]; apm[0] = null; final IConfigurationElement factory = this.annotationProcessorManagerFactory; SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { Util.log(exception, "Exception occurred while loading annotation processor manager"); //$NON-NLS-1$ } public void run() throws Exception { Object executableExtension = factory.createExecutableExtension("class"); //$NON-NLS-1$ if (executableExtension instanceof AbstractAnnotationProcessorManager) { apm[0] = (AbstractAnnotationProcessorManager) executableExtension; } } }); return apm[0]; }
Example 13
Source File: JavaModelManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static void recreatePersistedContainer(final IJavaProject project, final IPath containerPath, String containerString, boolean addToContainerValues) { if (!project.getProject().isAccessible()) return; // avoid leaking deleted project's persisted container if (containerString == null) { getJavaModelManager().containerPut(project, containerPath, null); } else { IClasspathEntry[] entries; try { entries = ((JavaProject) project).decodeClasspath(containerString, null/*not interested in unknown elements*/)[0]; } catch (IOException e) { Util.log(e, "Could not recreate persisted container: \n" + containerString); //$NON-NLS-1$ entries = JavaProject.INVALID_CLASSPATH; } if (entries != JavaProject.INVALID_CLASSPATH) { final IClasspathEntry[] containerEntries = entries; IClasspathContainer container = new IClasspathContainer() { public IClasspathEntry[] getClasspathEntries() { return containerEntries; } public String getDescription() { return "Persisted container ["+containerPath+" for project ["+ project.getElementName()+"]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ } public int getKind() { return 0; } public IPath getPath() { return containerPath; } public String toString() { return getDescription(); } }; if (addToContainerValues) { getJavaModelManager().containerPut(project, containerPath, container); } Map projectContainers = (Map)getJavaModelManager().previousSessionContainers.get(project); if (projectContainers == null){ projectContainers = new HashMap(1); getJavaModelManager().previousSessionContainers.put(project, projectContainers); } projectContainers.put(containerPath, container); } } }
Example 14
Source File: CommentFormatterUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Logs the given throwable. * * @param t the throwable * @since 3.1 */ public static void log(Throwable t) { Util.log(t, "Exception occured while formatting comments"); //$NON-NLS-1$ }