コード例 #1
0
 private RefactoringStatus checkExpressionFragmentIsRValue() throws JavaModelException {
   /* Moved this functionality to Checks, to allow sharing with
   ExtractTempRefactoring, others */
   switch (Checks.checkExpressionIsRValue(getSelectedExpression().getAssociatedExpression())) {
     case Checks.NOT_RVALUE_MISC:
       return RefactoringStatus.createStatus(
           RefactoringStatus.FATAL,
           RefactoringCoreMessages.ExtractConstantRefactoring_select_expression,
           null,
           Corext.getPluginId(),
           RefactoringStatusCodes.EXPRESSION_NOT_RVALUE,
           null);
     case Checks.NOT_RVALUE_VOID:
       return RefactoringStatus.createStatus(
           RefactoringStatus.FATAL,
           RefactoringCoreMessages.ExtractConstantRefactoring_no_void,
           null,
           Corext.getPluginId(),
           RefactoringStatusCodes.EXPRESSION_NOT_RVALUE_VOID,
           null);
     case Checks.IS_RVALUE_GUESSED:
     case Checks.IS_RVALUE:
       return new RefactoringStatus();
     default:
       Assert.isTrue(false);
       return null;
   }
 }
コード例 #2
0
 public void testCheckAmbiguityInRoleMethodSpec3() throws Exception {
   // check ambiguous role method specifier in callout binding of T3.R2
   RefactoringStatus expected =
       RefactoringUtil.addAmbiguityFatalError(null, new ExtractMethodAmbuguityMsgCreator());
   RefactoringStatus actual =
       RefactoringUtil.checkForAmbiguousRoleMethodSpecs(
           _t3r2, "m", new ExtractMethodAmbuguityMsgCreator());
   assertEquals(expected.getSeverity(), actual.getSeverity());
   assertNotNull(
       expected.getEntryMatchingCode(
           Corext.getPluginId(), OTRefactoringStatusCodes.AMBIGUOUS_METHOD_SPECIFIER));
   assertNotNull(
       actual.getEntryMatchingCode(
           Corext.getPluginId(), OTRefactoringStatusCodes.AMBIGUOUS_METHOD_SPECIFIER));
 }
コード例 #3
0
 public void testCheckAmbiguityInBaseMethodSpec2() throws Exception {
   // check ambiguous base method specifier in callout binding of T3.R2
   RefactoringStatus expected =
       RefactoringUtil.addAmbiguityFatalError(null, new ExtractMethodAmbuguityMsgCreator());
   ArrayList<IRoleType> boundRole = new ArrayList<IRoleType>();
   boundRole.add(_t3r2);
   RefactoringStatus actual =
       RefactoringUtil.checkForAmbiguousBaseMethodSpecs(
           boundRole, "f", "", new ExtractMethodAmbuguityMsgCreator());
   assertEquals(expected.getSeverity(), actual.getSeverity());
   assertNotNull(
       expected.getEntryMatchingCode(
           Corext.getPluginId(), OTRefactoringStatusCodes.AMBIGUOUS_METHOD_SPECIFIER));
   assertNotNull(
       actual.getEntryMatchingCode(
           Corext.getPluginId(), OTRefactoringStatusCodes.AMBIGUOUS_METHOD_SPECIFIER));
 }
コード例 #4
0
 /* test overloading of private base method */
 public void testCheckOverloading9() throws Exception {
   // focus type -> C
   ICompilationUnit cu = _c.getCompilationUnit();
   int[] selection = getSelection(cu.getSource());
   _refactoring = new ExtractMethodRefactoring(cu, selection[0], selection[1]);
   _refactoring.setMethodName("n");
   _refactoring.setVisibility(Modifier.PRIVATE);
   _refactoring.checkInitialConditions(new NullProgressMonitor());
   IMethod[] inheritedMethods = RefactoringUtil.getInheritedMethods(_c, true, true, false, null);
   RefactoringStatus expected =
       RefactoringUtil.addOverloadingWarning(new ExtractMethodOverloadingMsgCreator());
   RefactoringStatus actual =
       RefactoringUtil.checkOverloading(
           inheritedMethods,
           _refactoring.getMethodName(),
           fetchNewParameterTypes(),
           new ExtractMethodOverloadingMsgCreator());
   assertEquals(expected.getSeverity(), actual.getSeverity());
   assertNotNull(
       expected.getEntryMatchingCode(Corext.getPluginId(), OTRefactoringStatusCodes.OVERLOADING));
   assertNotNull(
       actual.getEntryMatchingCode(Corext.getPluginId(), OTRefactoringStatusCodes.OVERLOADING));
 }