Java Code Examples for org.eclipse.jdt.core.IType#getTypeParameter()
The following examples show how to use
org.eclipse.jdt.core.IType#getTypeParameter() .
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: SelectionRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void acceptLocalTypeParameter(TypeVariableBinding typeVariableBinding) { IJavaElement res; if(typeVariableBinding.declaringElement instanceof ParameterizedTypeBinding) { LocalTypeBinding localTypeBinding = (LocalTypeBinding)((ParameterizedTypeBinding)typeVariableBinding.declaringElement).genericType(); res = findLocalElement(localTypeBinding.sourceStart()); } else { SourceTypeBinding typeBinding = (SourceTypeBinding)typeVariableBinding.declaringElement; res = findLocalElement(typeBinding.sourceStart()); } if (res != null && res.getElementType() == IJavaElement.TYPE) { IType type = (IType) res; ITypeParameter typeParameter = type.getTypeParameter(new String(typeVariableBinding.sourceName)); if (typeParameter.exists()) { addElement(typeParameter); if(SelectionEngine.DEBUG){ System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ System.out.print(typeParameter.toString()); System.out.println(")"); //$NON-NLS-1$ } } } }
Example 2
Source File: RenameTypeParameterProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public Object getNewElement() throws CoreException { IMember member= fTypeParameter.getDeclaringMember(); if (member instanceof IType) { IType type= (IType) member; return type.getTypeParameter(getNewElementName()); } else if (member instanceof IMethod) { IMethod method= (IMethod) member; return method.getTypeParameter(getNewElementName()); } else { JavaLanguageServerPlugin.logError("Unexpected sub-type of IMember: " + member.getClass().getName()); //$NON-NLS-1$ Assert.isTrue(false); } return null; }
Example 3
Source File: RenameTypeParameterProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Object getNewElement() throws CoreException { IMember member= fTypeParameter.getDeclaringMember(); if (member instanceof IType) { IType type= (IType) member; return type.getTypeParameter(getNewElementName()); } else if (member instanceof IMethod) { IMethod method= (IMethod) member; return method.getTypeParameter(getNewElementName()); } else { JavaPlugin.logErrorMessage("Unexpected sub-type of IMember: " + member.getClass().getName()); //$NON-NLS-1$ Assert.isTrue(false); } return null; }
Example 4
Source File: SelectionRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void acceptTypeParameter(char[] declaringTypePackageName, char[] declaringTypeName, char[] typeParameterName, boolean isDeclaration, int start, int end) { IType type; if(isDeclaration) { type = resolveTypeByLocation(declaringTypePackageName, declaringTypeName, NameLookup.ACCEPT_ALL, start, end); } else { type = resolveType(declaringTypePackageName, declaringTypeName, NameLookup.ACCEPT_ALL); } if(type != null) { ITypeParameter typeParameter = type.getTypeParameter(new String(typeParameterName)); if(typeParameter == null) { addElement(type); if(SelectionEngine.DEBUG){ System.out.print("SELECTION - accept type("); //$NON-NLS-1$ System.out.print(type.toString()); System.out.println(")"); //$NON-NLS-1$ } } else { addElement(typeParameter); if(SelectionEngine.DEBUG){ System.out.print("SELECTION - accept type parameter("); //$NON-NLS-1$ System.out.print(typeParameter.toString()); System.out.println(")"); //$NON-NLS-1$ } } } }
Example 5
Source File: SourceMapper.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * @see ISourceElementRequestor */ public void enterType(TypeInfo typeInfo) { this.typeDepth++; if (this.typeDepth == this.types.length) { // need to grow System.arraycopy( this.types, 0, this.types = new IType[this.typeDepth * 2], 0, this.typeDepth); System.arraycopy( this.typeNameRanges, 0, this.typeNameRanges = new SourceRange[this.typeDepth * 2], 0, this.typeDepth); System.arraycopy( this.typeDeclarationStarts, 0, this.typeDeclarationStarts = new int[this.typeDepth * 2], 0, this.typeDepth); System.arraycopy( this.memberName, 0, this.memberName = new String[this.typeDepth * 2], 0, this.typeDepth); System.arraycopy( this.memberDeclarationStart, 0, this.memberDeclarationStart = new int[this.typeDepth * 2], 0, this.typeDepth); System.arraycopy( this.memberNameRange, 0, this.memberNameRange = new SourceRange[this.typeDepth * 2], 0, this.typeDepth); System.arraycopy( this.methodParameterTypes, 0, this.methodParameterTypes = new char[this.typeDepth * 2][][], 0, this.typeDepth); System.arraycopy( this.methodParameterNames, 0, this.methodParameterNames = new char[this.typeDepth * 2][][], 0, this.typeDepth); System.arraycopy( this.typeModifiers, 0, this.typeModifiers = new int[this.typeDepth * 2], 0, this.typeDepth); } if (typeInfo.name.length == 0) { this.anonymousCounter++; if (this.anonymousCounter == this.anonymousClassName) { this.types[this.typeDepth] = getType(this.binaryType.getElementName()); } else { this.types[this.typeDepth] = getType(new String(typeInfo.name)); } } else { this.types[this.typeDepth] = getType(new String(typeInfo.name)); } this.typeNameRanges[this.typeDepth] = new SourceRange(typeInfo.nameSourceStart, typeInfo.nameSourceEnd - typeInfo.nameSourceStart + 1); this.typeDeclarationStarts[this.typeDepth] = typeInfo.declarationStart; IType currentType = this.types[this.typeDepth]; // type parameters if (typeInfo.typeParameters != null) { for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) { TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i]; ITypeParameter typeParameter = currentType.getTypeParameter(new String(typeParameterInfo.name)); setSourceRange( typeParameter, new SourceRange( typeParameterInfo.declarationStart, typeParameterInfo.declarationEnd - typeParameterInfo.declarationStart + 1), new SourceRange( typeParameterInfo.nameSourceStart, typeParameterInfo.nameSourceEnd - typeParameterInfo.nameSourceStart + 1)); } } // type modifiers this.typeModifiers[this.typeDepth] = typeInfo.modifiers; // categories addCategories(currentType, typeInfo.categories); }