当前位置: 首页>>代码示例>>Java>>正文


Java RefactoringStatusContext类代码示例

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


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

示例1: addEntry

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private static void addEntry(RefactoringStatus status, IMethod sourceMethod, int severity,
		PreconditionFailure failure, IJavaElement... relatedElementCollection) {
	String message = formatMessage(failure.getMessage(), relatedElementCollection);

	// add the first element as the context if appropriate.
	if (relatedElementCollection.length > 0 && relatedElementCollection[0] instanceof IMember) {
		IMember member = (IMember) relatedElementCollection[0];
		RefactoringStatusContext context = JavaStatusContext.create(member);
		status.addEntry(new RefactoringStatusEntry(severity, message, context,
				MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID, failure.ordinal(),
				sourceMethod));
	} else // otherwise, just add the message.
		status.addEntry(new RefactoringStatusEntry(severity, message, null,
				MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID, failure.ordinal(),
				sourceMethod));
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:17,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例2: checkParameterNamesInRippleMethods

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private RefactoringStatus checkParameterNamesInRippleMethods() throws JavaModelException {
  RefactoringStatus result = new RefactoringStatus();
  Set<String> newParameterNames = getNewParameterNamesList();
  for (int i = 0; i < fRippleMethods.length; i++) {
    String[] paramNames = fRippleMethods[i].getParameterNames();
    for (int j = 0; j < paramNames.length; j++) {
      if (newParameterNames.contains(paramNames[j])) {
        String[] args =
            new String[] {
              JavaElementUtil.createMethodSignature(fRippleMethods[i]),
              BasicElementLabels.getJavaElementName(paramNames[j])
            };
        String msg =
            Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_already_has, args);
        RefactoringStatusContext context =
            JavaStatusContext.create(
                fRippleMethods[i].getCompilationUnit(), fRippleMethods[i].getNameRange());
        result.addError(msg, context);
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ChangeSignatureProcessor.java

示例3: checkIfDeletedParametersUsed

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
protected void checkIfDeletedParametersUsed() {
  for (Iterator<ParameterInfo> iter = getDeletedInfos().iterator(); iter.hasNext(); ) {
    ParameterInfo info = iter.next();
    VariableDeclaration paramDecl = getParameter(info.getOldIndex());
    TempOccurrenceAnalyzer analyzer = new TempOccurrenceAnalyzer(paramDecl, false);
    analyzer.perform();
    SimpleName[] paramRefs = analyzer.getReferenceNodes();

    if (paramRefs.length > 0) {
      RefactoringStatusContext context =
          JavaStatusContext.create(fCuRewrite.getCu(), paramRefs[0]);
      String typeName = getFullTypeName();
      Object[] keys =
          new String[] {
            BasicElementLabels.getJavaElementName(paramDecl.getName().getIdentifier()),
            BasicElementLabels.getJavaElementName(getMethod().getElementName()),
            BasicElementLabels.getJavaElementName(typeName)
          };
      String msg =
          Messages.format(
              RefactoringCoreMessages.ChangeSignatureRefactoring_parameter_used, keys);
      fResult.addError(msg, context);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:ChangeSignatureProcessor.java

示例4: checkIfOverridesAnother

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
public static RefactoringStatus checkIfOverridesAnother(IMethod method, ITypeHierarchy hierarchy)
    throws JavaModelException {
  IMethod overrides = MethodChecks.overridesAnotherMethod(method, hierarchy);
  if (overrides == null) return null;

  RefactoringStatusContext context = JavaStatusContext.create(overrides);
  String message =
      Messages.format(
          RefactoringCoreMessages.MethodChecks_overrides,
          new String[] {
            JavaElementUtil.createMethodSignature(overrides),
            JavaElementLabels.getElementLabel(
                overrides.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  return RefactoringStatus.createStatus(
      RefactoringStatus.FATAL,
      message,
      context,
      Corext.getPluginId(),
      RefactoringStatusCodes.OVERRIDES_ANOTHER_METHOD,
      overrides);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:MethodChecks.java

示例5: checkIfComesFromInterface

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
public static RefactoringStatus checkIfComesFromInterface(
    IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor)
    throws JavaModelException {
  IMethod inInterface = MethodChecks.isDeclaredInInterface(method, hierarchy, monitor);

  if (inInterface == null) return null;

  RefactoringStatusContext context = JavaStatusContext.create(inInterface);
  String message =
      Messages.format(
          RefactoringCoreMessages.MethodChecks_implements,
          new String[] {
            JavaElementUtil.createMethodSignature(inInterface),
            JavaElementLabels.getElementLabel(
                inInterface.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  return RefactoringStatus.createStatus(
      RefactoringStatus.FATAL,
      message,
      context,
      Corext.getPluginId(),
      RefactoringStatusCodes.METHOD_DECLARED_IN_INTERFACE,
      inInterface);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:MethodChecks.java

示例6: addReferenceShadowedError

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private static void addReferenceShadowedError(
    ICompilationUnit cu, SearchMatch newMatch, String newElementName, RefactoringStatus result) {
  // Found a new match with no corresponding old match.
  // -> The new match is a reference which was pointing to another element,
  // but that other element has been shadowed

  // TODO: should not have to filter declarations:
  if (newMatch instanceof MethodDeclarationMatch || newMatch instanceof FieldDeclarationMatch)
    return;
  ISourceRange range = getOldSourceRange(newMatch);
  RefactoringStatusContext context = JavaStatusContext.create(cu, range);
  String message =
      Messages.format(
          RefactoringCoreMessages.RenameAnalyzeUtil_reference_shadowed,
          new String[] {
            BasicElementLabels.getFileName(cu),
            BasicElementLabels.getJavaElementName(newElementName)
          });
  result.addError(message, context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:RenameAnalyzeUtil.java

示例7: checkTypeNameConflicts

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private RefactoringStatus checkTypeNameConflicts(
    ICompilationUnit iCompilationUnit, Set<String> topLevelTypeNames) throws CoreException {
  RefactoringStatus result = new RefactoringStatus();
  IType[] types = iCompilationUnit.getTypes();

  for (int i = 0; i < types.length; i++) {
    String name = types[i].getElementName();
    if (topLevelTypeNames.contains(name)) {
      String[] keys = {getElementLabel(iCompilationUnit.getParent()), getElementLabel(types[i])};
      String msg =
          Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_contains_type, keys);
      RefactoringStatusContext context = JavaStatusContext.create(types[i]);
      result.addError(msg, context);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenamePackageProcessor.java

示例8: checkClashesWithExistingFields

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private RefactoringStatus checkClashesWithExistingFields() {
  FieldDeclaration[] existingFields = getFieldDeclarations();
  for (int i = 0; i < existingFields.length; i++) {
    FieldDeclaration declaration = existingFields[i];
    VariableDeclarationFragment[] fragments =
        (VariableDeclarationFragment[])
            declaration
                .fragments()
                .toArray(new VariableDeclarationFragment[declaration.fragments().size()]);
    for (int j = 0; j < fragments.length; j++) {
      VariableDeclarationFragment fragment = fragments[j];
      if (fFieldName.equals(fragment.getName().getIdentifier())) {
        // cannot conflict with more than 1 name
        RefactoringStatusContext context = JavaStatusContext.create(fCu, fragment);
        return RefactoringStatus.createFatalErrorStatus(
            RefactoringCoreMessages.PromoteTempToFieldRefactoring_Name_conflict_with_field,
            context);
      }
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:PromoteTempToFieldRefactoring.java

示例9: checkDestinationInsideTypeToMove

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private RefactoringStatus checkDestinationInsideTypeToMove() throws JavaModelException {
	RefactoringStatus result= new RefactoringStatus();
	for (int i= 0; i < fMembersToMove.length; i++) {
		if (! (fMembersToMove[i] instanceof IType))
			continue;
		IType type= (IType) fMembersToMove[i];
		if (fDestinationType.equals(type) || JavaElementUtil.isAncestorOf(type, fDestinationType)) {
			String message= Messages.format(RefactoringCoreMessages.MoveMembersRefactoring_inside,
					new String[] { getQualifiedTypeLabel(type), getQualifiedTypeLabel(fDestinationType)});
			RefactoringStatusContext context= JavaStatusContext.create(fDestinationType.getCompilationUnit(), fDestinationType.getNameRange());
			result.addFatalError(message, context);
			return result;
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:MoveStaticMembersProcessor.java

示例10: checkParameterNamesInRippleMethods

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private RefactoringStatus checkParameterNamesInRippleMethods() throws JavaModelException {
	RefactoringStatus result= new RefactoringStatus();
	Set<String> newParameterNames= getNewParameterNamesList();
	for (int i= 0; i < fRippleMethods.length; i++) {
		String[] paramNames= fRippleMethods[i].getParameterNames();
		for (int j= 0; j < paramNames.length; j++) {
			if (newParameterNames.contains(paramNames[j])){
				String[] args= new String[]{ JavaElementUtil.createMethodSignature(fRippleMethods[i]), BasicElementLabels.getJavaElementName(paramNames[j])};
				String msg= Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_already_has, args);
				RefactoringStatusContext context= JavaStatusContext.create(fRippleMethods[i].getCompilationUnit(), fRippleMethods[i].getNameRange());
				result.addError(msg, context);
			}
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ChangeSignatureProcessor.java

示例11: checkIfDeletedParametersUsed

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
protected void checkIfDeletedParametersUsed() {
	for (Iterator<ParameterInfo> iter= getDeletedInfos().iterator(); iter.hasNext();) {
		ParameterInfo info= iter.next();
		VariableDeclaration paramDecl= getParameter(info.getOldIndex());
		TempOccurrenceAnalyzer analyzer= new TempOccurrenceAnalyzer(paramDecl, false);
		analyzer.perform();
		SimpleName[] paramRefs= analyzer.getReferenceNodes();

		if (paramRefs.length > 0) {
			RefactoringStatusContext context= JavaStatusContext.create(fCuRewrite.getCu(), paramRefs[0]);
			String typeName= getFullTypeName();
			Object[] keys= new String[] { BasicElementLabels.getJavaElementName(paramDecl.getName().getIdentifier()),
					BasicElementLabels.getJavaElementName(getMethod().getElementName()),
					BasicElementLabels.getJavaElementName(typeName) };
			String msg= Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_parameter_used, keys);
			fResult.addError(msg, context);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ChangeSignatureProcessor.java

示例12: checkFieldTypes

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private void checkFieldTypes(final IProgressMonitor monitor, final RefactoringStatus status) throws JavaModelException {
	final Map<IMember, Set<IMember>> mapping= getMatchingMembers(getDestinationTypeHierarchy(monitor), getDestinationType(), true);
	for (int i= 0; i < fMembersToMove.length; i++) {
		if (fMembersToMove[i].getElementType() != IJavaElement.FIELD)
			continue;
		final IField field= (IField) fMembersToMove[i];
		final String type= Signature.toString(field.getTypeSignature());
		Assert.isTrue(mapping.containsKey(field));
		for (final Iterator<IMember> iter= mapping.get(field).iterator(); iter.hasNext();) {
			final IField matchingField= (IField) iter.next();
			if (field.equals(matchingField))
				continue;
			if (type.equals(Signature.toString(matchingField.getTypeSignature())))
				continue;
			final String[] keys= { JavaElementLabels.getTextLabel(matchingField, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getTextLabel(matchingField.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)};
			final String message= Messages.format(RefactoringCoreMessages.PullUpRefactoring_different_field_type, keys);
			final RefactoringStatusContext context= JavaStatusContext.create(matchingField.getCompilationUnit(), matchingField.getSourceRange());
			status.addError(message, context);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:PullUpRefactoringProcessor.java

示例13: checkClashesWithExistingFields

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private RefactoringStatus checkClashesWithExistingFields(){
     FieldDeclaration[] existingFields= getFieldDeclarations();
     for (int i= 0; i < existingFields.length; i++) {
         FieldDeclaration declaration= existingFields[i];
VariableDeclarationFragment[] fragments= (VariableDeclarationFragment[]) declaration.fragments().toArray(new VariableDeclarationFragment[declaration.fragments().size()]);
for (int j= 0; j < fragments.length; j++) {
             VariableDeclarationFragment fragment= fragments[j];
             if (fFieldName.equals(fragment.getName().getIdentifier())){
             	//cannot conflict with more than 1 name
             	RefactoringStatusContext context= JavaStatusContext.create(fCu, fragment);
             	return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.PromoteTempToFieldRefactoring_Name_conflict_with_field, context);
             }
         }
     }
     return null;
 }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:PromoteTempToFieldRefactoring.java

示例14: checkKey

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
private static RefactoringStatus checkKey(String key) {
	RefactoringStatus result= new RefactoringStatus();

	if (key == null)
		result.addFatalError(NLSMessages.NLSRefactoring_null);

	if (key.startsWith("!") || key.startsWith("#")) { //$NON-NLS-1$ //$NON-NLS-2$
		RefactoringStatusContext context= new JavaStringStatusContext(key, new SourceRange(0, 0));
		result.addWarning(NLSMessages.NLSRefactoring_warning, context);
	}

	if ("".equals(key.trim())) //$NON-NLS-1$
		result.addFatalError(NLSMessages.NLSRefactoring_empty);

	final String[] UNWANTED_STRINGS= {" ", ":", "\"", "\\", "'", "?", "="}; //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
	//feature in resource bundle - does not work properly if keys have ":"
	for (int i= 0; i < UNWANTED_STRINGS.length; i++) {
		if (key.indexOf(UNWANTED_STRINGS[i]) != -1) {
			String[] args= {key, UNWANTED_STRINGS[i]};
			String msg= Messages.format(NLSMessages.NLSRefactoring_should_not_contain, args);
			result.addError(msg);
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:NLSRefactoring.java

示例15: setInput

import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; //导入依赖的package包/类
public void setInput(RefactoringStatusContext input) {
	ContentProvider contentProvider= new ContentProvider();

	ReferencesInBinaryContext binariesContext= (ReferencesInBinaryContext) input;
	List<SearchMatch> matches= binariesContext.getMatches();
	for (Iterator<SearchMatch> iter= matches.iterator(); iter.hasNext();) {
		SearchMatch match= iter.next();
		Object element= match.getElement();
		if (element != null)
			contentProvider.add(element);
	}
	fTreeViewer.setContentProvider(contentProvider);
	fTreeViewer.setInput(contentProvider);

	fLabel.setText(binariesContext.getDescription());

	fInput= binariesContext;
	fButton.setEnabled(!matches.isEmpty());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ReferencesInBinaryStatusContextViewer.java


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