Eclipse中提供了幾個擴展點
基本的重構功能有
Rename
re
re
re
re
pyParticipants
以ReName為例
實現這個擴展點的基本語法
< extension point=
< renameParticipant
id=
name=
class=
< enablement>
< /enablement>
< /renameParticipant>
< /extension>
這裡默認對響應所有改名事件
下面代碼進行了簡單的Eclipse重構功能實現
import re
import re
import re
import re
import re
import re
import re
import re
import re
import re
import org
public class TypeRenameParticipant extends RenameParticipant {
public TypeRenameParticipant() {
}
@Override
public RefactoringStatus checkConditions(IProgressMonitor pm
CheckConditionsContext context) throws OperationCanceledException {
return new RefactoringStatus();
}
@Override
public Change createChange(IProgressMonitor pm) throws CoreException
OperationCanceledException {
IFile file = ResourcesPlugin
TextFileChange textFileChange = new TextFileChange(
file);
ReplaceEdit edit = new ReplaceEdit(
textFileChange
return textFileChange;
}
@Override
public String getName() {
return
}
@Override
protected boolean initialize(Object element) {
// need sub
return true;
}
}
CreateChange方法內實現過於粗糙
Eclipse重構功能結果預覽
通過利用擴展點
Preview的結果如下圖
Java開源技術免費提供,內容來源於互聯網,本文歸原作者所有。