Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/LinkedCorrectionProposal.java

Issue 10834222: Initial implementation of 'Create Method' quick fix (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use resolveUnit() in ASTProvider Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/LinkedCorrectionProposal.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/LinkedCorrectionProposal.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/LinkedCorrectionProposal.java
new file mode 100644
index 0000000000000000000000000000000000000000..74365f0df80a8feb8494c4f71164b67fe1fd2e86
--- /dev/null
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/text/correction/proposals/LinkedCorrectionProposal.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012, the Dart project authors.
+ *
+ * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.dart.tools.ui.internal.text.correction.proposals;
+
+import com.google.dart.tools.core.dom.rewrite.TrackedNodePosition;
+import com.google.dart.tools.core.model.CompilationUnit;
+
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A proposal for quick fixes and quick assists that applies change and enters the linked mode when
+ * the proposal is set up.
+ */
+public class LinkedCorrectionProposal extends CUCorrectionProposal {
+
+ public LinkedCorrectionProposal(String name, CompilationUnit cu, TextChange change,
+ int relevance, Image image) {
+ super(name, cu, change, relevance, image);
+ }
+
+ /**
+ * Adds a linked position to be shown when the proposal is applied. All position with the same
+ * group id are linked.
+ *
+ * @param position The position to add.
+ * @param isFirst If set, the proposal is jumped to first.
+ * @param groupID The id of the group the proposal belongs to. All proposals in the same group are
+ * linked.
+ */
+ public void addLinkedPosition(TrackedNodePosition position, boolean isFirst, String groupID) {
+ getLinkedProposalModel().getPositionGroup(groupID, true).addPosition(position, isFirst);
+ }
+
+// /**
+// * Adds a linked position proposal to the group with the given id.
+// *
+// * @param groupID The id of the group that should present the proposal
+// * @param type The binding to use as type name proposal.
+// */
+// public void addLinkedPositionProposal(String groupID, ITypeBinding type) {
+// getLinkedProposalModel().getPositionGroup(groupID, true).addProposal(
+// type,
+// getCompilationUnit(),
+// 10);
+// }
+
+ /**
+ * Adds a linked position proposal to the group with the given id.
+ *
+ * @param groupID The id of the group that should present the proposal
+ * @param proposal The string to propose.
+ * @param image The image to show for the position proposal or <code>null</code> if no image is
+ * desired.
+ */
+ public void addLinkedPositionProposal(String groupID, String proposal, Image image) {
+ getLinkedProposalModel().getPositionGroup(groupID, true).addProposal(proposal, image, 10);
+ }
+
+ /**
+ * Sets the end position of the linked mode to the end of the passed range.
+ *
+ * @param position The position that describes the end position of the linked mode.
+ */
+ public void setEndPosition(TrackedNodePosition position) {
+ getLinkedProposalModel().setEndPosition(position);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698