List of usage examples for org.eclipse.jdt.core IJavaElement LOCAL_VARIABLE
int LOCAL_VARIABLE
To view the source code for org.eclipse.jdt.core IJavaElement LOCAL_VARIABLE.
Click Source Link
From source file:org.jboss.tools.jst.jsp.jspeditor.info.JavaStringELInfoHover.java
License:Open Source License
private static String getInfoText(IJavaElement element, boolean allowImage, boolean useFullHTML) { long flags;//from w w w .j a v a 2s . c om switch (element.getElementType()) { case IJavaElement.LOCAL_VARIABLE: flags = LOCAL_VARIABLE_FLAGS; break; case IJavaElement.TYPE_PARAMETER: flags = TYPE_PARAMETER_FLAGS; break; default: flags = LABEL_FLAGS; break; } StringBuffer label = new StringBuffer(JavaElementLinks.getElementLabel(element, flags)); String imageName = null; if (allowImage) { URL imageUrl = JavaPlugin.getDefault().getImagesOnFSRegistry().getImageURL(element); if (imageUrl != null) { imageName = imageUrl.toExternalForm(); } } StringBuffer buf = new StringBuffer(); addImageAndLabel(buf, imageName, 16, 16, 2, 2, label.toString(), 2, 2, useFullHTML); return buf.toString(); }
From source file:org.jboss.tools.vscode.java.internal.handlers.DocumentSymbolHandler.java
License:Open Source License
public static int mapKind(IJavaElement element) { // /**/*from w w w . j a v a 2s . c o m*/ // * A symbol kind. // */ // export enum SymbolKind { // File = 1, // Module = 2, // Namespace = 3, // Package = 4, // Class = 5, // Method = 6, // Property = 7, // Field = 8, // Constructor = 9, // Enum = 10, // Interface = 11, // Function = 12, // Variable = 13, // Constant = 14, // String = 15, // Number = 16, // Boolean = 17, // Array = 18, // } switch (element.getElementType()) { case IJavaElement.ANNOTATION: return 7; // TODO: find a better mapping case IJavaElement.CLASS_FILE: case IJavaElement.COMPILATION_UNIT: return 1; case IJavaElement.FIELD: return 8; case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: return 2; case IJavaElement.INITIALIZER: return 9; case IJavaElement.LOCAL_VARIABLE: case IJavaElement.TYPE_PARAMETER: return 13; case IJavaElement.METHOD: return 12; case IJavaElement.PACKAGE_DECLARATION: return 3; case IJavaElement.TYPE: try { return (((IType) element).isInterface() ? 11 : 5); } catch (JavaModelException e) { return 5; //fallback } } return 15; }
From source file:org.jboss.tools.ws.jaxrs.core.jdt.DOMUtils.java
License:Open Source License
/** * Returns the ASTNode associated with the given java Element expectedType and found at the given location. This method will * perform faster as the initial parentNode is precisely defined (eg : TypeDeclaration or MethodDeclaration instead of * CompilationUnit)/*from w w w.ja va2 s . c om*/ * * @param compilationUnit * @param elementType * @param position * @return * @see {@link IJavaElement} */ //FIXME: this should be part of the visitor. static ASTNode getASTNodeByTypeAndLocation(final ASTNode parentNode, final int expectedType, final int location) { switch (parentNode.getNodeType()) { case ASTNode.COMPILATION_UNIT: @SuppressWarnings("unchecked") final List<ASTNode> types = ((CompilationUnit) parentNode).types(); for (ASTNode type : types) { if (nodeMatches(type, location)) { if (expectedType == IJavaElement.TYPE) { return type; } // could also be ANNOTATION_TYPE_DECLARATION, which doesn't need to trigger recursive call to this // method. if (type.getNodeType() == CompilationUnit.TYPE_DECLARATION) { return getASTNodeByTypeAndLocation(type, expectedType, location); } } } break; case ASTNode.TYPE_DECLARATION: final FieldDeclaration[] fieldDeclarations = ((TypeDeclaration) parentNode).getFields(); for (FieldDeclaration fieldDeclaration : fieldDeclarations) { if (nodeMatches(fieldDeclaration, location)) { if (expectedType == IJavaElement.FIELD) { return fieldDeclaration; } } } final MethodDeclaration[] methodDeclarations = ((TypeDeclaration) parentNode).getMethods(); for (MethodDeclaration methodDeclaration : methodDeclarations) { if (nodeMatches(methodDeclaration, location)) { if (expectedType == IJavaElement.METHOD) { return methodDeclaration; } return getASTNodeByTypeAndLocation(methodDeclaration, expectedType, location); } } return null; case ASTNode.METHOD_DECLARATION: @SuppressWarnings("unchecked") final List<ASTNode> parameters = ((MethodDeclaration) parentNode).parameters(); for (ASTNode parameter : parameters) { if (nodeMatches(parameter, location)) { if (expectedType == IJavaElement.LOCAL_VARIABLE) { return parameter; } } } } return null; }
From source file:org.springframework.ide.eclipse.beans.ui.refactoring.actions.BeansRenameRefactorAction.java
License:Open Source License
private boolean isRenameAvailable(IJavaElement element) throws CoreException { switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: return RefactoringAvailabilityTester.isRenameAvailable((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return RefactoringAvailabilityTester.isRenameAvailable((IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return RefactoringAvailabilityTester.isRenameAvailable((IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return RefactoringAvailabilityTester.isRenameAvailable((ICompilationUnit) element); case IJavaElement.TYPE: return RefactoringAvailabilityTester.isRenameAvailable((IType) element); case IJavaElement.METHOD: final IMethod method = (IMethod) element; if (method.isConstructor()) return RefactoringAvailabilityTester.isRenameAvailable(method.getDeclaringType()); else/* ww w . j a v a2s .c o m*/ return RefactoringAvailabilityTester.isRenameAvailable(method); case IJavaElement.FIELD: final IField field = (IField) element; if (Flags.isEnum(field.getFlags())) return RefactoringAvailabilityTester.isRenameEnumConstAvailable(field); else return RefactoringAvailabilityTester.isRenameFieldAvailable(field); case IJavaElement.TYPE_PARAMETER: return RefactoringAvailabilityTester.isRenameAvailable((ITypeParameter) element); case IJavaElement.LOCAL_VARIABLE: return RefactoringAvailabilityTester.isRenameAvailable((ILocalVariable) element); } return false; }
From source file:org.summer.dsl.model.ui.refactoring.JdtRenameRefactoringProcessorFactory.java
License:Open Source License
public JavaRenameProcessor createRenameProcessor(IJavaElement element) { try {/*from w w w .j a v a2 s .c om*/ switch (element.getElementType()) { case IJavaElement.TYPE: return new RenameTypeProcessor((IType) element); case IJavaElement.FIELD: return new RenameFieldProcessor((IField) element); case IJavaElement.METHOD: if (((IMethod) element).isConstructor()) break; if (Flags.isStatic(((IMethod) element).getFlags())) return new RenameNonVirtualMethodProcessor((IMethod) element); else return new RenameVirtualMethodProcessor((IMethod) element); case IJavaElement.TYPE_PARAMETER: return new RenameTypeParameterProcessor((ITypeParameter) element); case IJavaElement.LOCAL_VARIABLE: return new RenameLocalVariableProcessor((ILocalVariable) element); } } catch (JavaModelException exc) { LOG.error("Error creating refactoring processor for " + element.getElementName(), exc); } return null; }
From source file:org.summer.dsl.xbase.ui.hover.HoverGenericsResolver.java
License:Open Source License
private static long getHeaderFlags(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.LOCAL_VARIABLE: return LOCAL_VARIABLE_FLAGS; case IJavaElement.TYPE_PARAMETER: return TYPE_PARAMETER_FLAGS; default://from w w w . j a va 2 s .com return LABEL_FLAGS; } }