mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
parent
9bc829ac73
commit
2cada0fe18
8 changed files with 33 additions and 191 deletions
|
@ -604,9 +604,7 @@ preferenceKeywords.smarttyping=editor typing type close comment tabs indentation
|
|||
historyAction.label = History...
|
||||
createScriptAction.label = Create Script...
|
||||
applyScriptAction.label = Apply Script...
|
||||
renameFolderParticipant.name = Source Folder Rename
|
||||
headerFileMoveParticipant.name = Header File Move
|
||||
headerFileRenameParticipant.name = Header File Rename
|
||||
renameParticipant.name = Source Folder Rename
|
||||
|
||||
FormatAction.label= &Format
|
||||
IndentAction.label= Correct &Indentation
|
||||
|
|
|
@ -4396,55 +4396,23 @@
|
|||
id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring">
|
||||
</contribution>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ltk.core.refactoring.moveParticipants">
|
||||
<moveParticipant id="org.eclipse.cdt.ui.headerFileMoveParticipant"
|
||||
name="%headerFileMoveParticipant.name"
|
||||
class="org.eclipse.cdt.internal.ui.refactoring.rename.HeaderFileMoveParticipant">
|
||||
<enablement>
|
||||
<with variable="affectedNatures">
|
||||
<iterate operator="or">
|
||||
<or>
|
||||
<equals value="org.eclipse.cdt.core.cnature" />
|
||||
<equals value="org.eclipse.cdt.core.ccnature" />
|
||||
</or>
|
||||
</iterate>
|
||||
</with>
|
||||
<with variable="element">
|
||||
<instanceof value="org.eclipse.core.resources.IResource"/>
|
||||
</with>
|
||||
</enablement>
|
||||
</moveParticipant>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ltk.core.refactoring.renameParticipants">
|
||||
<renameParticipant id="org.eclipse.cdt.ui.headerFileRenameParticipant"
|
||||
name="%headerFileRenameParticipant.name"
|
||||
class="org.eclipse.cdt.internal.ui.refactoring.rename.HeaderFileRenameParticipant">
|
||||
<enablement>
|
||||
<with variable="affectedNatures">
|
||||
<iterate operator="or">
|
||||
<or>
|
||||
<equals value="org.eclipse.cdt.core.cnature" />
|
||||
<equals value="org.eclipse.cdt.core.ccnature" />
|
||||
</or>
|
||||
</iterate>
|
||||
</with>
|
||||
<with variable="element">
|
||||
<instanceof value="org.eclipse.core.resources.IResource"/>
|
||||
</with>
|
||||
</enablement>
|
||||
</renameParticipant>
|
||||
<renameParticipant id="org.eclipse.cdt.ui.RenameSourceFolder"
|
||||
name="%renameFolderParticipant.name"
|
||||
name="%renameParticipant.name"
|
||||
class="org.eclipse.cdt.internal.ui.refactoring.rename.RenameSourceFolder">
|
||||
<enablement>
|
||||
<or>
|
||||
<with variable="affectedNatures">
|
||||
<iterate operator="or">
|
||||
<or>
|
||||
<equals value="org.eclipse.cdt.core.cnature" />
|
||||
<equals value="org.eclipse.cdt.core.ccnature" />
|
||||
</or>
|
||||
</iterate>
|
||||
</with>
|
||||
<with variable="affectedNatures">
|
||||
<iterate operator="or">
|
||||
<equals value="org.eclipse.cdt.core.cnature" />
|
||||
</iterate>
|
||||
</with>
|
||||
</or>
|
||||
<with variable="element">
|
||||
<instanceof value="org.eclipse.core.resources.IFolder" />
|
||||
</with>
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.rename;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
|
||||
import org.eclipse.ltk.core.refactoring.participants.MoveArguments;
|
||||
import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
|
||||
|
||||
public class HeaderFileMoveParticipant extends MoveParticipant {
|
||||
private IResource element;
|
||||
|
||||
public HeaderFileMoveParticipant() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean initialize(Object element) {
|
||||
if (element instanceof IResource) {
|
||||
this.element = (IResource) element;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
|
||||
throws OperationCanceledException {
|
||||
return RefactoringStatus.create(Status.OK_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
|
||||
MoveArguments args = getArguments();
|
||||
if (!args.getUpdateReferences())
|
||||
return null;
|
||||
Object destination = args.getDestination();
|
||||
if (!(destination instanceof IContainer))
|
||||
return null;
|
||||
IPath destinationLocation = ((IContainer) destination).getLocation();
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return RenameMessages.HeaderFileMoveParticipant_name;
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Google, Inc and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.rename;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
|
||||
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
|
||||
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
|
||||
|
||||
public class HeaderFileRenameParticipant extends RenameParticipant {
|
||||
private IResource element;
|
||||
|
||||
public HeaderFileRenameParticipant() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean initialize(Object element) {
|
||||
if (element instanceof IResource) {
|
||||
this.element = (IResource) element;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
|
||||
throws OperationCanceledException {
|
||||
return RefactoringStatus.create(Status.OK_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
|
||||
RenameArguments arguments = getArguments();
|
||||
if (!arguments.getUpdateReferences())
|
||||
return null;
|
||||
String newName = arguments.getNewName();
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return RenameMessages.HeaderFileRenameParticipant_name;
|
||||
}
|
||||
}
|
|
@ -95,23 +95,23 @@ public class RenameCSourceFolderChange extends Change {
|
|||
|
||||
private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){
|
||||
Set<ICSourceEntry> set = new HashSet<>();
|
||||
for (ICSourceEntry entry : entries){
|
||||
String seLocation = entry.getName();
|
||||
for (ICSourceEntry se : entries){
|
||||
String seLocation = se.getName();
|
||||
if (seLocation.equals(oldName.toPortableString())) {
|
||||
ICSourceEntry newSE = new CSourceEntry(newName, entry.getExclusionPatterns(), entry.getFlags());
|
||||
ICSourceEntry newSE = new CSourceEntry(newName, se.getExclusionPatterns(), se.getFlags());
|
||||
set.add(newSE);
|
||||
} else {
|
||||
Set<IPath> exclusionPatterns = new HashSet<>();
|
||||
for (IPath filter : entry.getExclusionPatterns()) {
|
||||
Set<IPath> exPatters = new HashSet<>();
|
||||
for (IPath filter : se.getExclusionPatterns()) {
|
||||
IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() -1);
|
||||
if (filter.equals(oldSegments)) {
|
||||
exclusionPatterns.add(newName.removeFirstSegments(newName.segmentCount() - 1));
|
||||
exPatters.add(newName.removeFirstSegments(newName.segmentCount() - 1));
|
||||
} else {
|
||||
exclusionPatterns.add(filter);
|
||||
exPatters.add(filter);
|
||||
}
|
||||
}
|
||||
|
||||
set.add(new CSourceEntry(entry.getValue(), exclusionPatterns.toArray(new IPath[exclusionPatterns.size()]), entry.getFlags()));
|
||||
set.add(new CSourceEntry(se.getValue(), exPatters.toArray(new IPath[exPatters.size()]), se.getFlags()));
|
||||
}
|
||||
}
|
||||
return set.toArray(new ICSourceEntry[set.size()]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2014 Wind River Systems, Inc.
|
||||
* Copyright (c) 2004, 2010 Wind River Systems, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -97,11 +97,9 @@ class RenameMessages extends NLS {
|
|||
public static String CRenameTopProcessor_virtualMethod;
|
||||
public static String CRenameTopProcessor_wizard_backup_title;
|
||||
public static String CRenameTopProcessor_wizard_title;
|
||||
public static String HeaderFileMoveParticipant_name;
|
||||
public static String HeaderFileRenameParticipant_name;
|
||||
public static String RenameCSourceFolderChange_ErrorMsg;
|
||||
public static String RenameCSourceFolderChange_Name0;
|
||||
public static String RenameSourceFolder_name;
|
||||
public static String RenameSourceFolder_0;
|
||||
public static String RenameInformationPopup_delayJobName;
|
||||
public static String RenameInformationPopup_EnterNewName;
|
||||
public static String RenameInformationPopup_menu;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2005, 2014 IBM Corporation and others.
|
||||
# Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -10,7 +10,7 @@
|
|||
# Markus Schorn, Wind River Systems Inc.
|
||||
# Sergey Prigogin (Google)
|
||||
###############################################################################
|
||||
ASTManager_error_macro_name_conflict=''{0}'' conflicts with the name of an existing macro.
|
||||
ASTManager_error_macro_name_conflict=''{0}'' conflicts with the name of an existing macro!
|
||||
ASTManager_subtask_analyzing=Analyzing {0} files
|
||||
ASTManager_task_analyze=Analyzing source code
|
||||
ASTManager_task_generateAst=Generating AST
|
||||
|
@ -93,11 +93,9 @@ CRenameTopProcessor_type=type
|
|||
CRenameTopProcessor_virtualMethod=virtual method
|
||||
CRenameTopProcessor_wizard_backup_title=Rename
|
||||
CRenameTopProcessor_wizard_title=Rename ''{0}''
|
||||
HeaderFileMoveParticipant_name=Header File Move
|
||||
HeaderFileRenameParticipant_name=Header File Rename
|
||||
RenameCSourceFolderChange_ErrorMsg=Folder {0} does not exist
|
||||
RenameCSourceFolderChange_Name0=Rename source folder {0} to {1}
|
||||
RenameSourceFolder_name=Rename C/C++ Source Folder
|
||||
RenameSourceFolder_0=Rename C/C++ Source Folder
|
||||
RenameInformationPopup_SnapTo=&Snap To
|
||||
RenameInformationPopup_snap_under_left=&Under Left
|
||||
RenameInformationPopup_snap_under_right=U&nder Right
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.ltk.core.refactoring.Change;
|
||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
|
||||
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
|
||||
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +28,7 @@ import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
|
|||
*/
|
||||
public class RenameSourceFolder extends RenameParticipant {
|
||||
private IFolder oldFolder;
|
||||
private String newName;
|
||||
|
||||
public RenameSourceFolder() {
|
||||
}
|
||||
|
@ -34,20 +36,21 @@ public class RenameSourceFolder extends RenameParticipant {
|
|||
@Override
|
||||
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
|
||||
throws OperationCanceledException {
|
||||
RenameArguments arg = getArguments();
|
||||
newName = arg.getNewName();
|
||||
return RefactoringStatus.create(Status.OK_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
|
||||
IPath oldFolderPath = oldFolder.getFullPath();
|
||||
String newName = getArguments().getNewName();
|
||||
IPath newFolderPath = oldFolderPath.removeLastSegments(1).append(newName);
|
||||
IPath newFolderPath = oldFolder.getFullPath().uptoSegment(oldFolder.getFullPath().segmentCount() - 1).append(newName);
|
||||
return new RenameCSourceFolderChange(oldFolderPath, newFolderPath, oldFolder.getProject(), oldFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return RenameMessages.RenameSourceFolder_name;
|
||||
return RenameMessages.RenameSourceFolder_0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue