Java Code Examples for org.eclipse.jdt.core.IJavaElement#LOCAL_VARIABLE
The following examples show how to use
org.eclipse.jdt.core.IJavaElement#LOCAL_VARIABLE .
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: JavaElementHyperlinkDeclaredTypeDetector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void addHyperlinks(List<IHyperlink> hyperlinksCollector, IRegion wordRegion, SelectionDispatchAction openAction, IJavaElement element, boolean qualify, JavaEditor editor) { try { if (element.getElementType() == IJavaElement.FIELD || element.getElementType() == IJavaElement.LOCAL_VARIABLE) { String typeSignature= getTypeSignature(element); if (!JavaModelUtil.isPrimitive(typeSignature) && SelectionConverter.canOperateOn(editor)) { if (Signature.getTypeSignatureKind(typeSignature) == Signature.INTERSECTION_TYPE_SIGNATURE) { String[] bounds= Signature.getIntersectionTypeBounds(typeSignature); qualify|= bounds.length >= 2; for (int i= 0; i < bounds.length; i++) { hyperlinksCollector.add(new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, bounds[i], qualify)); } } else { hyperlinksCollector.add(new JavaElementDeclaredTypeHyperlink(wordRegion, openAction, element, qualify)); } } } } catch (JavaModelException e) { JavaPlugin.log(e); } }
Example 2
Source File: RefactoringExecutionStarter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static RenameSupport createRenameSupport(IJavaElement element, String newName, int flags) throws CoreException { switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: return RenameSupport.create((IJavaProject) element, newName, flags); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return RenameSupport.create((IPackageFragmentRoot) element, newName); case IJavaElement.PACKAGE_FRAGMENT: return RenameSupport.create((IPackageFragment) element, newName, flags); case IJavaElement.COMPILATION_UNIT: return RenameSupport.create((ICompilationUnit) element, newName, flags); case IJavaElement.TYPE: return RenameSupport.create((IType) element, newName, flags); case IJavaElement.METHOD: final IMethod method= (IMethod) element; if (method.isConstructor()) return createRenameSupport(method.getDeclaringType(), newName, flags); else return RenameSupport.create((IMethod) element, newName, flags); case IJavaElement.FIELD: return RenameSupport.create((IField) element, newName, flags); case IJavaElement.TYPE_PARAMETER: return RenameSupport.create((ITypeParameter) element, newName, flags); case IJavaElement.LOCAL_VARIABLE: return RenameSupport.create((ILocalVariable) element, newName, flags); } return null; }
Example 3
Source File: SourceMapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public int getFlags(IJavaElement element) { switch(element.getElementType()) { case IJavaElement.LOCAL_VARIABLE : LocalVariableElementKey key = new LocalVariableElementKey(element.getParent(), element.getElementName()); if (this.finalParameters != null && this.finalParameters.contains(key)) { return Flags.AccFinal; } } return 0; }
Example 4
Source File: MatchLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public SearchMatch newDeclarationMatch( IJavaElement element, Binding binding, int accuracy, int offset, int length, SearchParticipant participant, IResource resource) { switch (element.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: return new PackageDeclarationMatch(element, accuracy, offset, length, participant, resource); case IJavaElement.TYPE: return new TypeDeclarationMatch(binding == null ? element : ((JavaElement) element).resolved(binding), accuracy, offset, length, participant, resource); case IJavaElement.FIELD: return new FieldDeclarationMatch(binding == null ? element : ((JavaElement) element).resolved(binding), accuracy, offset, length, participant, resource); case IJavaElement.METHOD: return new MethodDeclarationMatch(binding == null ? element : ((JavaElement) element).resolved(binding), accuracy, offset, length, participant, resource); case IJavaElement.LOCAL_VARIABLE: return new LocalVariableDeclarationMatch(element, accuracy, offset, length, participant, resource); case IJavaElement.PACKAGE_DECLARATION: return new PackageDeclarationMatch(element, accuracy, offset, length, participant, resource); case IJavaElement.TYPE_PARAMETER: return new TypeParameterDeclarationMatch(element, accuracy, offset, length, participant, resource); default: return null; } }
Example 5
Source File: JavadocHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; case IJavaElement.PACKAGE_FRAGMENT: return PACKAGE_FLAGS; default: return LABEL_FLAGS; } }
Example 6
Source File: JdtRenameRefactoringProcessorFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public JavaRenameProcessor createRenameProcessor(IJavaElement element) { try { switch (element.getElementType()) { case IJavaElement.TYPE: return new RenameTypeProcessor((IType) element); case IJavaElement.FIELD: if (((IField) element).getDeclaringType().isEnum()) return new RenameEnumConstProcessor((IField) element); else return new RenameFieldProcessor((IField) element); case IJavaElement.METHOD: if(((IMethod)element).isConstructor()) break; if (Flags.isStatic(((IMethod) element).getFlags()) || Flags.isPrivate(((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; }
Example 7
Source File: RefactoringAvailabilityTester.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean isRenameElementAvailable(IJavaElement element) throws CoreException { switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: return isRenameAvailable((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return isRenameAvailable((IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return isRenameAvailable((IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return isRenameAvailable((ICompilationUnit) element); case IJavaElement.TYPE: return isRenameAvailable((IType) element); case IJavaElement.METHOD: final IMethod method= (IMethod) element; if (method.isConstructor()) return isRenameAvailable(method.getDeclaringType()); else return isRenameAvailable(method); case IJavaElement.FIELD: final IField field= (IField) element; if (Flags.isEnum(field.getFlags())) return isRenameEnumConstAvailable(field); else return isRenameFieldAvailable(field); case IJavaElement.TYPE_PARAMETER: return isRenameAvailable((ITypeParameter) element); case IJavaElement.LOCAL_VARIABLE: return isRenameAvailable((ILocalVariable) element); } return false; }
Example 8
Source File: RefactoringAvailabilityTester.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static boolean isRenameElementAvailable(IJavaElement element) throws CoreException { switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: return isRenameAvailable((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return isRenameAvailable((IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return isRenameAvailable((IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return isRenameAvailable((ICompilationUnit) element); case IJavaElement.TYPE: return isRenameAvailable((IType) element); case IJavaElement.METHOD: final IMethod method = (IMethod) element; if (method.isConstructor()) { return isRenameAvailable(method.getDeclaringType()); } else { return isRenameAvailable(method); } case IJavaElement.FIELD: final IField field = (IField) element; if (Flags.isEnum(field.getFlags())) { return isRenameEnumConstAvailable(field); } else { return isRenameFieldAvailable(field); } case IJavaElement.TYPE_PARAMETER: return isRenameAvailable((ITypeParameter) element); case IJavaElement.LOCAL_VARIABLE: return isRenameAvailable((ILocalVariable) element); } return false; }
Example 9
Source File: RenameSupport.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static RenameSupport create(IJavaElement element, String newName, int flags) throws CoreException { switch (element.getElementType()) { case IJavaElement.JAVA_PROJECT: //return RenameSupport.create((IJavaProject) element, newName, flags); return null; case IJavaElement.PACKAGE_FRAGMENT_ROOT: //return RenameSupport.create((IPackageFragmentRoot) element, newName); return null; case IJavaElement.PACKAGE_FRAGMENT: return RenameSupport.create((IPackageFragment) element, newName, flags); case IJavaElement.COMPILATION_UNIT: return RenameSupport.create((ICompilationUnit) element, newName, flags); case IJavaElement.TYPE: return RenameSupport.create((IType) element, newName, flags); case IJavaElement.METHOD: final IMethod method = (IMethod) element; if (method.isConstructor()) { return create(method.getDeclaringType(), newName, flags); } else { return RenameSupport.create((IMethod) element, newName, flags); } case IJavaElement.FIELD: return RenameSupport.create((IField) element, newName, flags); case IJavaElement.TYPE_PARAMETER: return RenameSupport.create((ITypeParameter) element, newName, flags); case IJavaElement.LOCAL_VARIABLE: return RenameSupport.create((ILocalVariable) element, newName, flags); } return null; }
Example 10
Source File: GenericRefactoringHandleTransplanter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public final IJavaElement transplantHandle(IJavaElement element) { IJavaElement parent= element.getParent(); if (parent != null) parent= transplantHandle(parent); // recursive switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return transplantHandle((IJavaModel) element); case IJavaElement.JAVA_PROJECT: return transplantHandle((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return transplantHandle((IJavaProject) parent, (IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return transplantHandle((IPackageFragmentRoot) parent, (IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return transplantHandle((IPackageFragment) parent, (ICompilationUnit) element); case IJavaElement.CLASS_FILE: return transplantHandle((IPackageFragment) parent, (IClassFile) element); case IJavaElement.TYPE: return transplantHandle(parent, (IType) element); case IJavaElement.FIELD: return transplantHandle((IType) parent, (IField) element); case IJavaElement.METHOD: return transplantHandle((IType) parent, (IMethod) element); case IJavaElement.INITIALIZER: return transplantHandle((IType) parent, (IInitializer) element); case IJavaElement.PACKAGE_DECLARATION: return transplantHandle((ICompilationUnit) parent, (IPackageDeclaration) element); case IJavaElement.IMPORT_CONTAINER: return transplantHandle((ICompilationUnit) parent, (IImportContainer) element); case IJavaElement.IMPORT_DECLARATION: return transplantHandle((IImportContainer) parent, (IImportDeclaration) element); case IJavaElement.LOCAL_VARIABLE: return transplantHandle((ILocalVariable) element); case IJavaElement.TYPE_PARAMETER: return transplantHandle((IMember) parent, (ITypeParameter) element); case IJavaElement.ANNOTATION: return transplantHandle((IAnnotatable) parent, (IAnnotation) element); default: throw new IllegalArgumentException(element.toString()); } }
Example 11
Source File: JavaElementLabelComposer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
/** * Appends the label for a Java element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags. */ public void appendElementLabel(IJavaElement element, long flags) { int type= element.getElementType(); IPackageFragmentRoot root= null; if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) { root= JavaModelUtil.getPackageFragmentRoot(element); } if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) { appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); fBuilder.append(JavaElementLabels.CONCAT_STRING); } switch (type) { case IJavaElement.METHOD: appendMethodLabel((IMethod) element, flags); break; case IJavaElement.FIELD: appendFieldLabel((IField) element, flags); break; case IJavaElement.LOCAL_VARIABLE: appendLocalVariableLabel((ILocalVariable) element, flags); break; case IJavaElement.TYPE_PARAMETER: appendTypeParameterLabel((ITypeParameter) element, flags); break; case IJavaElement.INITIALIZER: appendInitializerLabel((IInitializer) element, flags); break; case IJavaElement.TYPE: appendTypeLabel((IType) element, flags); break; case IJavaElement.CLASS_FILE: appendClassFileLabel((IClassFile) element, flags); break; case IJavaElement.COMPILATION_UNIT: appendCompilationUnitLabel((ICompilationUnit) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT: appendPackageFragmentLabel((IPackageFragment) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags); break; case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.PACKAGE_DECLARATION: appendDeclarationLabel(element, flags); break; case IJavaElement.JAVA_PROJECT: case IJavaElement.JAVA_MODEL: fBuilder.append(element.getElementName()); break; default: fBuilder.append(element.getElementName()); } if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) { fBuilder.append(JavaElementLabels.CONCAT_STRING); appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); } }
Example 12
Source File: ProblemsLabelDecorator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Computes the adornment flags for the given element. * * @param obj the element to compute the flags for * * @return the adornment flags */ protected int computeAdornmentFlags(Object obj) { try { if (obj instanceof IJavaElement) { IJavaElement element= (IJavaElement) obj; int type= element.getElementType(); switch (type) { case IJavaElement.JAVA_MODEL: case IJavaElement.JAVA_PROJECT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: int flags= getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null); switch (type) { case IJavaElement.PACKAGE_FRAGMENT_ROOT: IPackageFragmentRoot root= (IPackageFragmentRoot) element; if (flags != ERRORTICK_ERROR && root.getKind() == IPackageFragmentRoot.K_SOURCE && isIgnoringOptionalProblems(root.getRawClasspathEntry())) { flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS; } break; case IJavaElement.JAVA_PROJECT: IJavaProject project= (IJavaProject) element; if (flags != ERRORTICK_ERROR && flags != ERRORTICK_BUILDPATH_ERROR && isIgnoringOptionalProblems(project)) { flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS; } break; } return flags; case IJavaElement.PACKAGE_FRAGMENT: return getPackageErrorTicksFromMarkers((IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null); case IJavaElement.PACKAGE_DECLARATION: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.IMPORT_CONTAINER: case IJavaElement.TYPE: case IJavaElement.INITIALIZER: case IJavaElement.METHOD: case IJavaElement.FIELD: case IJavaElement.LOCAL_VARIABLE: ICompilationUnit cu= (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { ISourceReference ref= (type == IJavaElement.COMPILATION_UNIT) ? null : (ISourceReference) element; // The assumption is that only source elements in compilation unit can have markers IAnnotationModel model= isInJavaAnnotationModel(cu); int result= 0; if (model != null) { // open in Java editor: look at annotation model result= getErrorTicksFromAnnotationModel(model, ref); } else { result= getErrorTicksFromMarkers(cu.getResource(), IResource.DEPTH_ONE, ref); } fCachedRange= null; return result; } break; default: } } else if (obj instanceof IResource) { return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null); } } catch (CoreException e) { if (e instanceof JavaModelException) { if (((JavaModelException) e).isDoesNotExist()) { return 0; } } if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) { return 0; } JavaPlugin.log(e); } return 0; }
Example 13
Source File: GenericRefactoringHandleTransplanter.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public final IJavaElement transplantHandle(IJavaElement element) { IJavaElement parent= element.getParent(); if (parent != null) { parent= transplantHandle(parent); // recursive } switch (element.getElementType()) { case IJavaElement.JAVA_MODEL: return transplantHandle((IJavaModel) element); case IJavaElement.JAVA_PROJECT: return transplantHandle((IJavaProject) element); case IJavaElement.PACKAGE_FRAGMENT_ROOT: return transplantHandle((IJavaProject) parent, (IPackageFragmentRoot) element); case IJavaElement.PACKAGE_FRAGMENT: return transplantHandle((IPackageFragmentRoot) parent, (IPackageFragment) element); case IJavaElement.COMPILATION_UNIT: return transplantHandle((IPackageFragment) parent, (ICompilationUnit) element); case IJavaElement.CLASS_FILE: return transplantHandle((IPackageFragment) parent, (IClassFile) element); case IJavaElement.TYPE: return transplantHandle(parent, (IType) element); case IJavaElement.FIELD: return transplantHandle((IType) parent, (IField) element); case IJavaElement.METHOD: return transplantHandle((IType) parent, (IMethod) element); case IJavaElement.INITIALIZER: return transplantHandle((IType) parent, (IInitializer) element); case IJavaElement.PACKAGE_DECLARATION: return transplantHandle((ICompilationUnit) parent, (IPackageDeclaration) element); case IJavaElement.IMPORT_CONTAINER: return transplantHandle((ICompilationUnit) parent, (IImportContainer) element); case IJavaElement.IMPORT_DECLARATION: return transplantHandle((IImportContainer) parent, (IImportDeclaration) element); case IJavaElement.LOCAL_VARIABLE: return transplantHandle((ILocalVariable) element); case IJavaElement.TYPE_PARAMETER: return transplantHandle((IMember) parent, (ITypeParameter) element); case IJavaElement.ANNOTATION: return transplantHandle((IAnnotatable) parent, (IAnnotation) element); default: throw new IllegalArgumentException(element.toString()); } }
Example 14
Source File: ParameterGuesser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public Variable createVariable(IJavaElement element, IType enclosingType, String expectedType, int positionScore) throws JavaModelException { int variableType; int elementType= element.getElementType(); String elementName= element.getElementName(); String typeSignature; switch (elementType) { case IJavaElement.FIELD: { IField field= (IField) element; if (field.getDeclaringType().equals(enclosingType)) { variableType= Variable.FIELD; } else { variableType= Variable.INHERITED_FIELD; } if (field.isResolved()) { typeSignature= new BindingKey(field.getKey()).toSignature(); } else { typeSignature= field.getTypeSignature(); } break; } case IJavaElement.LOCAL_VARIABLE: { ILocalVariable locVar= (ILocalVariable) element; variableType= Variable.LOCAL; typeSignature= locVar.getTypeSignature(); break; } case IJavaElement.METHOD: { IMethod method= (IMethod) element; if (isMethodToSuggest(method)) { if (method.getDeclaringType().equals(enclosingType)) { variableType= Variable.METHOD; } else { variableType= Variable.INHERITED_METHOD; } if (method.isResolved()) { typeSignature= Signature.getReturnType(new BindingKey(method.getKey()).toSignature()); } else { typeSignature= method.getReturnType(); } elementName= elementName + "()"; //$NON-NLS-1$ } else { return null; } break; } default: return null; } String type= Signature.toString(typeSignature); boolean isAutoboxMatch= isPrimitiveType(expectedType) != isPrimitiveType(type); return new Variable(type, elementName, variableType, isAutoboxMatch, positionScore, NO_TRIGGERS, getImageDescriptor(element)); }
Example 15
Source File: JavaElementLabelComposer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Appends the label for a Java element with the flags as defined by this class. * * @param element the element to render * @param flags the rendering flags. */ public void appendElementLabel(IJavaElement element, long flags) { int type= element.getElementType(); IPackageFragmentRoot root= null; if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT) root= JavaModelUtil.getPackageFragmentRoot(element); if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) { appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); fBuffer.append(JavaElementLabels.CONCAT_STRING); } switch (type) { case IJavaElement.METHOD: appendMethodLabel((IMethod) element, flags); break; case IJavaElement.FIELD: appendFieldLabel((IField) element, flags); break; case IJavaElement.LOCAL_VARIABLE: appendLocalVariableLabel((ILocalVariable) element, flags); break; case IJavaElement.TYPE_PARAMETER: appendTypeParameterLabel((ITypeParameter) element, flags); break; case IJavaElement.INITIALIZER: appendInitializerLabel((IInitializer) element, flags); break; case IJavaElement.TYPE: appendTypeLabel((IType) element, flags); break; case IJavaElement.CLASS_FILE: appendClassFileLabel((IClassFile) element, flags); break; case IJavaElement.COMPILATION_UNIT: appendCompilationUnitLabel((ICompilationUnit) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT: appendPackageFragmentLabel((IPackageFragment) element, flags); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags); break; case IJavaElement.IMPORT_CONTAINER: case IJavaElement.IMPORT_DECLARATION: case IJavaElement.PACKAGE_DECLARATION: appendDeclarationLabel(element, flags); break; case IJavaElement.JAVA_PROJECT: case IJavaElement.JAVA_MODEL: fBuffer.append(element.getElementName()); break; default: fBuffer.append(element.getElementName()); } if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) { int offset= fBuffer.length(); fBuffer.append(JavaElementLabels.CONCAT_STRING); appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED); if (getFlag(flags, JavaElementLabels.COLORIZE)) { fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE); } } }
Example 16
Source File: LocalVariableLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
protected int referenceType() { return IJavaElement.LOCAL_VARIABLE; }
Example 17
Source File: ParameterGuesser.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public Variable createVariable(IJavaElement element, IType enclosingType, String expectedType, int positionScore) throws JavaModelException { int variableType; int elementType= element.getElementType(); String elementName= element.getElementName(); String typeSignature; switch (elementType) { case IJavaElement.FIELD: { IField field= (IField) element; if (field.getDeclaringType().equals(enclosingType)) { variableType= Variable.FIELD; } else { variableType= Variable.INHERITED_FIELD; } if (field.isResolved()) { typeSignature= new BindingKey(field.getKey()).toSignature(); } else { typeSignature= field.getTypeSignature(); } break; } case IJavaElement.LOCAL_VARIABLE: { ILocalVariable locVar= (ILocalVariable) element; variableType= Variable.LOCAL; typeSignature= locVar.getTypeSignature(); break; } case IJavaElement.METHOD: { IMethod method= (IMethod) element; if (isMethodToSuggest(method)) { if (method.getDeclaringType().equals(enclosingType)) { variableType= Variable.METHOD; } else { variableType= Variable.INHERITED_METHOD; } if (method.isResolved()) { typeSignature= Signature.getReturnType(new BindingKey(method.getKey()).toSignature()); } else { typeSignature= method.getReturnType(); } elementName= elementName + "()"; //$NON-NLS-1$ } else { return null; } break; } default: return null; } String type= Signature.toString(typeSignature); boolean isAutoboxMatch= isPrimitiveType(expectedType) != isPrimitiveType(type); return new Variable(type, elementName, variableType, isAutoboxMatch, positionScore); }