<commit_before>package scala.tools.eclipse.quickfix

import scala.tools.eclipse.refactoring.RefactoringAction
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal
import org.eclipse.jface.text.IDocument
import org.eclipse.jface.text.contentassist.IContextInformation
import org.eclipse.swt.graphics.Image
import org.eclipse.swt.graphics.Point
import scala.tools.eclipse.refactoring.ActionAdapter
import scala.tools.eclipse.refactoring.rename.RenameAction
import scala.tools.eclipse.refactoring.ScalaIdeRefactoring
import scala.tools.eclipse.logging.HasLogger

abstract class ProposalRefactoringActionAdapter(
    val action: ActionAdapter, 
    relevance: Int, 
    displayString: String)
	extends IJavaCompletionProposal {
  
  def apply(document: IDocument): Unit = {
    action.run(null)
  }
  
  override def getRelevance = relevance
  def getDisplayString(): String = displayString
  def getSelection(document: IDocument): Point = null
  def getAdditionalProposalInfo(): String = null
  def getImage(): Image = null
  def getContextInformation: IContextInformation = null

  def isValidProposal : Boolean = {
    val ra = action match {
      case refactoringAction: RefactoringAction => refactoringAction
      case renameAction : RenameAction => renameAction.getRenameAction
    }
    ra.createScalaIdeRefactoringForCurrentEditorAndSelection match {
    	case Some(refactoring) => !refactoring.checkInitialConditions(null).hasWarning
    	case None	=> false
    }
  }
  
}<commit_msg>add some comments<commit_after>package scala.tools.eclipse.quickfix

import scala.tools.eclipse.refactoring.RefactoringAction
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal
import org.eclipse.jface.text.IDocument
import org.eclipse.jface.text.contentassist.IContextInformation
import org.eclipse.swt.graphics.Image
import org.eclipse.swt.graphics.Point
import scala.tools.eclipse.refactoring.ActionAdapter
import scala.tools.eclipse.refactoring.rename.RenameAction
import scala.tools.eclipse.refactoring.ScalaIdeRefactoring
import scala.tools.eclipse.logging.HasLogger

abstract class ProposalRefactoringActionAdapter(
    val action: ActionAdapter, 
    relevance: Int, 
    displayString: String)
	extends IJavaCompletionProposal {
  
  override def apply(document: IDocument): Unit = {
    // document is not used because the refactoring actions use the current editor
    // TODO not sure if this null here is very safe
    action.run(null)
  }
  
  override def getRelevance = relevance
  override def getDisplayString(): String = displayString
  override def getSelection(document: IDocument): Point = null
  override def getAdditionalProposalInfo(): String = null
  override def getImage(): Image = null
  override def getContextInformation: IContextInformation = null

  def isValidProposal : Boolean = {
    val ra = action match {
      case refactoringAction: RefactoringAction => refactoringAction
      case renameAction : RenameAction => renameAction.getRenameAction
    }
    ra.createScalaIdeRefactoringForCurrentEditorAndSelection match {
      // TODO not sure if this null here is very safe
    	case Some(refactoring) => !refactoring.checkInitialConditions(null).hasWarning
    	case None	=> false
    }
  }
  
}
{'fraction_non_alphanumeric': 0.07211538461538461, 'fraction_numerical': 0.0, 'mean_word_length': 4.0980091883614085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5532718', 'n_tokens_mistral': 993, 'n_tokens_neox': 940, 'n_words': 214}