use of org.eclipse.ltk.core.refactoring.GroupCategorySet in project che by eclipse.
the class InternalLanguageElementNode method getGroupCategorySet.
private GroupCategorySet getGroupCategorySet() {
if (fGroupCategories == null) {
fGroupCategories = GroupCategorySet.NONE;
for (Iterator iter = fChildren.iterator(); iter.hasNext(); ) {
PreviewNode node = (PreviewNode) iter.next();
GroupCategorySet other = null;
if (node instanceof TextEditGroupNode) {
other = ((TextEditGroupNode) node).getGroupCategorySet();
} else if (node instanceof InternalLanguageElementNode) {
other = ((InternalLanguageElementNode) node).getGroupCategorySet();
} else {
//$NON-NLS-1$
Assert.isTrue(false, "Shouldn't happen");
}
fGroupCategories = GroupCategorySet.union(fGroupCategories, other);
}
}
return fGroupCategories;
}
use of org.eclipse.ltk.core.refactoring.GroupCategorySet 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.GroupCategorySet 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