use of org.eclipse.ltk.core.refactoring.GroupCategory in project che by eclipse.
the class TextEditFix method createChange.
/**
* {@inheritDoc}
*/
public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException {
String label = fChangeDescription;
CompilationUnitChange result = new CompilationUnitChange(label, fUnit);
result.setEdit(fEdit);
result.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))));
return result;
}
use of org.eclipse.ltk.core.refactoring.GroupCategory in project che by eclipse.
the class StringFix method createCleanUp.
private static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addNLSTag, boolean removeNLSTag, IProblemLocation[] problems) throws CoreException, JavaModelException {
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
if (!cu.isStructureKnown())
//[clean up] 'Remove unnecessary $NLS-TAGS$' removes necessary ones in case of syntax errors: https://bugs.eclipse.org/bugs/show_bug.cgi?id=285814 :
return null;
List<CategorizedTextEditGroup> result = new ArrayList<CategorizedTextEditGroup>();
List<IProblemLocation> missingNLSProblems = new ArrayList<IProblemLocation>();
for (int i = 0; i < problems.length; i++) {
IProblemLocation problem = problems[i];
if (addNLSTag && problem.getProblemId() == IProblem.NonExternalizedStringLiteral) {
missingNLSProblems.add(problem);
}
if (removeNLSTag && problem.getProblemId() == IProblem.UnnecessaryNLSTag) {
IBuffer buffer = cu.getBuffer();
if (buffer != null) {
TextEdit edit = StringFix.getReplace(problem.getOffset(), problem.getLength(), buffer, false);
if (edit != null) {
String label = FixMessages.StringFix_RemoveNonNls_description;
result.add(new CategorizedTextEditGroup(label, edit, new GroupCategorySet(new GroupCategory(label, label, label))));
}
}
}
}
if (!missingNLSProblems.isEmpty()) {
int[] positions = new int[missingNLSProblems.size()];
int i = 0;
for (Iterator<IProblemLocation> iter = missingNLSProblems.iterator(); iter.hasNext(); ) {
IProblemLocation problem = iter.next();
positions[i] = problem.getOffset();
i++;
}
//TODO nls
//NLSUtil.createNLSEdits(cu, positions);
TextEdit[] edits = null;
if (edits != null) {
for (int j = 0; j < edits.length; j++) {
String label = FixMessages.StringFix_AddNonNls_description;
result.add(new CategorizedTextEditGroup(label, edits[j], new GroupCategorySet(new GroupCategory(label, label, label))));
}
}
}
if (result.isEmpty())
return null;
//$NON-NLS-1$
return new StringFix("", compilationUnit, result.toArray(new TextEditGroup[result.size()]));
}
Aggregations