Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 25947 Details for
Bug 63838
[misc] highlight control statement when break/continue selected [mark occurrences]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch against jdt ui (3.1)
bug63838_jdt_ui.patch (text/plain), 6.57 KB, created by
Adam Kiezun
on 2005-08-10 00:35:59 EDT
(
hide
)
Description:
patch against jdt ui (3.1)
Filename:
MIME Type:
Creator:
Adam Kiezun
Created:
2005-08-10 00:35:59 EDT
Size:
6.57 KB
patch
obsolete
>Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java,v >retrieving revision 1.365 >diff -u -r1.365 JavaEditor.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 14 Jun 2005 16:20:33 -0000 1.365 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 10 Aug 2005 04:31:44 -0000 >@@ -208,6 +208,7 @@ > import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectNextAction; > import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectPreviousAction; > import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectionAction; >+import org.eclipse.jdt.internal.ui.search.BreakContinueTargetFinder; > import org.eclipse.jdt.internal.ui.search.ExceptionOccurrencesFinder; > import org.eclipse.jdt.internal.ui.search.ImplementOccurrencesFinder; > import org.eclipse.jdt.internal.ui.search.MethodExitsFinder; >@@ -2929,6 +2930,14 @@ > } > } > >+ if ((matches == null || matches.isEmpty())) { >+ BreakContinueTargetFinder finder= new BreakContinueTargetFinder(); >+ String message= finder.initialize(astRoot, selection.getOffset(), selection.getLength()); >+ if (message == null) { >+ matches= finder.perform(); >+ } >+ } >+ > if ((matches == null || matches.isEmpty()) && (fMarkImplementors || fMarkTypeOccurrences)) { > ImplementOccurrencesFinder finder= new ImplementOccurrencesFinder(); > String message= finder.initialize(astRoot, selection.getOffset(), selection.getLength()); >Index: ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java >diff -N ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/search/BreakContinueTargetFinder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,122 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2005 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.ui.search; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.jdt.core.dom.ASTNode; >+import org.eclipse.jdt.core.dom.ASTVisitor; >+import org.eclipse.jdt.core.dom.BreakStatement; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jdt.core.dom.ContinueStatement; >+import org.eclipse.jdt.core.dom.DoStatement; >+import org.eclipse.jdt.core.dom.EnhancedForStatement; >+import org.eclipse.jdt.core.dom.ForStatement; >+import org.eclipse.jdt.core.dom.Initializer; >+import org.eclipse.jdt.core.dom.LabeledStatement; >+import org.eclipse.jdt.core.dom.MethodDeclaration; >+import org.eclipse.jdt.core.dom.SimpleName; >+import org.eclipse.jdt.core.dom.SwitchStatement; >+import org.eclipse.jdt.core.dom.WhileStatement; >+ >+ >+import org.eclipse.jdt.internal.corext.dom.NodeFinder; >+ >+/** >+ * Class used to find the target for a break or continue statement according >+ * to the language spec. >+ * The target statement is a while, do, switch, for or a labeled statement. >+ * Break is described in section 14.15 of the JLS3 and continue in section 14.16. >+ */ >+public class BreakContinueTargetFinder extends ASTVisitor { >+ private ASTNode fSelected; >+ private List fResult; >+ private boolean fIsBreak; >+ private SimpleName fLabel; >+ private static final Class[] STOPPERS = {MethodDeclaration.class, Initializer.class}; >+ private static final Class[] BREAKTARGETS = {ForStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class, SwitchStatement.class}; >+ private static final Class[] CONTINUETARGETS = {ForStatement.class, EnhancedForStatement.class, WhileStatement.class, DoStatement.class}; >+ >+ public String initialize(CompilationUnit root, int offset, int length) { >+ ASTNode node= NodeFinder.perform(root, offset, length); >+ if (node instanceof BreakStatement || node instanceof ContinueStatement){ >+ fSelected= node; >+ return null; >+ } else { >+ return "No break or continue statement selected"; >+ } >+ } >+ >+ public List perform() { >+ fResult= new ArrayList(); >+ fIsBreak= fSelected instanceof BreakStatement; >+ fLabel= getLabel(); >+ markReferences(); >+ return fResult; >+ } >+ >+ private SimpleName getLabel() { >+ if (fIsBreak){ >+ BreakStatement bs = (BreakStatement) fSelected; >+ return bs.getLabel(); >+ } else { >+ ContinueStatement cs= (ContinueStatement) fSelected; >+ return cs.getLabel(); >+ } >+ } >+ >+ private void markReferences() { >+ ASTNode node= getTarget(fSelected); >+ if (node != null) >+ fResult.add(node); >+ } >+ >+ private ASTNode getTarget(ASTNode node) { >+ do { >+ node= node.getParent(); >+ } while (keepWalkingUp(node)); >+ boolean noEnclosingStatement = (node == null) >+ || (node instanceof MethodDeclaration) >+ || (node instanceof Initializer); >+ return noEnclosingStatement ? null : node; >+ } >+ >+ private boolean keepWalkingUp(ASTNode node) { >+ if (node == null) >+ return false; >+ if (isAnyInstanceOf(STOPPERS, node)) >+ return false; >+ if (fLabel != null && LabeledStatement.class.isInstance(node)){ >+ LabeledStatement ls= (LabeledStatement)node; >+ return ! areEqualLabels(ls.getLabel(), fLabel); >+ } >+ if (fLabel == null && fIsBreak && isAnyInstanceOf(BREAKTARGETS, node)) >+ return false; >+ if (fLabel == null && !fIsBreak && isAnyInstanceOf(CONTINUETARGETS, node)) >+ return false; >+ return true; >+ } >+ >+ //TODO see bug 33739 - resolveBinding always returns null >+ //so we just compare names >+ private static boolean areEqualLabels(SimpleName labelToMatch, SimpleName labelSelected) { >+ return labelSelected.getIdentifier().equals(labelToMatch.getIdentifier()); >+ } >+ >+ private static boolean isAnyInstanceOf(Class[] continueTargets, ASTNode node) { >+ for (int i = 0; i < continueTargets.length; i++) { >+ if (continueTargets[i].isInstance(node)) >+ return true; >+ } >+ return false; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 63838
:
25654
|
25947
|
25948
|
26294
|
26440
|
26441
|
27865
|
27866
|
27948
|
27949