[jbosstools-commits] JBoss Tools SVN: r31191 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue May 10 12:55:18 EDT 2011


Author: vrubezhny
Date: 2011-05-10 12:55:18 -0400 (Tue, 10 May 2011)
New Revision: 31191

Modified:
   trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java
Log:
JBIDE-6061
Incorrect Code assist proposals

issue is fixed

Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java	2011-05-10 16:54:01 UTC (rev 31190)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/proposal/CSSClassProposalType.java	2011-05-10 16:55:18 UTC (rev 31191)
@@ -56,7 +56,7 @@
 					CSSRuleList rules = descr.sheet.getCssRules();
 					for (int i = 0; rules != null && i < rules.getLength(); i++) {
 						CSSRule rule = rules.item(i);
-						idList.addAll(getNamesFromCSSRule(rule));
+						idList.addAll(getClassNamesFromCSSRule(rule));
 					}
 				}
 			}
@@ -64,13 +64,13 @@
 	}
 
 	/**
-	 * Returns the style name found in the specified CSS Rule 
+	 * Returns the style class name found in the specified CSS Rule 
 	 * 
 	 * @param cssRule
 	 * @param styleName
 	 * @return
 	 */
-	public static Set<String> getNamesFromCSSRule(CSSRule cssRule) {
+	public static Set<String> getClassNamesFromCSSRule(CSSRule cssRule) {
 		Set<String> styleNames = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
 		
 		// get selector text
@@ -81,22 +81,30 @@
 			for (String styleText : styles) {
 				String[] styleWords = styleText.trim().split(" ");  //$NON-NLS-1$
 				if (styleWords != null) {
-					for (String name : styleWords) {
-						if (name.startsWith(".")) //$NON-NLS-1$
-							continue;
-						
-						if (name.indexOf("[") >= 0) { //$NON-NLS-1$
-							name = name.substring(0, name.indexOf("[")); //$NON-NLS-1$
+					for (String styleWord : styleWords) {
+						String[] anotherStyleWords = styleWord.split(":");
+						for (String name : anotherStyleWords) {
+							String nameWithoutArgs = name;
+							// Add (if exists) class name defined before args
+							if (name.indexOf('[') >= 0) { //$NON-NLS-1$
+								nameWithoutArgs = name.substring(0, name.indexOf("[")); //$NON-NLS-1$
+							}
+							
+							if (nameWithoutArgs != null && nameWithoutArgs.indexOf(".") >= 0) { //$NON-NLS-1$
+								nameWithoutArgs = nameWithoutArgs.substring(nameWithoutArgs.indexOf(".") + 1); //$NON-NLS-1$
+
+								styleNames.add(nameWithoutArgs);
+							}
+
+							if (name.lastIndexOf(']') >= 0) {
+								nameWithoutArgs = name.substring(name.indexOf(']') + 1);
+								if (nameWithoutArgs != null && nameWithoutArgs.indexOf(".") >= 0) { //$NON-NLS-1$
+									nameWithoutArgs = nameWithoutArgs.substring(nameWithoutArgs.indexOf(".") + 1); //$NON-NLS-1$
+
+									styleNames.add(nameWithoutArgs);
+								}
+							}
 						}
-						if (name.indexOf(".") >= 0) { //$NON-NLS-1$
-							name = name.substring(0, name.indexOf(".")); //$NON-NLS-1$
-						}
-						if (name.indexOf(":") >= 0) { //$NON-NLS-1$
-							name = name.substring(0, name.indexOf(":")); //$NON-NLS-1$
-						}
-						
-						// Use the first word as a style name
-						styleNames.add(name);
 					}
 				}
 			}



More information about the jbosstools-commits mailing list