diff options
author | nsandonato | 2011-01-26 22:25:29 +0000 |
---|---|---|
committer | nsandonato | 2011-01-26 22:25:29 +0000 |
commit | e8ad7b2afb8ea82b6bcf922fe583c357c13da431 (patch) | |
tree | fbc921af31a7198ba35592848d56ad4528d2abab /bundles/org.eclipse.jst.jsp.ui/src | |
parent | 9779c28ca972108b300d93746ae8457c1ecf474f (diff) | |
download | webtools.sourceediting-e8ad7b2afb8ea82b6bcf922fe583c357c13da431.tar.gz webtools.sourceediting-e8ad7b2afb8ea82b6bcf922fe583c357c13da431.tar.xz webtools.sourceediting-e8ad7b2afb8ea82b6bcf922fe583c357c13da431.zip |
[334150] Breakpoints in JSP fragment (.jspf) files are not hit
Diffstat (limited to 'bundles/org.eclipse.jst.jsp.ui/src')
2 files changed, 85 insertions, 19 deletions
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/ClassPatternRegistry.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/ClassPatternRegistry.java index 321570ac9e..2c53099771 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/ClassPatternRegistry.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/ClassPatternRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2010, 2011 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 @@ -11,13 +11,18 @@ package org.eclipse.jst.jsp.ui.internal.breakpointproviders; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map; +import java.util.Set; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.RegistryFactory; import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin; +import com.ibm.icu.util.StringTokenizer; + /** * This registry provides all additional class patterns to be associated with a specific content type * @@ -36,16 +41,21 @@ public class ClassPatternRegistry { for (int i = 0; i < elements.length; i++) { final IConfigurationElement element = elements[i]; final String contentType = element.getAttribute("contentType"); //$NON-NLS-1$ - String pattern = element.getAttribute("pattern"); //$NON-NLS-1$ + final String pattern = element.getAttribute("pattern"); //$NON-NLS-1$ if (pattern != null && contentType != null) { - String old = (String) fPatterns.get(contentType); - final StringBuffer buffer = old == null ? new StringBuffer() : new StringBuffer(old); - pattern = pattern.trim(); - if (pattern.length() > 0) { - if (pattern.charAt(0) != ',' && buffer.length() > 0 && buffer.charAt(buffer.length() - 1) != ',') - buffer.append(','); - buffer.append(pattern); - fPatterns.put(contentType, buffer.toString()); + final StringTokenizer tokenizer = new StringTokenizer(pattern, ","); //$NON-NLS-1$ + Set patterns = (Set) fPatterns.get(contentType); + if (patterns == null) { + patterns = new HashSet(0); + fPatterns.put(contentType, patterns); + } + + while (tokenizer.hasMoreTokens()) { + String token = tokenizer.nextToken(); + token = token.trim(); + if (token.length() > 0) { + patterns.add(token); + } } } @@ -54,14 +64,60 @@ public class ClassPatternRegistry { } /** - * Returns an iterator for the additional class patterns to be associated with the provided content type id. + * Returns the additional class patterns to be associated with the provided content type id. * @param contentType the content type id to find patterns for - * @return an iterator for the additional class patterns + * @return an String for the additional class patterns */ public String getClassPattern(String contentType) { - return fPatterns != null ? (String) fPatterns.get(contentType) : null; + if (fPatterns == null) + return null; + final Set patterns = (Set) fPatterns.get(contentType); + if (patterns != null) { + final Iterator it = patterns.iterator(); + final StringBuffer buffer = new StringBuffer(); + while (it.hasNext()) { + if (buffer.length() > 0) + buffer.append(','); + buffer.append(it.next()); + } + return buffer.toString(); + } + return null; + } + + public Iterator getClassPatternSegments(String contentType) { + Iterator result = EMPTY; + if (fPatterns != null) { + Set patterns = (Set) fPatterns.get(contentType); + if (patterns != null) + result = patterns.iterator(); + } + return result; } + private static final Iterator EMPTY = new Iterator() { + + /* (non-Javadoc) + * @see java.util.Iterator#hasNext() + */ + public boolean hasNext() { + return false; + } + + /* (non-Javadoc) + * @see java.util.Iterator#next() + */ + public Object next() { + return null; + } + + /* (non-Javadoc) + * @see java.util.Iterator#remove() + */ + public void remove() {} + + }; + public static synchronized ClassPatternRegistry getInstance() { if (fInstance == null) { fInstance = new ClassPatternRegistry(); diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java index c4e7badf92..b97f332a76 100644 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java +++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 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 @@ -11,7 +11,10 @@ package org.eclipse.jst.jsp.ui.internal.breakpointproviders; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map; +import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -125,6 +128,7 @@ public class JavaStratumBreakpointProvider implements IBreakpointProvider, IExec types = Platform.getContentTypeManager().findContentTypesFor(resource.getName()); } StringBuffer patternBuffer = new StringBuffer("_" + shortName); + final Set contributions = new HashSet(0); for (int i = 0; i < types.length; i++) { final String id = types[i].getId(); Object pattern = ((Map) fData).get(id); @@ -133,11 +137,17 @@ public class JavaStratumBreakpointProvider implements IBreakpointProvider, IExec patternBuffer.append(pattern); } // Append contributions - final String contributions = ClassPatternRegistry.getInstance().getClassPattern(id); - if (contributions != null && contributions.length() > 0) { - if (contributions.charAt(0) != ',') - patternBuffer.append(','); - patternBuffer.append(contributions); + + final Iterator it = ClassPatternRegistry.getInstance().getClassPatternSegments(id); + while (it.hasNext()) { + contributions.add(it.next()); + } + } + if (contributions.size() > 0) { + final Iterator it = contributions.iterator(); + while (it.hasNext()) { + patternBuffer.append(','); + patternBuffer.append(it.next()); } } return patternBuffer.toString(); |