org.eclipse.jdt.core.dom.TypeParameter Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.TypeParameter.
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: NewCUProposal.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void addTypeParameters(TypeDeclaration newDeclaration) { if (isParameterizedType(fTypeKind, fNode)) { String typeArgBaseName = getGenericTypeArgBaseName(ASTNodes.getSimpleNameIdentifier(fNode)); int nTypeArgs = ((ParameterizedType) fNode.getParent().getParent()).typeArguments().size(); String[] typeArgNames = new String[nTypeArgs]; if (nTypeArgs == 1) { typeArgNames[0] = typeArgBaseName; } else { for (int i = 0; i < nTypeArgs; i++) { StringBuilder buf = new StringBuilder(typeArgBaseName); buf.append(i + 1); typeArgNames[i] = buf.toString(); } } AST ast = newDeclaration.getAST(); for (String typeArgName : typeArgNames) { TypeParameter typeArg = ast.newTypeParameter(); typeArg.setName(ast.newSimpleName(typeArgName)); newDeclaration.typeParameters().add(typeArg); } } }
Example #2
Source File: JavadocTagsSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private void insertAllMissingTypeTags(ASTRewrite rewriter, TypeDeclaration typeDecl) { AST ast= typeDecl.getAST(); Javadoc javadoc= typeDecl.getJavadoc(); ListRewrite tagsRewriter= rewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY); List<TypeParameter> typeParams= typeDecl.typeParameters(); for (int i= typeParams.size() - 1; i >= 0; i--) { TypeParameter decl= typeParams.get(i); String name= '<' + decl.getName().getIdentifier() + '>'; if (findTag(javadoc, TagElement.TAG_PARAM, name) == null) { TagElement newTag= ast.newTagElement(); newTag.setTagName(TagElement.TAG_PARAM); TextElement text= ast.newTextElement(); text.setText(name); newTag.fragments().add(text); insertTabStop(rewriter, newTag.fragments(), "typeParam" + i); //$NON-NLS-1$ insertTag(tagsRewriter, newTag, getPreviousTypeParamNames(typeParams, decl)); } } }
Example #3
Source File: CPlusPlusASTNodeWriter.java From juniversal with MIT License | 6 votes |
/** * Write out the type parameters in the specified list, surrounded by "<" and ">". * * @param typeParameters list of TypeParameter objects * @param includeClassKeyword if true, each parameter is prefixed with "class " */ public void writeTypeParameters(List typeParameters, boolean includeClassKeyword) { // If we're writing the implementation of a generic method, include the "template<...>" prefix write("<"); forEach(typeParameters, (TypeParameter typeParameter, boolean first) -> { if (!first) write(", "); if (includeClassKeyword) write("class "); write(typeParameter.getName().getIdentifier()); }); write(">"); }
Example #4
Source File: JavadocTagsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void insertAllMissingTypeTags(ASTRewrite rewriter, TypeDeclaration typeDecl) { AST ast= typeDecl.getAST(); Javadoc javadoc= typeDecl.getJavadoc(); ListRewrite tagsRewriter= rewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY); List<TypeParameter> typeParams= typeDecl.typeParameters(); for (int i= typeParams.size() - 1; i >= 0; i--) { TypeParameter decl= typeParams.get(i); String name= '<' + decl.getName().getIdentifier() + '>'; if (findTag(javadoc, TagElement.TAG_PARAM, name) == null) { TagElement newTag= ast.newTagElement(); newTag.setTagName(TagElement.TAG_PARAM); TextElement text= ast.newTextElement(); text.setText(name); newTag.fragments().add(text); insertTabStop(rewriter, newTag.fragments(), "typeParam" + i); //$NON-NLS-1$ insertTag(tagsRewriter, newTag, getPreviousTypeParamNames(typeParams, decl)); } } }
Example #5
Source File: StubUtility2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static void createTypeParameters(ImportRewrite imports, ImportRewriteContext context, AST ast, IMethodBinding binding, MethodDeclaration decl) { ITypeBinding[] typeParams= binding.getTypeParameters(); List<TypeParameter> typeParameters= decl.typeParameters(); for (int i= 0; i < typeParams.length; i++) { ITypeBinding curr= typeParams[i]; TypeParameter newTypeParam= ast.newTypeParameter(); newTypeParam.setName(ast.newSimpleName(curr.getName())); ITypeBinding[] typeBounds= curr.getTypeBounds(); if (typeBounds.length != 1 || !"java.lang.Object".equals(typeBounds[0].getQualifiedName())) {//$NON-NLS-1$ List<Type> newTypeBounds= newTypeParam.typeBounds(); for (int k= 0; k < typeBounds.length; k++) { newTypeBounds.add(imports.addImport(typeBounds[k], ast, context)); } } typeParameters.add(newTypeParam); } }
Example #6
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public boolean visit(final TypeParameter node) { node.getName().accept(this); boolean _isEmpty = node.typeBounds().isEmpty(); boolean _not = (!_isEmpty); if (_not) { this.appendToBuffer(" extends "); for (Iterator<Type> _it = node.typeBounds().iterator(); _it.hasNext();) { { Type t = _it.next(); t.accept(this); boolean _hasNext = _it.hasNext(); if (_hasNext) { this.appendToBuffer(" & "); } } } } return false; }
Example #7
Source File: MoveInnerToTopRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addEnclosingInstanceTypeParameters(final ITypeBinding[] parameters, final AbstractTypeDeclaration declaration, final ASTRewrite rewrite) { Assert.isNotNull(parameters); Assert.isNotNull(declaration); Assert.isNotNull(rewrite); if (declaration instanceof TypeDeclaration) { final TypeDeclaration type= (TypeDeclaration) declaration; final List<TypeParameter> existing= type.typeParameters(); final Set<String> names= new HashSet<String>(); TypeParameter parameter= null; for (final Iterator<TypeParameter> iterator= existing.iterator(); iterator.hasNext();) { parameter= iterator.next(); names.add(parameter.getName().getIdentifier()); } final ListRewrite rewriter= rewrite.getListRewrite(type, TypeDeclaration.TYPE_PARAMETERS_PROPERTY); String name= null; for (int index= 0; index < parameters.length; index++) { name= parameters[index].getName(); if (!names.contains(name)) { parameter= type.getAST().newTypeParameter(); parameter.setName(type.getAST().newSimpleName(name)); rewriter.insertLast(parameter, null); } } } }
Example #8
Source File: MoveInnerToTopRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static void addTypeParameters(final CompilationUnit unit, final IType type, final Map<String, ITypeBinding> map) throws JavaModelException { Assert.isNotNull(unit); Assert.isNotNull(type); Assert.isNotNull(map); final AbstractTypeDeclaration declaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode(type, unit); if (declaration instanceof TypeDeclaration) { ITypeBinding binding= null; TypeParameter parameter= null; for (final Iterator<TypeParameter> iterator= ((TypeDeclaration) declaration).typeParameters().iterator(); iterator.hasNext();) { parameter= iterator.next(); binding= parameter.resolveBinding(); if (binding != null && !map.containsKey(binding.getKey())) map.put(binding.getKey(), binding); } final IType declaring= type.getDeclaringType(); if (declaring != null && !JdtFlags.isStatic(type)) addTypeParameters(unit, declaring, map); } }
Example #9
Source File: IntroduceFactoryRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Copies the constructor's parent type's type parameters, if any, as * method type parameters of the new static factory method. (Recall * that static methods can't refer to type arguments of the enclosing * class, since they have no instance to serve as a context.)<br> * Makes sure to copy the bounds from the owning type, to ensure that the * return type of the factory method satisfies the bounds of the type * being instantiated.<br> * E.g., for ctor Foo() in the type Foo<T extends Number>, be sure that * the factory method is declared as<br> * <code>static <T extends Number> Foo<T> createFoo()</code><br> * and not simply<br> * <code>static <T> Foo<T> createFoo()</code><br> * or the compiler will bark. * @param ast utility object needed to create ASTNode's for the new method * @param newMethod the method onto which to copy the type parameters */ private void copyTypeParameters(AST ast, MethodDeclaration newMethod) { ITypeBinding[] ctorOwnerTypeParms= fCtorBinding.getDeclaringClass().getTypeParameters(); List<TypeParameter> factoryMethodTypeParms= newMethod.typeParameters(); for(int i= 0; i < ctorOwnerTypeParms.length; i++) { TypeParameter newParm= ast.newTypeParameter(); ITypeBinding[] parmTypeBounds= ctorOwnerTypeParms[i].getTypeBounds(); List<Type> newParmBounds= newParm.typeBounds(); newParm.setName(ast.newSimpleName(ctorOwnerTypeParms[i].getName())); for(int b=0; b < parmTypeBounds.length; b++) { if (parmTypeBounds[b].isClass() && parmTypeBounds[b].getSuperclass() == null) continue; Type newBound= fImportRewriter.addImport(parmTypeBounds[b], ast); newParmBounds.add(newBound); } factoryMethodTypeParms.add(newParm); } }
Example #10
Source File: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addTypeParameters(CompilationUnitRewrite imRewrite, List<TypeParameter> list, ITypeBinding parent) { ITypeBinding enclosing= parent.getDeclaringClass(); if (enclosing != null) addTypeParameters(imRewrite, list, enclosing); ITypeBinding[] typeParameters= parent.getTypeParameters(); for (int i= 0; i < typeParameters.length; i++) { TypeParameter ntp= imRewrite.getAST().newTypeParameter(); ntp.setName(imRewrite.getAST().newSimpleName(typeParameters[i].getName())); ITypeBinding[] bounds= typeParameters[i].getTypeBounds(); for (int j= 0; j < bounds.length; j++) if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) //$NON-NLS-1$ ntp.typeBounds().add(imRewrite.getImportRewrite().addImport(bounds[j], imRewrite.getAST())); list.add(ntp); } }
Example #11
Source File: ConvertAnonymousToNestedRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final boolean visit(TypeParameter parameter) { ITypeBinding binding= parameter.resolveBinding(); if (binding != null) { // don't collect type parameters declared inside the anonymous fBindings.put(binding.getKey(), binding); } return false; }
Example #12
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void endVisit(TypeParameter node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getName()); process(info, node.typeBounds()); }
Example #13
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(TypeParameter node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getName()); process(info, node.typeBounds()); }
Example #14
Source File: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void copyTypeParameters(MethodDeclaration intermediary, CompilationUnitRewrite rew) { ITypeBinding[] typeParameters= fTargetMethodBinding.getTypeParameters(); for (int i= 0; i < typeParameters.length; i++) { ITypeBinding current= typeParameters[i]; TypeParameter parameter= rew.getAST().newTypeParameter(); parameter.setName(rew.getAST().newSimpleName(current.getName())); ITypeBinding[] bounds= current.getTypeBounds(); for (int j= 0; j < bounds.length; j++) if (!"java.lang.Object".equals(bounds[j].getQualifiedName())) //$NON-NLS-1$ parameter.typeBounds().add(rew.getImportRewrite().addImport(bounds[j], rew.getAST())); intermediary.typeParameters().add(parameter); } }
Example #15
Source File: TypeContextChecker.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void appendTypeParameters(StringBuffer buf, List<TypeParameter> typeParameters) { int typeParametersCount= typeParameters.size(); if (typeParametersCount > 0) { buf.append('<'); for (int i= 0; i < typeParametersCount; i++) { TypeParameter typeParameter= typeParameters.get(i); buf.append(ASTNodes.asString(typeParameter)); if (i < typeParametersCount - 1) buf.append(','); } buf.append('>'); } }
Example #16
Source File: ScopeAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(TypeParameter node) { if (hasFlag(TYPES, fFlags) && node.getStartPosition() < fPosition) { fBreak= fRequestor.acceptBinding(node.getName().resolveBinding()); } return !fBreak; }
Example #17
Source File: ASTNodeFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static TypeParameter newTypeParameter(AST ast, String content) { StringBuffer buffer= new StringBuffer(TYPEPARAM_HEADER); buffer.append(content); buffer.append(TYPEPARAM_FOOTER); ASTParser p= ASTParser.newParser(ast.apiLevel()); p.setSource(buffer.toString().toCharArray()); CompilationUnit root= (CompilationUnit) p.createAST(null); List<AbstractTypeDeclaration> list= root.types(); TypeDeclaration typeDecl= (TypeDeclaration) list.get(0); MethodDeclaration methodDecl= typeDecl.getMethods()[0]; TypeParameter tp= (TypeParameter) methodDecl.typeParameters().get(0); ASTNode result= ASTNode.copySubtree(ast, tp); result.accept(new PositionClearer()); return (TypeParameter) result; }
Example #18
Source File: JavadocTagsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static Set<String> getPreviousTypeParamNames(List<TypeParameter> typeParams, ASTNode missingNode) { Set<String> previousNames= new HashSet<String>(); for (int i = 0; i < typeParams.size(); i++) { TypeParameter curr= typeParams.get(i); if (curr == missingNode) { return previousNames; } previousNames.add('<' + curr.getName().getIdentifier() + '>'); } return previousNames; }
Example #19
Source File: MoveInstanceMethodProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new generic reference finder. * * @param declaration * the method declaration */ public GenericReferenceFinder(final MethodDeclaration declaration) { Assert.isNotNull(declaration); ITypeBinding binding= null; TypeParameter parameter= null; for (final Iterator<TypeParameter> iterator= declaration.typeParameters().iterator(); iterator.hasNext();) { parameter= iterator.next(); binding= parameter.resolveBinding(); if (binding != null) fBindings.add(binding.getKey()); } }
Example #20
Source File: JavadocTagsSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public static Set<String> getPreviousTypeParamNames(List<TypeParameter> typeParams, ASTNode missingNode) { Set<String> previousNames= new HashSet<>(); for (int i = 0; i < typeParams.size(); i++) { TypeParameter curr= typeParams.get(i); if (curr == missingNode) { return previousNames; } previousNames.add('<' + curr.getName().getIdentifier() + '>'); } return previousNames; }
Example #21
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void appendTypeParameters(final Iterable<TypeParameter> iterable) { boolean _isEmpty = IterableExtensions.isEmpty(iterable); if (_isEmpty) { return; } this.appendToBuffer("<"); this.visitAllSeparatedByComma(iterable); this.appendToBuffer(">"); }
Example #22
Source File: ExtractSupertypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates the type parameters of the new supertype. * * @param targetRewrite * the target compilation unit rewrite * @param subType * the subtype * @param sourceDeclaration * the type declaration of the source type * @param targetDeclaration * the type declaration of the target type */ protected final void createTypeParameters(final CompilationUnitRewrite targetRewrite, final IType subType, final AbstractTypeDeclaration sourceDeclaration, final AbstractTypeDeclaration targetDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(sourceDeclaration); Assert.isNotNull(targetDeclaration); if (sourceDeclaration instanceof TypeDeclaration) { TypeParameter parameter= null; final ListRewrite rewrite= targetRewrite.getASTRewrite().getListRewrite(targetDeclaration, TypeDeclaration.TYPE_PARAMETERS_PROPERTY); for (final Iterator<TypeParameter> iterator= ((TypeDeclaration) sourceDeclaration).typeParameters().iterator(); iterator.hasNext();) { parameter= iterator.next(); final ASTNode node= ASTNode.copySubtree(targetRewrite.getAST(), parameter); rewrite.insertLast(node, null); } } }
Example #23
Source File: SuperTypeRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates the type parameters of the new supertype. * * @param targetRewrite * the target compilation unit rewrite * @param subType * the subtype * @param sourceDeclaration * the type declaration of the source type * @param targetDeclaration * the type declaration of the target type */ protected final void createTypeParameters(final ASTRewrite targetRewrite, final IType subType, final AbstractTypeDeclaration sourceDeclaration, final AbstractTypeDeclaration targetDeclaration) { Assert.isNotNull(targetRewrite); Assert.isNotNull(sourceDeclaration); Assert.isNotNull(targetDeclaration); if (sourceDeclaration instanceof TypeDeclaration) { TypeParameter parameter= null; final ListRewrite rewrite= targetRewrite.getListRewrite(targetDeclaration, TypeDeclaration.TYPE_PARAMETERS_PROPERTY); for (final Iterator<TypeParameter> iterator= ((TypeDeclaration) sourceDeclaration).typeParameters().iterator(); iterator.hasNext();) { parameter= iterator.next(); rewrite.insertLast(ASTNode.copySubtree(targetRewrite.getAST(), parameter), null); ImportRewriteUtil.collectImports(subType.getJavaProject(), sourceDeclaration, fTypeBindings, fStaticBindings, false); } } }
Example #24
Source File: MoveInnerToTopRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void updateConstructorReference(ITypeBinding[] parameters, ParameterizedType type, CompilationUnitRewrite targetRewrite, ICompilationUnit cu, TextEditGroup group) throws CoreException { final ListRewrite rewrite= targetRewrite.getASTRewrite().getListRewrite(type, ParameterizedType.TYPE_ARGUMENTS_PROPERTY); TypeParameter parameter= null; for (int index= type.typeArguments().size(); index < parameters.length; index++) { parameter= targetRewrite.getRoot().getAST().newTypeParameter(); parameter.setName(targetRewrite.getRoot().getAST().newSimpleName(parameters[index].getName())); rewrite.insertLast(parameter, group); } if (type.getParent() instanceof ClassInstanceCreation) updateConstructorReference((ClassInstanceCreation) type.getParent(), targetRewrite, cu, group); }
Example #25
Source File: CopyQualifiedNameAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private Object getSelectedElement(JavaEditor editor) { ISourceViewer viewer= editor.getViewer(); if (viewer == null) return null; Point selectedRange= viewer.getSelectedRange(); int length= selectedRange.y; int offset= selectedRange.x; ITypeRoot element= JavaUI.getEditorInputTypeRoot(editor.getEditorInput()); if (element == null) return null; CompilationUnit ast= SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, null); if (ast == null) return null; NodeFinder finder= new NodeFinder(ast, offset, length); ASTNode node= finder.getCoveringNode(); IBinding binding= null; if (node instanceof Name) { binding= getConstructorBindingIfAvailable((Name)node); if (binding != null) return binding; binding= ((Name)node).resolveBinding(); } else if (node instanceof MethodInvocation) { binding= ((MethodInvocation)node).resolveMethodBinding(); } else if (node instanceof MethodDeclaration) { binding= ((MethodDeclaration)node).resolveBinding(); } else if (node instanceof Type) { binding= ((Type)node).resolveBinding(); } else if (node instanceof AnonymousClassDeclaration) { binding= ((AnonymousClassDeclaration)node).resolveBinding(); } else if (node instanceof TypeDeclaration) { binding= ((TypeDeclaration)node).resolveBinding(); } else if (node instanceof CompilationUnit) { return ((CompilationUnit)node).getJavaElement(); } else if (node instanceof Expression) { binding= ((Expression)node).resolveTypeBinding(); } else if (node instanceof ImportDeclaration) { binding= ((ImportDeclaration)node).resolveBinding(); } else if (node instanceof MemberRef) { binding= ((MemberRef)node).resolveBinding(); } else if (node instanceof MemberValuePair) { binding= ((MemberValuePair)node).resolveMemberValuePairBinding(); } else if (node instanceof PackageDeclaration) { binding= ((PackageDeclaration)node).resolveBinding(); } else if (node instanceof TypeParameter) { binding= ((TypeParameter)node).resolveBinding(); } else if (node instanceof VariableDeclaration) { binding= ((VariableDeclaration)node).resolveBinding(); } if (binding != null) return binding.getJavaElement(); return null; }
Example #26
Source File: IdentifierPerType.java From codemining-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public boolean visit(final TypeParameter node) { addToMap(identifiers, node, node.getName().toString()); return super.visit(node); }
Example #27
Source File: HeaderTypeDeclarationWriter.java From juniversal with MIT License | 4 votes |
public void write(TypeDeclaration typeDeclaration) { this.typeDeclaration = typeDeclaration; // Skip the modifiers and the space/comments following them skipModifiers(typeDeclaration.modifiers()); skipSpaceAndComments(); // Remember how much the type is indented (typically only nested types are indented), so we can use that in // determining the "natural" indent for some things inside the type declaration. typeIndent = getTargetWriter().getCurrColumn(); boolean isInterface = typeDeclaration.isInterface(); @SuppressWarnings("unchecked") List<TypeParameter> typeParameters = (List<TypeParameter>) typeDeclaration.typeParameters(); boolean isGeneric = !typeParameters.isEmpty(); if (isGeneric) { write("template "); //sCPlusPlusASTWriter.writeTypeParameters(typeParameters, true); write(" "); } if (isInterface) matchAndWrite("interface", "class"); else matchAndWrite("class"); copySpaceAndComments(); matchAndWrite(typeDeclaration.getName().getIdentifier()); // Skip past the type parameters if (isGeneric) { setPosition(ASTUtil.getEndPosition(typeParameters)); skipSpaceAndComments(); match(">"); } writeSuperClassAndInterfaces(); copySpaceAndComments(); matchAndWrite("{"); copySpaceAndCommentsUntilEOL(); writeln(); // sourceFileWriter.getTargetWriter().incrementByPreferredIndent(); outputSomethingForType = false; writeNestedTypes(); writeMethods(); writeSuperDefinition(); writeFields(); writeSpaces(typeIndent); write("};"); setPosition(ASTUtil.getEndPosition(typeDeclaration)); }
Example #28
Source File: JavadocTagsSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public static void getMissingJavadocTagProposals(IInvocationContext context, IProblemLocationCore problem, Collection<ChangeCorrectionProposal> proposals) { ASTNode node= problem.getCoveringNode(context.getASTRoot()); if (node == null) { return; } node= ASTNodes.getNormalizedNode(node); BodyDeclaration bodyDeclaration= ASTResolving.findParentBodyDeclaration(node); if (bodyDeclaration == null) { return; } Javadoc javadoc= bodyDeclaration.getJavadoc(); if (javadoc == null) { return; } String label; StructuralPropertyDescriptor location= node.getLocationInParent(); if (location == SingleVariableDeclaration.NAME_PROPERTY) { label= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_paramtag_description; if (node.getParent().getLocationInParent() != MethodDeclaration.PARAMETERS_PROPERTY) { return; // paranoia checks } } else if (location == TypeParameter.NAME_PROPERTY) { label= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_paramtag_description; StructuralPropertyDescriptor parentLocation= node.getParent().getLocationInParent(); if (parentLocation != MethodDeclaration.TYPE_PARAMETERS_PROPERTY && parentLocation != TypeDeclaration.TYPE_PARAMETERS_PROPERTY) { return; // paranoia checks } } else if (location == MethodDeclaration.RETURN_TYPE2_PROPERTY) { label= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_returntag_description; } else if (location == MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY) { label= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_throwstag_description; } else { return; } ASTRewriteCorrectionProposal proposal= new AddMissingJavadocTagProposal(label, context.getCompilationUnit(), bodyDeclaration, node, IProposalRelevance.ADD_MISSING_TAG); proposals.add(proposal); String label2= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_allmissing_description; ASTRewriteCorrectionProposal addAllMissing= new AddAllMissingJavadocTagsProposal(label2, context.getCompilationUnit(), bodyDeclaration, IProposalRelevance.ADD_ALL_MISSING_TAGS); proposals.add(addAllMissing); }
Example #29
Source File: DOMFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public boolean visit(TypeParameter node) { if (found(node, node.getName()) && this.resolveBinding) this.foundBinding = node.resolveBinding(); return true; }
Example #30
Source File: NewMethodCorrectionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected void addNewTypeParameters(ASTRewrite rewrite, List<String> takenNames, List<TypeParameter> params) throws CoreException { }