From 2cada0fe18e4affe0049cd32805428f175b3561a Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 30 May 2014 18:11:12 -0700 Subject: [PATCH] Revert "WIP" This reverts commit 9bc829ac7356a0181898242111aec39b0f0964c2. --- core/org.eclipse.cdt.ui/plugin.properties | 4 +- core/org.eclipse.cdt.ui/plugin.xml | 56 ++++------------ .../rename/HeaderFileMoveParticipant.java | 64 ------------------- .../rename/HeaderFileRenameParticipant.java | 59 ----------------- .../rename/RenameCSourceFolderChange.java | 18 +++--- .../ui/refactoring/rename/RenameMessages.java | 6 +- .../rename/RenameMessages.properties | 8 +-- .../rename/RenameSourceFolder.java | 9 ++- 8 files changed, 33 insertions(+), 191 deletions(-) delete mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java delete mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 28069ba36a4..be1b67e5126 100755 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -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 diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 91985c6b1f1..c50d54b410c 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -4396,55 +4396,23 @@ id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + + + + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java deleted file mode 100644 index fb50540aaa1..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileMoveParticipant.java +++ /dev/null @@ -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; - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java deleted file mode 100644 index ff8d83d7756..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/HeaderFileRenameParticipant.java +++ /dev/null @@ -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; - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java index 5f91e31cec8..f5b94402f32 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java @@ -93,25 +93,25 @@ public class RenameCSourceFolderChange extends Change { CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor()); } - private ICSourceEntry[] renameEntry(ICSourceEntry[] entries) { + private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){ Set 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 exclusionPatterns = new HashSet<>(); - for (IPath filter : entry.getExclusionPatterns()) { + Set 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()]); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java index 20e2ec7b1ee..07482025cda 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java @@ -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; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties index 25606c38d50..e3c27856bd7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties @@ -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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java index e25fd9fe48c..f7ea3a0be0b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java @@ -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