APISonar


org.eclipse.jdt.internal.core.util.Util.log

> org > eclipse > jdt > internal > core > util > Util > log
org APIs eclipse APIs jdt APIs internal APIs core APIs util APIs Util APIs log APIs

Example 1
private double getOpenableRatio() {
	String property = System.getProperty(RATIO_PROPERTY);
	if (property != null) {
		try {
			return Double.parseDouble(property);
		} catch (NumberFormatException e) {
			// ignore
			Util.log(e, "Could not parse value for " + RATIO_PROPERTY + ": " + property); //$NON-NLS-1$ //$NON-NLS-2$
		}
	}
	return 1.0;
}
Example 2
private static void log(final Throwable t, final String form, final Object... args) {
        String m = "Groovy-Eclipse Type Inferencing: " + String.format(form, args);
        Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, m, t);
        Util.log(s);
    }
Example 3
private static void log(Exception e) {
		if (JavaCore.getPlugin()==null || JavaCore.getPlugin().getLog()==null) {
			System.err.println("Error creating Groovy language support:"); //$NON-NLS-1$
			e.printStackTrace(System.err);
		} else {
			Util.log(e, "Error creating Groovy language support"); //$NON-NLS-1$
		}
	}
Example 4
public void setGroovyCompilerLevel(IProject project, String level) {
        IEclipsePreferences preferences = getProjectPreferences(project);
        if (preferences != null) {
            preferences.put(GROOVY_COMPILER_LEVEL, level);
            try {
                preferences.flush();
            } catch (BackingStoreException e) {
                Util.log(e);
            }
        }
    }
Example 5
public void setGroovyCompilerLevel(IProject project, String level) {
		IEclipsePreferences projectPreferences = getProjectScope(project);
		if (projectPreferences != null) {
			projectPreferences.put(GROOVY_COMPILER_LEVEL, level);
			try {
				projectPreferences.flush();
			} catch (BackingStoreException e) {
				Util.log(e);
			}
		}
	}
Example 6
private List<Token> getTokensIncludingEOF() {
        List<Token> result = new ArrayList<Token>();
        Token token;
        try {
            do {
                token = nextToken();
                result.add(token);
            } while (token.getType() != GroovyTokenTypeBridge.EOF);
        } catch (Exception e) {
            if (logLimit-- > 0) {
                Util.log(e);
            }
        }
        return result;
    }
Example 7
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 8
public IModule getModule() {
		IModuleDescription desc = getModuleDescription();
		if (desc != null) {
			try {
				return (IModule)((JavaElement) desc).getElementInfo();
			} catch (JavaModelException e) {
				Util.log(e);
			}
		}
		return null;
	}
Example 9
private static boolean isGroovyLikeSourceUnit(ICompilationUnit sourceUnit) {
        if (sourceUnit.getFileName() == null || !isJavaLikeButNotGroovyLikeFileName(new CharArraySequence(sourceUnit.getFileName()))) {
            if (GROOVY_SOURCE_DISCRIMINATOR.matcher(new CharArraySequence(sourceUnit.getContents())).find()) {
                Util.log(1, "Identified a Groovy source unit through inspection of its contents: " +
                    String.valueOf(sourceUnit.getContents(), 0, Math.min(250, sourceUnit.getContents().length)));
                return true;
            }
        }
        return false;
    }
Example 10
private HighlightedTypedPosition handleAnnotationElement(AnnotationNode anno, MethodNode elem) {
        try {
            int start = anno.getStart(), until = anno.getEnd();
            String source = unit.getSource().substring(start, until);

            // search for the element label in the source since no AST node exists for it
            Matcher m = Pattern.compile("\\b" + Pattern.quote(elem.getName()) + "\\b").matcher(source);
            if (m.find()) {
                return new HighlightedTypedPosition(start + m.start(), elem.getName().length(), HighlightKind.TAG_KEY);
            }
        } catch (Exception e) {
            Util.log(e);
        }
        return null;
    }
Example 11
private IClasspathEntry[][] readFileEntries(Map unkwownElements) {
		try {
			return readFileEntriesWithException(unkwownElements);
		} catch (CoreException e) {
			Util.log(e, "Exception while reading " + getPath().append(JavaProject.CLASSPATH_FILENAME)); //$NON-NLS-1$
			return new IClasspathEntry[][]{JavaProject.INVALID_CLASSPATH, ClasspathEntry.NO_ENTRIES};
		} catch (IOException e) {
			Util.log(e, "Exception while reading " + getPath().append(JavaProject.CLASSPATH_FILENAME)); //$NON-NLS-1$
			return new IClasspathEntry[][]{JavaProject.INVALID_CLASSPATH, ClasspathEntry.NO_ENTRIES};
		} catch (ClasspathEntry.AssertionFailedException e) {
			Util.log(e, "Exception while reading " + getPath().append(JavaProject.CLASSPATH_FILENAME)); //$NON-NLS-1$
			return new IClasspathEntry[][]{JavaProject.INVALID_CLASSPATH, ClasspathEntry.NO_ENTRIES};
		}
	}
Example 12
public static IType findType(String fullyQualifiedName, IJavaElement referenceContext) {
        try {
            IJavaProject project = referenceContext.getJavaProject();
            return project.findType(fullyQualifiedName.replace('$', '.'), (IProgressMonitor) null);
        } catch (JavaModelException e) {
            Util.log(e);
            return null;
        }
    }
Example 13
public static void unregisterClassFile(IPath annotationBase, IPath relativeAnnotationPath) {
		int baseDepth = annotationBase.segmentCount();
		if (baseDepth == 0) {
			Util.log(new IllegalArgumentException("annotationBase cannot be empty")); //$NON-NLS-1$
		} else {
			relativeAnnotationPath = relativeAnnotationPath.addFileExtension(ExternalAnnotationProvider.ANNOTATION_FILE_EXTENSION);
			DirectoryNode base = singleton.getAnnotationBase(singleton.tree, annotationBase, baseDepth, 1);
			base.unregisterClassFile(relativeAnnotationPath);
		}
	}
Example 14
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 15
public static void removeClasspathVariable(String variableName, IProgressMonitor monitor) {
		try {
			SetVariablesOperation operation = new SetVariablesOperation(new String[]{ variableName}, new IPath[]{ null }, true/*update preferences*/);
			operation.runOperation(monitor);
		} catch (JavaModelException e) {
			Util.log(e, "Exception while removing variable " + variableName); //$NON-NLS-1$
		}
	}
Example 16
private void replaceWhiteSpaceAfter(MultiTextEdit edits, Token token, String replaceWith) {
        GroovyDocumentScanner tokens = formatter.getTokens();
        try {
            int editStart = tokens.getEnd(token);
            Token first = tokens.getNextToken(token); // first whitespace token (if any)
            Token last = first; // first non-whitespace token
            // if no white space tokens where found then first and last will be the same token (i.e. token just after the given token)
            while (isWhiteSpace(last.getType())) {
                last = tokens.getNextToken(last);
            }
            replaceFromTo(editStart, tokens.getOffset(last), replaceWith, edits);
        } catch (BadLocationException e) {
            Util.log(e);
        }
    }
Example 17
public void refreshReferences(IProject source, IProgressMonitor monitor) {
		IProject externalProject = getExternalFoldersProject();
		if (source.equals(externalProject))
			return;
		if (!JavaProject.hasJavaNature(source))
			return;
		try {
			Set<IPath> externalFolders = getExternalFolders(((JavaProject) JavaCore.create(source)).getResolvedClasspath());
			runRefreshJob(externalFolders);
		} catch (CoreException e) {
			Util.log(e, "Exception while refreshing external project"); //$NON-NLS-1$
		}
	}
Example 18
public static IMethod findMethod(MethodNode methodNode, IType declaringType) {
        try {
            char[] methodName = methodNode.getName().toCharArray();
            String[] paramTypes = GroovyUtils.getParameterTypeSignatures(methodNode, declaringType.isBinary());
            return Util.findMethod(declaringType, methodName, paramTypes, methodNode instanceof ConstructorNode);
        } catch (JavaModelException e) {
            Util.log(e);
            return null;
        }
    }
Example 19
protected void reportSearchMatch(IJavaElement element, Function<IJavaElement, SearchMatch> producer) {
        if (element.getOpenable() instanceof GroovyClassFileWorkingCopy) {
            element = ((GroovyClassFileWorkingCopy) element.getOpenable()).convertToBinary(element);
        }
        SearchMatch match = producer.apply(element);
        try {
            requestor.acceptSearchMatch(match);
        } catch (CoreException e) {
            Util.log(e, "Error reporting search match inside of " + element + " in resource " + element.getResource());
        }
    }
Example 20
protected boolean interestingElement(IJavaElement enclosingElement) {
        // the clinit is always interesting since it contains static initializers
        if (enclosingElement.getElementName().equals("<clinit>")) {
            return true;
        }
        if (enclosingElement instanceof ISourceReference) {
            try {
                ISourceRange range = ((ISourceReference) enclosingElement).getSourceRange();
                return range.getOffset() <= nodeToLookFor.getStart() && range.getOffset() + range.getLength() >= nodeToLookFor.getEnd();
            } catch (JavaModelException e) {
                Util.log(e);
            }
        }
        return false;
    }
Example 21
protected void cacheSuperclass(IType type, IType superclass) {
	if (superclass != null) {
		if (superclass.equals(type)) {
			Util.log(IStatus.ERROR, "Type "+type.getFullyQualifiedName()+" is it's own superclass");  //$NON-NLS-1$//$NON-NLS-2$
			return; // refuse to enter what could lead to a stackoverflow later
		}
		this.classToSuperclass.put(type, superclass);
		addSubtype(superclass, type);
	}
}
Example 22
private ITypeLookup[] createLookups(IProject project) {
		ITypeLookup[] lookups;
		try {
			List<ITypeLookup> lookupsList = TypeLookupRegistry.getRegistry().getLookupsFor(project);
			lookupsList.add(new CategoryTypeLookup());
			lookupsList.add(new SimpleTypeLookup());
			lookups = lookupsList.toArray(new ITypeLookup[0]);

		} catch (CoreException e) {
			Util.log(e, "Exception creating type lookups for project " + project.getName() + ".  Using default instead"); //$NON-NLS-1$ //$NON-NLS-2$
			lookups = new ITypeLookup[] { new CategoryTypeLookup(), new SimpleTypeLookup() };
		}
		return lookups;
	}
Example 23
public static boolean hasRunnableMain(IType type) {
        try {
            IMethod[] allMethods = type.getMethods();
            for (IMethod method : allMethods) {
                if (method.getElementName().equals("main") && Flags.isStatic(method.getFlags()) && // void or Object are valid return types
                    (method.getReturnType().equals("V") || method.getReturnType().endsWith("java.lang.Object;")) && hasAppropriateArrayArgsForMain(method.getParameterTypes())) {

                    return true;
                }
            }
        } catch (JavaModelException e) {
            Util.log(e, "Exception searching for main method in " + type);
        }
        return false;
    }