org.eclipse.jdt.core.dom.Javadoc Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.Javadoc. 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: PullUpRefactoringProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Javadoc createJavadocForStub(final String enclosingTypeName, final MethodDeclaration oldMethod, final MethodDeclaration newMethodNode, final ICompilationUnit cu, final ASTRewrite rewrite) throws CoreException {
	if (fSettings.createComments) {
		final IMethodBinding binding= oldMethod.resolveBinding();
		if (binding != null) {
			final ITypeBinding[] params= binding.getParameterTypes();
			final String fullTypeName= getDestinationType().getFullyQualifiedName('.');
			final String[] fullParamNames= new String[params.length];
			for (int i= 0; i < fullParamNames.length; i++) {
				fullParamNames[i]= Bindings.getFullyQualifiedName(params[i]);
			}
			final String comment= CodeGeneration.getMethodComment(cu, enclosingTypeName, newMethodNode, false, binding.getName(), fullTypeName, fullParamNames, StubUtility.getLineDelimiterUsed(cu));
			if (comment != null)
				return (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
		}
	}
	return null;
}
 
Example #2
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean visit(final EnumConstantDeclaration node) {
  Javadoc _javadoc = node.getJavadoc();
  boolean _tripleNotEquals = (_javadoc != null);
  if (_tripleNotEquals) {
    node.getJavadoc().accept(this);
  }
  this.appendModifiers(node, node.modifiers());
  node.getName().accept(this);
  boolean _isEmpty = node.arguments().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    this.addProblem(node, "Enum constant cannot have any arguments");
    this.appendToBuffer("(");
    this.visitAllSeparatedByComma(node.arguments());
    this.appendToBuffer(")");
  }
  AnonymousClassDeclaration _anonymousClassDeclaration = node.getAnonymousClassDeclaration();
  boolean _tripleNotEquals_1 = (_anonymousClassDeclaration != null);
  if (_tripleNotEquals_1) {
    this.addProblem(node, "Enum constant cannot have any anonymous class declarations");
    node.getAnonymousClassDeclaration().accept(this);
  }
  return false;
}
 
Example #3
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean visit(final AnnotationTypeMemberDeclaration node) {
  Javadoc _javadoc = node.getJavadoc();
  boolean _tripleNotEquals = (_javadoc != null);
  if (_tripleNotEquals) {
    node.getJavadoc().accept(this);
  }
  this.appendModifiers(node, node.modifiers());
  node.getType().accept(this);
  this.appendSpaceToBuffer();
  node.getName().accept(this);
  Expression _default = node.getDefault();
  boolean _tripleNotEquals_1 = (_default != null);
  if (_tripleNotEquals_1) {
    this.appendToBuffer(" = ");
    node.getDefault().accept(this);
  }
  this.appendLineWrapToBuffer();
  return false;
}
 
Example #4
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Start self Converted part
 */
@Override
public boolean visit(final AnnotationTypeDeclaration node) {
  Javadoc _javadoc = node.getJavadoc();
  boolean _tripleNotEquals = (_javadoc != null);
  if (_tripleNotEquals) {
    node.getJavadoc().accept(this);
  }
  this.appendModifiers(node, node.modifiers());
  this.appendToBuffer("annotation ");
  node.getName().accept(this);
  this.appendToBuffer(" {");
  this.appendLineWrapToBuffer();
  this.visitAll(node.bodyDeclarations());
  this.appendToBuffer("}");
  return false;
}
 
Example #5
Source File: MoveMethodRefactoring.java    From JDeodorant with MIT License 6 votes vote down vote up
private void addParamTagElementToJavadoc(MethodDeclaration newMethodDeclaration, ASTRewrite targetRewriter, String parameterToBeAdded) {
	if(newMethodDeclaration.getJavadoc() != null) {
		AST ast = newMethodDeclaration.getAST();
		Javadoc javadoc = newMethodDeclaration.getJavadoc();
		List<TagElement> tags = javadoc.tags();
		TagElement returnTagElement = null;
		for(TagElement tag : tags) {
			if(tag.getTagName() != null && tag.getTagName().equals(TagElement.TAG_RETURN)) {
				returnTagElement = tag;
				break;
			}
		}
		
		TagElement tagElement = ast.newTagElement();
		targetRewriter.set(tagElement, TagElement.TAG_NAME_PROPERTY, TagElement.TAG_PARAM, null);
		ListRewrite fragmentsRewrite = targetRewriter.getListRewrite(tagElement, TagElement.FRAGMENTS_PROPERTY);
		SimpleName paramName = ast.newSimpleName(parameterToBeAdded);
		fragmentsRewrite.insertLast(paramName, null);
		
		ListRewrite tagsRewrite = targetRewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY);
		if(returnTagElement != null)
			tagsRewrite.insertBefore(tagElement, returnTagElement, null);
		else
			tagsRewrite.insertLast(tagElement, null);
	}
}
 
Example #6
Source File: MoveInnerToTopRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addEnclosingInstanceDeclaration(final AbstractTypeDeclaration declaration, final ASTRewrite rewrite) throws CoreException {
	Assert.isNotNull(declaration);
	Assert.isNotNull(rewrite);
	final AST ast= declaration.getAST();
	final VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment();
	fragment.setName(ast.newSimpleName(fEnclosingInstanceFieldName));
	final FieldDeclaration newField= ast.newFieldDeclaration(fragment);
	newField.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getEnclosingInstanceAccessModifiers()));
	newField.setType(createEnclosingType(ast));
	final String comment= CodeGeneration.getFieldComment(fType.getCompilationUnit(), declaration.getName().getIdentifier(), fEnclosingInstanceFieldName, StubUtility.getLineDelimiterUsed(fType.getJavaProject()));
	if (comment != null && comment.length() > 0) {
		final Javadoc doc= (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
		newField.setJavadoc(doc);
	}
	rewrite.getListRewrite(declaration, declaration.getBodyDeclarationsProperty()).insertFirst(newField, null);
}
 
Example #7
Source File: MoveMethodRefactoring.java    From JDeodorant with MIT License 6 votes vote down vote up
private void removeParamTagElementFromJavadoc(MethodDeclaration newMethodDeclaration, ASTRewrite targetRewriter, String parameterToBeRemoved) {
	if(newMethodDeclaration.getJavadoc() != null) {
		Javadoc javadoc = newMethodDeclaration.getJavadoc();
		List<TagElement> tags = javadoc.tags();
		for(TagElement tag : tags) {
			if(tag.getTagName() != null && tag.getTagName().equals(TagElement.TAG_PARAM)) {
				List<ASTNode> tagFragments = tag.fragments();
				boolean paramFound = false;
				for(ASTNode node : tagFragments) {
					if(node instanceof SimpleName) {
						SimpleName simpleName = (SimpleName)node;
						if(simpleName.getIdentifier().equals(parameterToBeRemoved)) {
							paramFound = true;
							break;
						}
					}
				}
				if(paramFound) {
					ListRewrite tagsRewrite = targetRewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY);
					tagsRewrite.remove(tag, null);
					break;
				}
			}
		}
	}
}
 
Example #8
Source File: ConvertAnonymousToNestedRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createFieldsForAccessedLocals(CompilationUnitRewrite rewrite, IVariableBinding[] varBindings, String[] fieldNames, List<BodyDeclaration> newBodyDeclarations) throws CoreException {
	final ImportRewrite importRewrite= rewrite.getImportRewrite();
	final ASTRewrite astRewrite= rewrite.getASTRewrite();
	final AST ast= astRewrite.getAST();

	for (int i= 0; i < varBindings.length; i++) {
		VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment();
		fragment.setInitializer(null);
		fragment.setName(ast.newSimpleName(fieldNames[i]));
		FieldDeclaration field= ast.newFieldDeclaration(fragment);
		ITypeBinding varType= varBindings[i].getType();
		field.setType(importRewrite.addImport(varType, ast));
		field.modifiers().addAll(ASTNodeFactory.newModifiers(ast, Modifier.PRIVATE | Modifier.FINAL));
		if (doAddComments()) {
			String string= CodeGeneration.getFieldComment(rewrite.getCu(), varType.getName(), fieldNames[i], StubUtility.getLineDelimiterUsed(fCu));
			if (string != null) {
				Javadoc javadoc= (Javadoc) astRewrite.createStringPlaceholder(string, ASTNode.JAVADOC);
				field.setJavadoc(javadoc);
			}
		}

		newBodyDeclarations.add(field);

		addLinkedPosition(KEY_FIELD_NAME_EXT + i, fragment.getName(), astRewrite, false);
	}
}
 
Example #9
Source File: JavadocTagsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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 #10
Source File: EmptyBuilderClassGeneratorFragment.java    From SparkBuilderGenerator with MIT License 6 votes vote down vote up
public TypeDeclaration createBuilderClass(AST ast, TypeDeclaration originalType) {
    TypeDeclaration builderType = ast.newTypeDeclaration();
    builderType.setName(ast.newSimpleName(getBuilderName(originalType)));

    if (preferencesManager.getPreferenceValue(ADD_GENERATED_ANNOTATION)) {
        generatedAnnotationPopulator.addGeneratedAnnotation(ast, builderType);
    }
    builderType.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
    builderType.modifiers().add(ast.newModifier(ModifierKeyword.STATIC_KEYWORD));
    builderType.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD));

    if (preferencesManager.getPreferenceValue(ADD_JACKSON_DESERIALIZE_ANNOTATION)) {
        jsonPOJOBuilderAdderFragment.addJsonPOJOBuilder(ast, builderType);
    }

    if (preferencesManager.getPreferenceValue(GENERATE_JAVADOC_ON_BUILDER_CLASS)) {
        Javadoc javadoc = javadocGenerator.generateJavadoc(ast, String.format(Locale.ENGLISH, "Builder to build {@link %s}.", originalType.getName().toString()),
                Collections.emptyMap());
        builderType.setJavadoc(javadoc);
    }

    return builderType;
}
 
Example #11
Source File: AbstractToStringGenerator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * adds a comment (if necessary) and an <code>@Override</code> annotation to the generated
 * method
 * 
 * @throws CoreException if creation failed
 */
protected void createMethodComment() throws CoreException {
	ITypeBinding object= fAst.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
	IMethodBinding[] objms= object.getDeclaredMethods();
	IMethodBinding objectMethod= null;
	for (int i= 0; i < objms.length; i++) {
		if (objms[i].getName().equals(METHODNAME_TO_STRING) && objms[i].getParameterTypes().length == 0)
			objectMethod= objms[i];
	}
	if (fContext.isCreateComments()) {
		String docString= CodeGeneration.getMethodComment(fContext.getCompilationUnit(), fContext.getTypeBinding().getQualifiedName(), toStringMethod, objectMethod, StubUtility
				.getLineDelimiterUsed(fContext.getCompilationUnit()));
		if (docString != null) {
			Javadoc javadoc= (Javadoc)fContext.getASTRewrite().createStringPlaceholder(docString, ASTNode.JAVADOC);
			toStringMethod.setJavadoc(javadoc);
		}
	}
	if (fContext.isOverrideAnnotation() && fContext.is50orHigher())
		StubUtility2.addOverrideAnnotation(fContext.getTypeBinding().getJavaElement().getJavaProject(), fContext.getASTRewrite(), toStringMethod, objectMethod);
}
 
Example #12
Source File: JavadocTagsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static TagElement findTag(Javadoc javadoc, String name, String arg) {
	List<TagElement> tags= javadoc.tags();
	int nTags= tags.size();
	for (int i= 0; i < nTags; i++) {
		TagElement curr= tags.get(i);
		if (name.equals(curr.getTagName())) {
			if (arg != null) {
				String argument= getArgument(curr);
				if (arg.equals(argument)) {
					return curr;
				}
			} else {
				return curr;
			}
		}
	}
	return null;
}
 
Example #13
Source File: ParameterObjectFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private MethodDeclaration createGetter(ParameterInfo pi, String declaringType, CompilationUnitRewrite cuRewrite) throws CoreException {
	AST ast= cuRewrite.getAST();
	ICompilationUnit cu= cuRewrite.getCu();
	IJavaProject project= cu.getJavaProject();

	MethodDeclaration methodDeclaration= ast.newMethodDeclaration();
	String fieldName= pi.getNewName();
	String getterName= getGetterName(pi, ast, project);
	String lineDelim= StubUtility.getLineDelimiterUsed(cu);
	String bareFieldname= NamingConventions.getBaseName(NamingConventions.VK_INSTANCE_FIELD, fieldName, project);
	if (createComments(project)) {
		String comment= CodeGeneration.getGetterComment(cu, declaringType, getterName, fieldName, pi.getNewTypeName(), bareFieldname, lineDelim);
		if (comment != null)
			methodDeclaration.setJavadoc((Javadoc) cuRewrite.getASTRewrite().createStringPlaceholder(comment, ASTNode.JAVADOC));
	}
	methodDeclaration.setName(ast.newSimpleName(getterName));
	methodDeclaration.setReturnType2(importBinding(pi.getNewTypeBinding(), cuRewrite));
	methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
	Block block= ast.newBlock();
	methodDeclaration.setBody(block);
	boolean useThis= StubUtility.useThisForFieldAccess(project);
	if (useThis) {
		fieldName= "this." + fieldName; //$NON-NLS-1$
	}
	String bodyContent= CodeGeneration.getGetterMethodBodyContent(cu, declaringType, getterName, fieldName, lineDelim);
	ASTNode getterBody= cuRewrite.getASTRewrite().createStringPlaceholder(bodyContent, ASTNode.EXPRESSION_STATEMENT);
	block.statements().add(getterBody);
	return methodDeclaration;
}
 
Example #14
Source File: DelegateCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the javadoc for the delegate.
 *
 * @throws JavaModelException
 */
private void createJavadoc() throws JavaModelException {
	TagElement tag= getDelegateJavadocTag(fDeclaration);

	Javadoc comment= fDeclaration.getJavadoc();
	if (comment == null) {
		comment= getAst().newJavadoc();
		comment.tags().add(tag);
		fDelegateRewrite.getASTRewrite().set(fDeclaration, getJavaDocProperty(), comment, null);
	} else
		fDelegateRewrite.getASTRewrite().getListRewrite(comment, Javadoc.TAGS_PROPERTY).insertLast(tag, null);
}
 
Example #15
Source File: AstUtils.java    From RefactoringMiner with MIT License 5 votes vote down vote up
public static boolean containsDeprecatedTag(Javadoc javadoc) {
	if (javadoc == null) {
		return false;
	}
	List<TagElement> javadocTags = (List<TagElement>) javadoc.tags();
	for (TagElement tag : javadocTags) {
		if ("@deprecated".equals(tag.getTagName())) {
			return true;
		}
	}
	return false;
}
 
Example #16
Source File: ChangeMethodSignatureProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private TagElement findParamTag(MethodDeclaration decl, SingleVariableDeclaration param) {
	Javadoc javadoc= decl.getJavadoc();
	if (javadoc != null) {
		return JavadocTagsSubProcessor.findParamTag(javadoc, param.getName().getIdentifier());
	}
	return null;
}
 
Example #17
Source File: PromoteTempToFieldRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Javadoc getNewConstructorComment(ASTRewrite rewrite) throws CoreException {
	if (StubUtility.doAddComments(fCu.getJavaProject())){
		String comment= CodeGeneration.getMethodComment(fCu, getEnclosingTypeName(), getEnclosingTypeName(), new String[0], new String[0], null, null, StubUtility.getLineDelimiterUsed(fCu));
		if (comment != null && comment.length() > 0) {
			return (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
		}
	}
	return null;
}
 
Example #18
Source File: ExceptionOccurrencesFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(MethodDeclaration node) {
	Javadoc javadoc= node.getJavadoc();
	if (javadoc != null) {
		List<TagElement> tags= javadoc.tags();
		for (TagElement tag : tags) {
			String tagName= tag.getTagName();
			if (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName)) {
				ASTNode name= (ASTNode) tag.fragments().get(0);
				if (name instanceof Name) {
					if (name != fSelectedNode && Bindings.equals(fException, ((Name) name).resolveBinding())) {
						fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription));
					}
				}
			}
		}
	}
	List<Type> thrownExceptionTypes= node.thrownExceptionTypes();
	for (Iterator<Type> iter= thrownExceptionTypes.iterator(); iter.hasNext(); ) {
		Type type = iter.next();
		if (type != fSelectedNode && Bindings.equals(fException, type.resolveBinding())) {
			fResult.add(new OccurrenceLocation(type.getStartPosition(), type.getLength(), 0, fDescription));
		}
	}
	Block body= node.getBody();
	if (body != null) {
		node.getBody().accept(this);
	}
	return false;
}
 
Example #19
Source File: ExtractMethodRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private MethodDeclaration createNewMethod(ASTNode[] selectedNodes, String lineDelimiter, TextEditGroup substitute) throws CoreException {
	MethodDeclaration result= createNewMethodDeclaration();
	result.setBody(createMethodBody(selectedNodes, substitute, result.getModifiers()));
	if (fGenerateJavadoc) {
		AbstractTypeDeclaration enclosingType=
			(AbstractTypeDeclaration)ASTNodes.getParent(fAnalyzer.getEnclosingBodyDeclaration(), AbstractTypeDeclaration.class);
		String string= CodeGeneration.getMethodComment(fCUnit, enclosingType.getName().getIdentifier(), result, null, lineDelimiter);
		if (string != null) {
			Javadoc javadoc= (Javadoc)fRewriter.createStringPlaceholder(string, ASTNode.JAVADOC);
			result.setJavadoc(javadoc);
		}
	}
	return result;
}
 
Example #20
Source File: JavadocContentAccess2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String getHTMLContentFromAttachedSource(IPackageFragmentRoot root, IPackageFragment packageFragment) throws CoreException {
	String filePath= packageFragment.getElementName().replace('.', '/') + '/' + JavaModelUtil.PACKAGE_INFO_JAVA;
	String contents= getFileContentFromAttachedSource(root, filePath);
	if (contents != null) {
		Javadoc packageJavadocNode= getPackageJavadocNode(packageFragment, contents);
		if (packageJavadocNode != null)
			return new JavadocContentAccess2(packageFragment, packageJavadocNode, contents).toHTML();

	}
	filePath= packageFragment.getElementName().replace('.', '/') + '/' + JavaModelUtil.PACKAGE_HTML;
	return getFileContentFromAttachedSource(root, filePath);
}
 
Example #21
Source File: JavadocContentAccess2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private JavadocContentAccess2(IJavaElement element, Javadoc javadoc, String source) {
	Assert.isTrue(element instanceof IMember || element instanceof IPackageFragment);
	fElement= element;
	fMethod= null;
	fJavadoc= javadoc;
	fSource= source;
	fJavadocLookup= JavadocLookup.NONE;
}
 
Example #22
Source File: ModifierCorrectionSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void addOverridingDeprecatedMethodProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {

		ICompilationUnit cu= context.getCompilationUnit();

		ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
		if (!(selectedNode instanceof MethodDeclaration)) {
			return;
		}
		boolean is50OrHigher= JavaModelUtil.is50OrHigher(cu.getJavaProject());
		MethodDeclaration methodDecl= (MethodDeclaration) selectedNode;
		AST ast= methodDecl.getAST();
		ASTRewrite rewrite= ASTRewrite.create(ast);
		if (is50OrHigher) {
			Annotation annot= ast.newMarkerAnnotation();
			annot.setTypeName(ast.newName("Deprecated")); //$NON-NLS-1$
			rewrite.getListRewrite(methodDecl, methodDecl.getModifiersProperty()).insertFirst(annot, null);
		}
		Javadoc javadoc= methodDecl.getJavadoc();
		if (javadoc != null || !is50OrHigher) {
			if (!is50OrHigher) {
				javadoc= ast.newJavadoc();
				rewrite.set(methodDecl, MethodDeclaration.JAVADOC_PROPERTY, javadoc, null);
			}
			TagElement newTag= ast.newTagElement();
			newTag.setTagName(TagElement.TAG_DEPRECATED);
			JavadocTagsSubProcessor.insertTag(rewrite.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY), newTag, null);
		}

		String label= CorrectionMessages.ModifierCorrectionSubProcessor_overrides_deprecated_description;
		Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
		ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.OVERRIDES_DEPRECATED, image);
		proposals.add(proposal);
	}
 
Example #23
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final FieldDeclaration it) {
  Javadoc _javadoc = it.getJavadoc();
  boolean _tripleNotEquals = (_javadoc != null);
  if (_tripleNotEquals) {
    it.getJavadoc().accept(this);
  }
  final Consumer<VariableDeclarationFragment> _function = (VariableDeclarationFragment frag) -> {
    this.appendModifiers(it, it.modifiers());
    boolean _isPackageVisibility = this._aSTFlattenerUtils.isPackageVisibility(Iterables.<Modifier>filter(it.modifiers(), Modifier.class));
    if (_isPackageVisibility) {
      ASTNode _parent = it.getParent();
      if ((_parent instanceof TypeDeclaration)) {
        ASTNode _parent_1 = it.getParent();
        boolean _isInterface = ((TypeDeclaration) _parent_1).isInterface();
        boolean _not = (!_isInterface);
        if (_not) {
          this.appendToBuffer("package ");
        }
      }
    }
    it.getType().accept(this);
    this.appendExtraDimensions(frag.getExtraDimensions());
    this.appendSpaceToBuffer();
    frag.accept(this);
  };
  it.fragments().forEach(_function);
  return false;
}
 
Example #24
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final Javadoc it) {
  this.appendToBuffer("/** ");
  this.visitAll(it.tags());
  this.appendLineWrapToBuffer();
  this.appendToBuffer(" */");
  this.appendLineWrapToBuffer();
  return false;
}
 
Example #25
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final PackageDeclaration it) {
  Javadoc _javadoc = it.getJavadoc();
  boolean _tripleNotEquals = (_javadoc != null);
  if (_tripleNotEquals) {
    it.getJavadoc().accept(this);
  }
  this.visitAll(it.annotations(), " ");
  this.appendToBuffer("package ");
  it.getName().accept(this);
  this.appendLineWrapToBuffer();
  return false;
}
 
Example #26
Source File: ChangeMethodSignatureProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private TagElement findThrowsTag(MethodDeclaration decl, Type exception) {
	Javadoc javadoc= decl.getJavadoc();
	if (javadoc != null) {
		String name= ASTNodes.getTypeName(exception);
		return JavadocTagsSubProcessor.findThrowsTag(javadoc, name);
	}
	return null;
}
 
Example #27
Source File: ChangeMethodSignatureProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private TagElement findParamTag(MethodDeclaration decl, SingleVariableDeclaration param) {
	Javadoc javadoc= decl.getJavadoc();
	if (javadoc != null) {
		return JavadocTagsSubProcessor.findParamTag(javadoc, param.getName().getIdentifier());
	}
	return null;
}
 
Example #28
Source File: JavadocTagsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static TagElement findThrowsTag(Javadoc javadoc, String arg) {
	List<TagElement> tags= javadoc.tags();
	int nTags= tags.size();
	for (int i= 0; i < nTags; i++) {
		TagElement curr= tags.get(i);
		String currName= curr.getTagName();
		if (TagElement.TAG_THROWS.equals(currName) || TagElement.TAG_EXCEPTION.equals(currName)) {
			String argument= getArgument(curr);
			if (arg.equals(argument)) {
				return curr;
			}
		}
	}
	return null;
}
 
Example #29
Source File: JavadocTagsSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static TagElement findParamTag(Javadoc javadoc, String arg) {
	List<TagElement> tags= javadoc.tags();
	int nTags= tags.size();
	for (int i= 0; i < nTags; i++) {
		TagElement curr= tags.get(i);
		String currName= curr.getTagName();
		if (TagElement.TAG_PARAM.equals(currName)) {
			String argument= getArgument(curr);
			if (arg.equals(argument)) {
				return curr;
			}
		}
	}
	return null;
}
 
Example #30
Source File: JavadocLineBreakPreparator.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(Javadoc node) {
	int commentIndex = this.tokenManager.firstIndexIn(node, TerminalTokens.TokenNameCOMMENT_JAVADOC);
	Token commentToken = this.tokenManager.get(commentIndex);
	this.commentTokenManager = new TokenManager(commentToken.getInternalStructure(), this.tokenManager);
	this.declaration = node.getParent();
	this.firstTagElement = true;
	this.hasText = false;
	return true;
}