當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodDeclaration.setJavadoc方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.dom.MethodDeclaration.setJavadoc方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodDeclaration.setJavadoc方法的具體用法?Java MethodDeclaration.setJavadoc怎麽用?Java MethodDeclaration.setJavadoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.dom.MethodDeclaration的用法示例。


在下文中一共展示了MethodDeclaration.setJavadoc方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addNewJavadoc

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
private void addNewJavadoc(ASTRewrite rewrite, MethodDeclaration decl, ImportRewriteContext context) throws CoreException {
	IType parentType = fField.getDeclaringType();

	String typeName = Signature.toString(fField.getTypeSignature());
	String accessorName = StubUtility.getBaseName(fField);
	String lineDelim = "\n";

	String comment = null;
	String name = getFunctionName();
	if (isGetter) {
		comment = CodeGeneration.getGetterComment(fField.getCompilationUnit(), parentType.getTypeQualifiedName('.'), name, fField.getElementName(), typeName, accessorName, lineDelim);
	} else {
		String argname = getArgumentName();
		comment = CodeGeneration.getSetterComment(fField.getCompilationUnit(), parentType.getTypeQualifiedName('.'), name, fField.getElementName(), typeName, argname, accessorName, lineDelim);
	}
	comment = comment.substring(0, comment.lastIndexOf(lineDelim));

	if (comment != null) {
		Javadoc javadoc = (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
		decl.setJavadoc(javadoc);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:23,代碼來源:SelfEncapsulateFieldProposal.java

示例2: addJavadocForWithMethod

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
public void addJavadocForWithMethod(AST ast, String fieldName, MethodDeclaration builderMethod) {
    if (preferencesManager.getPreferenceValue(GENERATE_JAVADOC_ON_EACH_BUILDER_METHOD)) {
        Map<String, String> javadocTags = new LinkedHashMap<>();
        javadocTags.put(PARAM_JAVADOC_TAG_NAME, String.format(Locale.ENGLISH, "%s field to set", fieldName));
        javadocTags.put(RETURN_JAVADOC_TAG_NAME, "builder");
        Javadoc javadoc = javadocGenerator.generateJavadoc(ast,
                String.format(Locale.ENGLISH, "Builder method for %s parameter.", fieldName),
                javadocTags);
        builderMethod.setJavadoc(javadoc);
    }
}
 
開發者ID:helospark,項目名稱:SparkBuilderGenerator,代碼行數:12,代碼來源:JavadocAdder.java

示例3: addJavadocForBuildMethod

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
public void addJavadocForBuildMethod(AST ast, MethodDeclaration buildMethod) {
    if (preferencesManager.getPreferenceValue(GENERATE_JAVADOC_ON_EACH_BUILDER_METHOD)) {
        Javadoc javadoc = javadocGenerator.generateJavadoc(ast, "Builder method of the builder.",
                Collections.singletonMap(RETURN_JAVADOC_TAG_NAME, "built class"));
        buildMethod.setJavadoc(javadoc);
    }
}
 
開發者ID:helospark,項目名稱:SparkBuilderGenerator,代碼行數:8,代碼來源:JavadocAdder.java

示例4: addJavadocForBuilderMethod

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
public void addJavadocForBuilderMethod(AST ast, String typeName, MethodDeclaration builderMethod) {
    if (preferencesManager.getPreferenceValue(PluginPreferenceList.GENERATE_JAVADOC_ON_BUILDER_METHOD)) {
        Javadoc javadoc = javadocGenerator.generateJavadoc(ast, String.format(Locale.ENGLISH, "Creates builder to build {@link %s}.", typeName),
                Collections.singletonMap(RETURN_JAVADOC_TAG_NAME, "created builder"));
        builderMethod.setJavadoc(javadoc);
    }
}
 
開發者ID:helospark,項目名稱:SparkBuilderGenerator,代碼行數:8,代碼來源:JavadocAdder.java

示例5: addJavadocForWithBuilderMethod

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
public void addJavadocForWithBuilderMethod(AST ast, String typeName, String parameterName, MethodDeclaration builderMethod) {
    if (preferencesManager.getPreferenceValue(PluginPreferenceList.GENERATE_JAVADOC_ON_BUILDER_METHOD)) {
        Javadoc javadoc = javadocGenerator.generateJavadoc(ast,
                String.format(Locale.ENGLISH, "Creates builder to build {@link %s} and setting %s parameter.", typeName, parameterName),
                Collections.singletonMap(RETURN_JAVADOC_TAG_NAME, "created builder"));
        builderMethod.setJavadoc(javadoc);
    }
}
 
開發者ID:helospark,項目名稱:SparkBuilderGenerator,代碼行數:9,代碼來源:JavadocAdder.java

示例6: createNewMethod

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
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;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:14,代碼來源:ExtractMethodRefactoring.java

示例7: getStub

import org.eclipse.jdt.core.dom.MethodDeclaration; //導入方法依賴的package包/類
private MethodDeclaration getStub(ASTRewrite rewrite, ASTNode targetTypeDecl) throws CoreException {
	ImportRewriteContext context=new ContextSensitiveImportRewriteContext(targetTypeDecl, getImportRewrite());

	AST ast= targetTypeDecl.getAST();
	MethodDeclaration decl= ast.newMethodDeclaration();

	SimpleName newNameNode= getNewName(rewrite);

	decl.setConstructor(isConstructor());

	addNewModifiers(rewrite, targetTypeDecl, decl.modifiers());

	ArrayList<String> takenNames= new ArrayList<>();
	addNewTypeParameters(rewrite, takenNames, decl.typeParameters(), context);

	decl.setName(newNameNode);

	IVariableBinding[] declaredFields= fSenderBinding.getDeclaredFields();
	for (int i= 0; i < declaredFields.length; i++) { // avoid to take parameter names that are equal to field names
		takenNames.add(declaredFields[i].getName());
	}

	String bodyStatement= ""; //$NON-NLS-1$
	boolean isAbstractMethod= Modifier.isAbstract(decl.getModifiers()) || (fSenderBinding.isInterface() && !Modifier.isStatic(decl.getModifiers()) && !Modifier.isDefault(decl.getModifiers()));
	if (!isConstructor()) {
		Type returnType= getNewMethodType(rewrite, context);
		decl.setReturnType2(returnType);

		boolean isVoid= returnType instanceof PrimitiveType && PrimitiveType.VOID.equals(((PrimitiveType)returnType).getPrimitiveTypeCode());
		if (!isAbstractMethod && !isVoid) {
			ReturnStatement returnStatement= ast.newReturnStatement();
			returnStatement.setExpression(ASTNodeFactory.newDefaultExpression(ast, returnType, 0));
			bodyStatement= ASTNodes.asFormattedString(returnStatement, 0, String.valueOf('\n'), getCompilationUnit().getJavaProject().getOptions(true));
		}
	}

	addNewParameters(rewrite, takenNames, decl.parameters(), context);
	addNewExceptions(rewrite, decl.thrownExceptionTypes(), context);

	Block body= null;
	if (!isAbstractMethod && !Flags.isAbstract(decl.getModifiers())) {
		body= ast.newBlock();
		if (bodyStatement.length() > 0) {
			ReturnStatement todoNode = (ReturnStatement) rewrite.createStringPlaceholder(bodyStatement,
					ASTNode.RETURN_STATEMENT);
			body.statements().add(todoNode);
		}
	}
	decl.setBody(body);

	CodeGenerationSettings settings = PreferenceManager.getCodeGenerationSettings(getCompilationUnit().getResource());
	if (settings.createComments && !fSenderBinding.isAnonymous()) {
		String string = CodeGeneration.getMethodComment(getCompilationUnit(), fSenderBinding.getName(), decl, null,
				String.valueOf('\n'));
		if (string != null) {
			Javadoc javadoc= (Javadoc) rewrite.createStringPlaceholder(string, ASTNode.JAVADOC);
			decl.setJavadoc(javadoc);
		}
	}
	return decl;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:62,代碼來源:AbstractMethodCorrectionProposal.java


注:本文中的org.eclipse.jdt.core.dom.MethodDeclaration.setJavadoc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。