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


Java NewVariableCorrectionProposal類代碼示例

本文整理匯總了Java中org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal的典型用法代碼示例。如果您正苦於以下問題:Java NewVariableCorrectionProposal類的具體用法?Java NewVariableCorrectionProposal怎麽用?Java NewVariableCorrectionProposal使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NewVariableCorrectionProposal類屬於org.eclipse.jdt.internal.ui.text.correction.proposals包,在下文中一共展示了NewVariableCorrectionProposal類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addEnhancedForWithoutTypeProposals

import org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal; //導入依賴的package包/類
private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) {
	if (selectedNode instanceof SimpleName && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY || selectedNode.getLocationInParent() == NameQualifiedType.NAME_PROPERTY)) {
		ASTNode type= selectedNode.getParent();
		if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
			SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent();
			if (svd.getLocationInParent() == EnhancedForStatement.PARAMETER_PROPERTY) {
				if (svd.getName().getLength() == 0) {
					SimpleName simpleName= (SimpleName) selectedNode;
					String name= simpleName.getIdentifier();
					int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7;
					String label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_create_loop_variable_description, BasicElementLabels.getJavaElementName(name));
					Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
					
					proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL, simpleName, null, relevance, image));
				}
			}
		}
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:20,代碼來源:UnresolvedElementsSubProcessor.java

示例2: addEnhancedForWithoutTypeProposals

import org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal; //導入依賴的package包/類
private static void addEnhancedForWithoutTypeProposals(
    ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) {
  if (selectedNode instanceof SimpleName
      && (selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY
          || selectedNode.getLocationInParent() == NameQualifiedType.NAME_PROPERTY)) {
    ASTNode type = selectedNode.getParent();
    if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) {
      SingleVariableDeclaration svd = (SingleVariableDeclaration) type.getParent();
      if (svd.getLocationInParent() == EnhancedForStatement.PARAMETER_PROPERTY) {
        if (svd.getName().getLength() == 0) {
          SimpleName simpleName = (SimpleName) selectedNode;
          String name = simpleName.getIdentifier();
          int relevance = StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7;
          String label =
              Messages.format(
                  CorrectionMessages
                      .UnresolvedElementsSubProcessor_create_loop_variable_description,
                  BasicElementLabels.getJavaElementName(name));
          Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);

          proposals.add(
              new NewVariableCorrectionProposal(
                  label,
                  cu,
                  NewVariableCorrectionProposal.LOCAL,
                  simpleName,
                  null,
                  relevance,
                  image));
        }
      }
    }
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:35,代碼來源:UnresolvedElementsSubProcessor.java

示例3: addNewFieldForType

import org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal; //導入依賴的package包/類
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding, ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst, Collection<ICommandAccess> proposals) {
	String name= simpleName.getIdentifier();
	String nameLabel= BasicElementLabels.getJavaElementName(name);
	String label;
	Image image;
	if (senderDeclBinding.isEnum() && !isWriteAccess) {
		label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createenum_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
		image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
		proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.ENUM_CONST, simpleName, senderDeclBinding, 10, image));
	} else {
		if (!mustBeConst) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_description, nameLabel);
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_other_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) } );
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
			}
			int fieldRelevance= StubUtility.hasFieldName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_FIELD_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_FIELD;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.FIELD, simpleName, senderDeclBinding, fieldRelevance, image));
		}

		if (!isWriteAccess && !senderDeclBinding.isAnonymous()) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_description, nameLabel);
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_other_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) } );
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
			}
			int constRelevance= StubUtility.hasConstantName(targetCU.getJavaProject(), name) ? IProposalRelevance.CREATE_CONSTANT_PREFIX_OR_SUFFIX_MATCH : IProposalRelevance.CREATE_CONSTANT;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.CONST_FIELD, simpleName, senderDeclBinding, constRelevance, image));
		}
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:36,代碼來源:UnresolvedElementsSubProcessor.java

示例4: addNewFieldForType

import org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal; //導入依賴的package包/類
private static void addNewFieldForType(ICompilationUnit targetCU, ITypeBinding binding, ITypeBinding senderDeclBinding, SimpleName simpleName, boolean isWriteAccess, boolean mustBeConst, Collection<ICommandAccess> proposals) {
	String name= simpleName.getIdentifier();
	String nameLabel= BasicElementLabels.getJavaElementName(name);
	String label;
	Image image;
	if (senderDeclBinding.isEnum() && !isWriteAccess) {
		label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createenum_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) });
		image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
		proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.ENUM_CONST, simpleName, senderDeclBinding, 10, image));
	} else {
		if (!mustBeConst) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_description, nameLabel);
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createfield_other_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) } );
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
			}
			int fieldRelevance= StubUtility.hasFieldName(targetCU.getJavaProject(), name) ? 9 : 6;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.FIELD, simpleName, senderDeclBinding, fieldRelevance, image));
		}

		if (!isWriteAccess && !senderDeclBinding.isAnonymous()) {
			if (binding == null) {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_description, nameLabel);
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE);
			} else {
				label= Messages.format(CorrectionMessages.UnresolvedElementsSubProcessor_createconst_other_description, new Object[] { nameLabel, ASTResolving.getTypeSignature(senderDeclBinding) } );
				image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
			}
			int constRelevance= StubUtility.hasConstantName(targetCU.getJavaProject(), name) ? 9 : 4;
			proposals.add(new NewVariableCorrectionProposal(label, targetCU, NewVariableCorrectionProposal.CONST_FIELD, simpleName, senderDeclBinding, constRelevance, image));
		}
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion-Juno38,代碼行數:36,代碼來源:UnresolvedElementsSubProcessor.java


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