Search in sources :

Example 11 with InnovationContext

use of org.eclipse.jdt.ls.core.internal.corrections.InnovationContext in project eclipse.jdt.ls by eclipse.

the class SourceAssistProcessor method getInnovationContext.

public static InnovationContext getInnovationContext(CodeActionParams params, IProgressMonitor monitor) {
    final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(params.getTextDocument().getUri());
    if (unit == null) {
        return null;
    }
    int start = DiagnosticsHelper.getStartOffset(unit, params.getRange());
    int end = DiagnosticsHelper.getEndOffset(unit, params.getRange());
    InnovationContext context = new InnovationContext(unit, start, end - start);
    CompilationUnit astRoot = CoreASTProvider.getInstance().getAST(unit, CoreASTProvider.WAIT_YES, monitor);
    if (astRoot == null) {
        return null;
    }
    context.setASTRoot(astRoot);
    return context;
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) InnovationContext(org.eclipse.jdt.ls.core.internal.corrections.InnovationContext)

Aggregations

InnovationContext (org.eclipse.jdt.ls.core.internal.corrections.InnovationContext)11 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)8 ASTNode (org.eclipse.jdt.core.dom.ASTNode)7 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)6 CoreException (org.eclipse.core.runtime.CoreException)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Expression (org.eclipse.jdt.core.dom.Expression)3 ParenthesizedExpression (org.eclipse.jdt.core.dom.ParenthesizedExpression)3 Map (java.util.Map)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 AbstractTypeDeclaration (org.eclipse.jdt.core.dom.AbstractTypeDeclaration)2 BodyDeclaration (org.eclipse.jdt.core.dom.BodyDeclaration)2 CastExpression (org.eclipse.jdt.core.dom.CastExpression)2 ChildListPropertyDescriptor (org.eclipse.jdt.core.dom.ChildListPropertyDescriptor)2 ConditionalExpression (org.eclipse.jdt.core.dom.ConditionalExpression)2 EmptyStatement (org.eclipse.jdt.core.dom.EmptyStatement)2 ExpressionStatement (org.eclipse.jdt.core.dom.ExpressionStatement)2 ForStatement (org.eclipse.jdt.core.dom.ForStatement)2 IfStatement (org.eclipse.jdt.core.dom.IfStatement)2