本文整理汇总了Java中org.eclipse.jdt.ui.CodeGeneration.getTypeComment方法的典型用法代码示例。如果您正苦于以下问题:Java CodeGeneration.getTypeComment方法的具体用法?Java CodeGeneration.getTypeComment怎么用?Java CodeGeneration.getTypeComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.ui.CodeGeneration
的用法示例。
在下文中一共展示了CodeGeneration.getTypeComment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeComment
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
/**
* Hook method that gets called from <code>createType</code> to retrieve
* a type comment. This default implementation returns the content of the
* 'type comment' template.
*
* @param parentCU the parent compilation unit
* @param lineDelimiter the line delimiter to use
* @return the type comment or <code>null</code> if a type comment
* is not desired
*
* @since 3.0
*/
protected String getTypeComment(ICompilationUnit parentCU, String lineDelimiter) {
if (isAddComments()) {
try {
StringBuffer typeName= new StringBuffer();
if (isEnclosingTypeSelected()) {
typeName.append(getEnclosingType().getTypeQualifiedName('.')).append('.');
}
typeName.append(getTypeNameWithoutParameters());
String[] typeParamNames= new String[0];
String comment= CodeGeneration.getTypeComment(parentCU, typeName.toString(), typeParamNames, lineDelimiter);
if (comment != null && isValidComment(comment)) {
return comment;
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
return null;
}
示例2: getTypeComment
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private String getTypeComment(ICompilationUnit cu) {
if (addComments) {
try {
String comment = CodeGeneration.getTypeComment(cu, simpleTypeName, new String[0], lineDelimiter);
if (comment != null && isValidComment(comment)) {
return comment;
}
} catch (CoreException e) {
CorePluginLog.logError(e);
}
}
return null;
}
示例3: getTypeComment
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
protected String getTypeComment(ICompilationUnit parentCU, String lineDelimiter) throws CoreException {
if (StubUtility.doAddComments(parentCU.getJavaProject())) {
StringBuffer typeName= new StringBuffer();
typeName.append(getClassName());
String[] typeParamNames= new String[0];
String comment= CodeGeneration.getTypeComment(parentCU, typeName.toString(), typeParamNames, lineDelimiter);
if (comment != null && isValidComment(comment)) {
return comment;
}
}
return null;
}
示例4: getUnformattedSource
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private String getUnformattedSource(IProgressMonitor pm) throws CoreException {
ICompilationUnit newCu= null;
try {
newCu= fAccessorPackage.getCompilationUnit(fAccessorPath.lastSegment()).getWorkingCopy(null);
String typeComment= null, fileComment= null;
final IJavaProject project= newCu.getJavaProject();
final String lineDelim= StubUtility.getLineDelimiterUsed(project);
if (StubUtility.doAddComments(project)) {
typeComment= CodeGeneration.getTypeComment(newCu, fAccessorClassName, lineDelim);
fileComment= CodeGeneration.getFileComment(newCu, lineDelim);
}
String classContent= createClass(lineDelim);
String cuContent= CodeGeneration.getCompilationUnitContent(newCu, fileComment, typeComment, classContent, lineDelim);
if (cuContent == null) {
StringBuffer buf= new StringBuffer();
if (fileComment != null) {
buf.append(fileComment).append(lineDelim);
}
if (!fAccessorPackage.isDefaultPackage()) {
buf.append("package ").append(fAccessorPackage.getElementName()).append(';'); //$NON-NLS-1$
}
buf.append(lineDelim).append(lineDelim);
if (typeComment != null) {
buf.append(typeComment).append(lineDelim);
}
buf.append(classContent);
cuContent= buf.toString();
}
newCu.getBuffer().setContents(cuContent);
addImportsToAccessorCu(newCu, pm);
return newCu.getSource();
} finally {
if (newCu != null) {
newCu.discardWorkingCopy();
}
}
}
示例5: createTypeTags
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private String createTypeTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IType type)
throws CoreException, BadLocationException
{
String[] typeParamNames= StubUtility.getTypeParameterNames(type.getTypeParameters());
String comment= CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParamNames, lineDelimiter);
if (comment != null) {
boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$
if (!isFirstComment(document, command, type, javadocComment))
return null;
return prepareTemplateComment(comment.trim(), indentation, type.getJavaProject(), lineDelimiter);
}
return null;
}
示例6: createNewNestedClass
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private AbstractTypeDeclaration createNewNestedClass(
CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException {
final AST ast = fAnonymousInnerClassNode.getAST();
final TypeDeclaration newDeclaration = ast.newTypeDeclaration();
newDeclaration.setInterface(false);
newDeclaration.setJavadoc(null);
newDeclaration
.modifiers()
.addAll(ASTNodeFactory.newModifiers(ast, createModifiersForNestedClass()));
newDeclaration.setName(ast.newSimpleName(fClassName));
TypeParameter parameter = null;
for (int index = 0; index < typeParameters.length; index++) {
parameter = ast.newTypeParameter();
parameter.setName(ast.newSimpleName(typeParameters[index].getName()));
newDeclaration.typeParameters().add(parameter);
}
setSuperType(newDeclaration);
IJavaProject project = fCu.getJavaProject();
IVariableBinding[] bindings = getUsedLocalVariables();
ArrayList<String> fieldNames = new ArrayList<String>();
for (int i = 0; i < bindings.length; i++) {
String name = StubUtility.getBaseName(bindings[i], project);
String[] fieldNameProposals =
StubUtility.getVariableNameSuggestions(
NamingConventions.VK_INSTANCE_FIELD, project, name, 0, fieldNames, true);
fieldNames.add(fieldNameProposals[0]);
if (fLinkedProposalModel != null) {
LinkedProposalPositionGroup positionGroup =
fLinkedProposalModel.getPositionGroup(KEY_FIELD_NAME_EXT + i, true);
for (int k = 0; k < fieldNameProposals.length; k++) {
positionGroup.addProposal(fieldNameProposals[k], null, fieldNameProposals.length - k);
}
}
}
String[] allFieldNames = fieldNames.toArray(new String[fieldNames.size()]);
List<BodyDeclaration> newBodyDeclarations = newDeclaration.bodyDeclarations();
createFieldsForAccessedLocals(rewrite, bindings, allFieldNames, newBodyDeclarations);
MethodDeclaration newConstructorDecl = createNewConstructor(rewrite, bindings, allFieldNames);
if (newConstructorDecl != null) {
newBodyDeclarations.add(newConstructorDecl);
}
updateAndMoveBodyDeclarations(
rewrite, bindings, allFieldNames, newBodyDeclarations, newConstructorDecl);
if (doAddComments()) {
String[] parameterNames = new String[typeParameters.length];
for (int index = 0; index < parameterNames.length; index++) {
parameterNames[index] = typeParameters[index].getName();
}
String string =
CodeGeneration.getTypeComment(
rewrite.getCu(), fClassName, parameterNames, StubUtility.getLineDelimiterUsed(fCu));
if (string != null) {
Javadoc javadoc =
(Javadoc) rewrite.getASTRewrite().createStringPlaceholder(string, ASTNode.JAVADOC);
newDeclaration.setJavadoc(javadoc);
}
}
if (fLinkedProposalModel != null) {
addLinkedPosition(KEY_TYPE_NAME, newDeclaration.getName(), rewrite.getASTRewrite(), false);
ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(
fLinkedProposalModel, rewrite.getASTRewrite(), newDeclaration.modifiers(), false);
}
return newDeclaration;
}
示例7: createNewNestedClass
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private AbstractTypeDeclaration createNewNestedClass(CompilationUnitRewrite rewrite, ITypeBinding[] typeParameters) throws CoreException {
final AST ast= fAnonymousInnerClassNode.getAST();
final TypeDeclaration newDeclaration= ast.newTypeDeclaration();
newDeclaration.setInterface(false);
newDeclaration.setJavadoc(null);
newDeclaration.modifiers().addAll(ASTNodeFactory.newModifiers(ast, createModifiersForNestedClass()));
newDeclaration.setName(ast.newSimpleName(fClassName));
TypeParameter parameter= null;
for (int index= 0; index < typeParameters.length; index++) {
parameter= ast.newTypeParameter();
parameter.setName(ast.newSimpleName(typeParameters[index].getName()));
newDeclaration.typeParameters().add(parameter);
}
setSuperType(newDeclaration);
IJavaProject project= fCu.getJavaProject();
IVariableBinding[] bindings= getUsedLocalVariables();
ArrayList<String> fieldNames= new ArrayList<String>();
for (int i= 0; i < bindings.length; i++) {
String name= StubUtility.getBaseName(bindings[i], project);
String[] fieldNameProposals= StubUtility.getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, project, name, 0, fieldNames, true);
fieldNames.add(fieldNameProposals[0]);
if (fLinkedProposalModel != null) {
LinkedProposalPositionGroup positionGroup= fLinkedProposalModel.getPositionGroup(KEY_FIELD_NAME_EXT + i, true);
for (int k= 0; k < fieldNameProposals.length; k++) {
positionGroup.addProposal(fieldNameProposals[k], null, fieldNameProposals.length - k);
}
}
}
String[] allFieldNames= fieldNames.toArray(new String[fieldNames.size()]);
List<BodyDeclaration> newBodyDeclarations= newDeclaration.bodyDeclarations();
createFieldsForAccessedLocals(rewrite, bindings, allFieldNames, newBodyDeclarations);
MethodDeclaration newConstructorDecl= createNewConstructor(rewrite, bindings, allFieldNames);
if (newConstructorDecl != null) {
newBodyDeclarations.add(newConstructorDecl);
}
updateAndMoveBodyDeclarations(rewrite, bindings, allFieldNames, newBodyDeclarations, newConstructorDecl);
if (doAddComments()) {
String[] parameterNames= new String[typeParameters.length];
for (int index= 0; index < parameterNames.length; index++) {
parameterNames[index]= typeParameters[index].getName();
}
String string= CodeGeneration.getTypeComment(rewrite.getCu(), fClassName, parameterNames, StubUtility.getLineDelimiterUsed(fCu));
if (string != null) {
Javadoc javadoc= (Javadoc) rewrite.getASTRewrite().createStringPlaceholder(string, ASTNode.JAVADOC);
newDeclaration.setJavadoc(javadoc);
}
}
if (fLinkedProposalModel != null) {
addLinkedPosition(KEY_TYPE_NAME, newDeclaration.getName(), rewrite.getASTRewrite(), false);
ModifierCorrectionSubProcessor.installLinkedVisibilityProposals(fLinkedProposalModel, rewrite.getASTRewrite(), newDeclaration.modifiers(), false);
}
return newDeclaration;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:66,代码来源:ConvertAnonymousToNestedRefactoring.java
示例8: createTypeComment
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private String createTypeComment(IType type, String lineDelimiter) throws CoreException {
String[] typeParameterNames= StubUtility.getTypeParameterNames(type.getTypeParameters());
return CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParameterNames, lineDelimiter);
}
示例9: getTypeComment
import org.eclipse.jdt.ui.CodeGeneration; //导入方法依赖的package包/类
private String getTypeComment(String lineDelimiterUsed) throws CoreException {
ICompilationUnit cu= fCreatedPackageFragment.getCompilationUnit(PACKAGE_INFO_JAVA_FILENAME);
String typeName= PACKAGE_INFO_JAVA_FILENAME.substring(0, PACKAGE_INFO_JAVA_FILENAME.length() - JavaModelUtil.DEFAULT_CU_SUFFIX.length());
return CodeGeneration.getTypeComment(cu, typeName, lineDelimiterUsed);
}