Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:37:56+00:00 2026-06-17T10:37:56+00:00

I could use Refactor->Inine when I need to inline a method. This the code

  • 0

I could use Refactor->Inine when I need to inline a method.

enter image description here
enter image description here
enter image description here
enter image description here

This the code skeleton that I tried, I used the code in this post – Is there any eclipse refactoring API that I can call programmatically?.

// 1. Get ICompiationUnit for type "smcho.Hello"
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("Hello");
project.open(null /* IProgressMonitor */);

IJavaProject javaProject = JavaCore.create(project);
IType itype = javaProject.findType("smcho.Hello");
org.eclipse.jdt.core.ICompilationUnit icu = itype.getCompilationUnit();

// 2. Contribution and Description creation
RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(IJavaRefactorings.INLINE_METHOD);
InlineMethodDescriptor descriptor = (InlineMethodDescriptor) contribution.createDescriptor();

descriptor.setProject(icu.getResource().getProject().getName( ));

// 3. executing the refactoring
RefactoringStatus status = new RefactoringStatus();
try {
    Refactoring refactoring = descriptor.createRefactoring(status);

    IProgressMonitor monitor = new NullProgressMonitor();
    refactoring.checkInitialConditions(monitor);
    refactoring.checkFinalConditions(monitor);
    Change change = refactoring.createChange(monitor);
    change.perform(monitor);
} catch (CoreException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} 

When I execute the code, I got this error

org.eclipse.core.runtime.CoreException: The refactoring script argument 'input' is missing 
in the refactoring script.  

I think I need to give the refactored method name to the API. What might be wrong in the code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:37:57+00:00Added an answer on June 17, 2026 at 10:37 am

    This is the code that works with inline refactoring JDT API.
    It requires start position and length to be inlined.

    int[] selection= {start, length}; // getSelection();
    InlineMethodRefactoring refactoring= InlineMethodRefactoring.create(this.icu, new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(this.icu, true), selection[0], selection[1]);
    refactoring.setDeleteSource(true);
    refactoring.setCurrentMode(Mode.INLINE_ALL); // or INLINE SINGLE based on the user's intervention
    
    IProgressMonitor pm= new NullProgressMonitor();
    RefactoringStatus res = refactoring.checkInitialConditions(pm);
    res = refactoring.checkFinalConditions(pm);
    
    final PerformRefactoringOperation op= new PerformRefactoringOperation(
    refactoring, getCheckingStyle());
    op.run(new NullProgressMonitor());
    

    When you know the name of the method that is going to be inlined, you can use the code in – Getting startPosition and length of a method invocation using JDT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How could I refactor this code to use only one Dir[ ] call? Dir[
There's some legacy code that I would like to refactor. There is some data
I've inherited a rather large application that really could use some cleanup. There is
I could use another pair of eyes. This script does what I want in
I could use some help with expression conversion. I have a method on a
I could use a bit of help with this, as i am new to
could someone help me with the regex pattern that i could use to match
I know I could use PHP to do this, but wanted to find out
I always thought that you could use OR in a LIKE statment to query
I use code rush and refactor pro (highlight possible code issues and so on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.