• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StubUtility类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.internal.corext.codemanipulation.StubUtility的典型用法代码示例。如果您正苦于以下问题:Java StubUtility类的具体用法?Java StubUtility怎么用?Java StubUtility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StubUtility类属于org.eclipse.jdt.internal.corext.codemanipulation包,在下文中一共展示了StubUtility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
protected void setUp() throws Exception {
  //		super.setUp();
  //		fWasAutobuild= CoreUtility.setAutoBuilding(false);
  //		if (JavaPlugin.getActivePage() != null)
  //			JavaPlugin.getActivePage().close();

  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
  options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0");
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(9999));

  JavaCore.setOptions(options);
  TestOptions.initializeCodeGenerationOptions();
  JavaPlugin.getDefault().getCodeTemplateStore().load();

  StringBuffer comment = new StringBuffer();
  comment.append("/**\n");
  comment.append(" * ${tags}\n");
  comment.append(" */");
  StubUtility.setCodeTemplate(
      CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, comment.toString(), null);
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:AbstractRefactoringTestSetup.java


示例2: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  String newFileTemplate = "${package_declaration}\n\n${type_declaration}";
  StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID, newFileTemplate, null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:UnresolvedTypesQuickFixTest.java


示例3: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  fJProject1 = Java18ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:AdvancedQuickAssistTest18.java


示例4: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE,
      JavaCore.DO_NOT_INSERT);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = Java17ProjectTestSetup.getProject();

  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:ModifierCorrectionsQuickFixTest17.java


示例5: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE,
      String.valueOf(99));
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:TypeMismatchQuickFixTests.java


示例6: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  options.put(
      DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE,
      JavaCore.DO_NOT_INSERT);
  options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR);
  options.put(JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, JavaCore.ERROR);

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  fJProject1 = ProjectTestSetup.getProject();

  StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
  StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ModifierCorrectionsQuickFixTest.java


示例7: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  fJProject1 = Java18ProjectTestSetup.getProject();
  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:AssistQuickFixTest18.java


示例8: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  //		Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences();
  //		corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  //		corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  //		corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  //		corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  fJProject1 = ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:AdvancedQuickAssistTest.java


示例9: setUp

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  super.setUp();
  Hashtable options = TestOptions.getDefaultOptions();
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
  options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

  JavaCore.setOptions(options);

  IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
  store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
  store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

  StubUtility.setCodeTemplate(
      CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

  //		Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences();
  //		corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
  //		corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
  //		corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
  //		corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

  fJProject1 = Java17ProjectTestSetup.getProject();

  fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:AdvancedQuickAssistTest17.java


示例10: getMethodComment

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
/**
 * Returns the comment for a method or constructor using the comment code templates (constructor /
 * method / overriding method). <code>null</code> is returned if the template is empty.
 *
 * <p>The returned string is unformatted and not indented.
 *
 * @param method The method to be documented. The method must exist.
 * @param overridden The method that will be overridden by the created method or <code>null</code>
 *     for non-overriding methods. If not <code>null</code>, the method must exist.
 * @param lineDelimiter The line delimiter to be used.
 * @return Returns the constructed comment or <code>null</code> if the comment code template is
 *     empty. The returned string is unformatted and and has no indent (formatting required).
 * @throws CoreException Thrown when the evaluation of the code template fails.
 */
public static String getMethodComment(IMethod method, IMethod overridden, String lineDelimiter)
    throws CoreException {
  String retType = method.isConstructor() ? null : method.getReturnType();
  String[] paramNames = method.getParameterNames();
  String[] typeParameterNames =
      StubUtility.shouldGenerateMethodTypeParameterTags(method.getJavaProject())
          ? StubUtility.getTypeParameterNames(method.getTypeParameters())
          : new String[0];

  return StubUtility.getMethodComment(
      method.getCompilationUnit(),
      method.getDeclaringType().getElementName(),
      method.getElementName(),
      paramNames,
      method.getExceptionTypes(),
      retType,
      typeParameterNames,
      overridden,
      false,
      lineDelimiter);
}
 
开发者ID:eclipse,项目名称:che,代码行数:36,代码来源:CodeGeneration.java


示例11: suggestVariableName

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
private String[] suggestVariableName(String type, String[] excludes)
    throws IllegalArgumentException {
  int dim = 0;
  while (type.endsWith("[]")) { // $NON-NLS-1$
    dim++;
    type = type.substring(0, type.length() - 2);
  }

  IJavaProject project = getJavaProject();
  if (project != null)
    return StubUtility.getVariableNameSuggestions(
        NamingConventions.VK_LOCAL, project, type, dim, Arrays.asList(excludes), true);

  // fallback if we lack proper context: roll-our own lowercasing
  return new String[] {Signature.getSimpleName(type).toLowerCase()};
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:JavaContext.java


示例12: getVariableNameProposals

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
private String[] getVariableNameProposals() {

    String[] variableNames = getUsedVariableNames();
    String[] elementSuggestions =
        StubUtility.getLocalNameSuggestions(
            getJavaProject(), FOR_LOOP_ELEMENT_IDENTIFIER, 0, variableNames);

    final ITypeBinding binding = fIteratorVariable.getType();
    if (binding != null && binding.isParameterizedType()) {
      String type = binding.getTypeArguments()[0].getName();
      String[] typeSuggestions =
          StubUtility.getLocalNameSuggestions(getJavaProject(), type, 0, variableNames);

      String[] result = new String[elementSuggestions.length + typeSuggestions.length];
      System.arraycopy(typeSuggestions, 0, result, 0, typeSuggestions.length);
      System.arraycopy(
          elementSuggestions, 0, result, typeSuggestions.length, elementSuggestions.length);
      return result;
    } else {
      return elementSuggestions;
    }
  }
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:ConvertIterableLoopOperation.java


示例13: getUnqualifiedFieldAccessResolveOperation

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
private static AddThisQualifierOperation getUnqualifiedFieldAccessResolveOperation(
    CompilationUnit compilationUnit, IProblemLocation problem) {
  SimpleName name = getName(compilationUnit, problem);
  if (name == null) return null;

  IBinding binding = name.resolveBinding();
  if (binding == null || binding.getKind() != IBinding.VARIABLE) return null;

  ImportRewrite imports = StubUtility.createImportRewrite(compilationUnit, true);

  String replacement =
      getThisExpressionQualifier(((IVariableBinding) binding).getDeclaringClass(), imports, name);
  if (replacement == null) return null;

  if (replacement.length() == 0) replacement = null;

  return new AddThisQualifierOperation(replacement, name);
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:CodeStyleFix.java


示例14: getVariableNameProposals

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
private String[] getVariableNameProposals(ITypeBinding arrayTypeBinding, IJavaProject project) {
  String[] variableNames = getUsedVariableNames();
  String baseName = FOR_LOOP_ELEMENT_IDENTIFIER;
  String name = fArrayBinding.getName();
  if (name.length() > 2 && name.charAt(name.length() - 1) == 's') {
    baseName = name.substring(0, name.length() - 1);
  }
  String[] elementSuggestions =
      StubUtility.getLocalNameSuggestions(project, baseName, 0, variableNames);

  String type = arrayTypeBinding.getElementType().getName();
  String[] typeSuggestions =
      StubUtility.getLocalNameSuggestions(
          project, type, arrayTypeBinding.getDimensions() - 1, variableNames);

  String[] result = new String[elementSuggestions.length + typeSuggestions.length];
  System.arraycopy(elementSuggestions, 0, result, 0, elementSuggestions.length);
  System.arraycopy(typeSuggestions, 0, result, elementSuggestions.length, typeSuggestions.length);
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ConvertForLoopOperation.java


示例15: rewriteAST

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel positionGroups)
    throws CoreException {
  final ASTRewrite rewrite = cuRewrite.getASTRewrite();
  VariableDeclarationFragment fragment = null;
  for (int i = 0; i < fNodes.length; i++) {
    final ASTNode node = fNodes[i];

    final AST ast = node.getAST();

    fragment = ast.newVariableDeclarationFragment();
    fragment.setName(ast.newSimpleName(NAME_FIELD));

    final FieldDeclaration declaration = ast.newFieldDeclaration(fragment);
    declaration.setType(ast.newPrimitiveType(PrimitiveType.LONG));
    declaration
        .modifiers()
        .addAll(
            ASTNodeFactory.newModifiers(
                ast, Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL));

    if (!addInitializer(fragment, node)) continue;

    if (fragment.getInitializer() != null) {

      final TextEditGroup editGroup =
          createTextEditGroup(FixMessages.SerialVersion_group_description, cuRewrite);
      if (node instanceof AbstractTypeDeclaration)
        rewrite
            .getListRewrite(node, ((AbstractTypeDeclaration) node).getBodyDeclarationsProperty())
            .insertAt(declaration, 0, editGroup);
      else if (node instanceof AnonymousClassDeclaration)
        rewrite
            .getListRewrite(node, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY)
            .insertAt(declaration, 0, editGroup);
      else if (node instanceof ParameterizedType) {
        final ParameterizedType type = (ParameterizedType) node;
        final ASTNode parent = type.getParent();
        if (parent instanceof ClassInstanceCreation) {
          final ClassInstanceCreation creation = (ClassInstanceCreation) parent;
          final AnonymousClassDeclaration anonymous = creation.getAnonymousClassDeclaration();
          if (anonymous != null)
            rewrite
                .getListRewrite(anonymous, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY)
                .insertAt(declaration, 0, editGroup);
        }
      } else Assert.isTrue(false);

      addLinkedPositions(rewrite, fragment, positionGroups);
    }

    final String comment =
        CodeGeneration.getFieldComment(
            fUnit,
            declaration.getType().toString(),
            NAME_FIELD,
            StubUtility.getLineDelimiterUsed(fUnit));
    if (comment != null && comment.length() > 0) {
      final Javadoc doc = (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC);
      declaration.setJavadoc(doc);
    }
  }
  if (fragment == null) return;

  positionGroups.setEndPosition(rewrite.track(fragment));
}
 
开发者ID:eclipse,项目名称:che,代码行数:68,代码来源:AbstractSerialVersionOperation.java


示例16: getImportRewrite

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
public ImportRewrite getImportRewrite() {
  if (fImportRewrite == null) {
    // lazily initialized to avoid lengthy processing in checkInitialConditions(..)
    try {
      /* If bindings are to be resolved, then create the AST, so that
       * ImportRewrite#setUseContextToFilterImplicitImports(boolean) will be set to true
       * and ContextSensitiveImportRewriteContext etc. can be used. */
      if (fRoot == null && !fResolveBindings) {
        fImportRewrite = StubUtility.createImportRewrite(fCu, true);
      } else {
        fImportRewrite = StubUtility.createImportRewrite(getRoot(), true);
      }
    } catch (CoreException e) {
      JavaPlugin.log(e);
      throw new IllegalStateException(e.getMessage()); // like ASTParser#createAST(..) does
    }
  }
  return fImportRewrite;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:CompilationUnitRewrite.java


示例17: createFieldsForAccessedLocals

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
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);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:ConvertAnonymousToNestedRefactoring.java


示例18: getNewConstructorComment

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:PromoteTempToFieldRefactoring.java


示例19: guessTempNames

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
/**
 * @return proposed variable names (may be empty, but not null). The first proposal should be used
 *     as "best guess" (if it exists).
 */
public String[] guessTempNames() {
  if (fGuessedTempNames == null) {
    try {
      Expression expression = getSelectedExpression().getAssociatedExpression();
      if (expression != null) {
        ITypeBinding binding = guessBindingForReference(expression);
        fGuessedTempNames =
            StubUtility.getVariableNameSuggestions(
                NamingConventions.VK_LOCAL,
                fCu.getJavaProject(),
                binding,
                expression,
                Arrays.asList(getExcludedVariableNames()));
      }
    } catch (JavaModelException e) {
    }
    if (fGuessedTempNames == null) fGuessedTempNames = new String[0];
  }
  return fGuessedTempNames;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ExtractTempRefactoring.java


示例20: guessConstantNames

import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; //导入依赖的package包/类
/**
 * @return proposed variable names (may be empty, but not null). The first proposal should be used
 *     as "best guess" (if it exists).
 */
public String[] guessConstantNames() {
  if (fGuessedConstNames == null) {
    try {
      Expression expression = getSelectedExpression().getAssociatedExpression();
      if (expression != null) {
        ITypeBinding binding = guessBindingForReference(expression);
        fGuessedConstNames =
            StubUtility.getVariableNameSuggestions(
                NamingConventions.VK_STATIC_FINAL_FIELD,
                fCu.getJavaProject(),
                binding,
                expression,
                Arrays.asList(getExcludedVariableNames()));
      }
    } catch (JavaModelException e) {
    }
    if (fGuessedConstNames == null) fGuessedConstNames = new String[0];
  }
  return fGuessedConstNames;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:ExtractConstantRefactoring.java



注:本文中的org.eclipse.jdt.internal.corext.codemanipulation.StubUtility类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Global类代码示例发布时间:2022-05-22
下一篇:
Java RegressionModel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap