use of org.eclipse.wst.common.core.search.SearchMatch in project webtools.sourceediting by eclipse.
the class XSDComponentDescriptionProvider method getFile.
public IFile getFile(Object component) {
IFile result = null;
if (component instanceof ComponentSpecification) {
result = ((ComponentSpecification) component).getFile();
} else if (component instanceof SearchMatch) {
result = ((SearchMatch) component).getFile();
} else if (component instanceof XSDConcreteComponent) {
XSDConcreteComponent concreteComponent = (XSDConcreteComponent) component;
XSDSchema schema = concreteComponent.getSchema();
if (schema != null) {
// TODO (cs) revisit and test more
//
String location = schema.getSchemaLocation();
String platformResource = "platform:/resource";
if (location != null && location.startsWith(platformResource)) {
Path path = new Path(location.substring(platformResource.length()));
result = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
}
}
}
return result;
}
use of org.eclipse.wst.common.core.search.SearchMatch in project webtools.sourceediting by eclipse.
the class XMLComponentRenameParticipant method createChange.
// private RefactoringStatus createRenameChanges(final IProgressMonitor monitor) throws CoreException {
// Assert.isNotNull(monitor);
// final RefactoringStatus status= new RefactoringStatus();
// try {
// monitor.beginTask("RefactoringMessages.RenameComponentRefactoring_searching", 1);
// createRenameChanges(new SubProgressMonitor(monitor, 1));
// //updateChangeManager(new SubProgressMonitor(monitor, 1), status);
// } finally {
// monitor.done();
// }
// return status;
// }
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
for (Iterator iter = matches.iterator(); iter.hasNext(); ) {
SearchMatch match = (SearchMatch) iter.next();
TextChange textChange = getChangeManager().get(match.getFile());
String newName = getArguments().getNewName();
String qualifier = "";
if (getArguments() instanceof ComponentRenameArguments) {
qualifier = ((ComponentRenameArguments) getArguments()).getQualifier();
}
if (match.getObject() instanceof Node) {
Node node = (Node) match.getObject();
if (node instanceof IDOMAttr) {
IDOMAttr attr = (IDOMAttr) node;
IDOMElement element = (IDOMElement) attr.getOwnerElement();
newName = getNewQName(element, qualifier, newName);
}
newName = RenameComponentProcessor.quoteString(newName);
}
ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), match.getLength(), newName);
String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_reference");
TextChangeCompatibility.addTextEdit(textChange, editName, replaceEdit);
}
// don't create any change now, all the changes are in changeManger variable and will be combined in RenameComponentProcessor.postCreateChange method
return null;
}
Aggregations