[jbosstools-commits] JBoss Tools SVN: r42386 - in trunk/jst: tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent and 1 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Jul 4 09:32:41 EDT 2012
Author: vrubezhny
Date: 2012-07-04 09:32:39 -0400 (Wed, 04 Jul 2012)
New Revision: 42386
Added:
trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/indexResolveIDAttributes.html
trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/styleIDAttributes.css
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
trunk/jst/tests/org.jboss.tools.jst.text.ext.test/src/org/jboss/tools/jst/text/ext/test/CSSStylesheetOpenOnTest.java
Log:
JBIDE-10127
Resolve selector in open-on of style class in VPE
Issue is fixed: ID Attribute Values are to be processed in case-insensitive manner.
JUnit Test case is added.
Modified: trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2012-07-04 09:19:35 UTC (rev 42385)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2012-07-04 13:32:39 UTC (rev 42386)
@@ -388,7 +388,8 @@
}
}
if (currentAxis.idAttributeValues.size() > 0) {
- allValuesAreOK &= currentAxis.idAttributeValues.contains(Utils.trimQuotes(getNodeAttributeValue(node, "id"))); //$NON-NLS-1$
+ String nodeIDAttributeValue = Utils.trimQuotes(getNodeAttributeValue(node, "id")); //$NON-NLS-1$
+ allValuesAreOK &= currentAxis.idAttributeValues.contains(nodeIDAttributeValue == null ? null : nodeIDAttributeValue.toLowerCase());
}
attrFound = allValuesAreOK;
Added: trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/indexResolveIDAttributes.html
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/indexResolveIDAttributes.html (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/indexResolveIDAttributes.html 2012-07-04 13:32:39 UTC (rev 42386)
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <link href="styleIDAttributes.css" rel="stylesheet" type="text/css"></link>
+ </head>
+
+ <body>
+
+ <div class="bc">
+ 1. This matches (.bc).
+ <i class="cd"> 2. This matches (.bc .cd).</i>
+ </div>
+
+ <div id="Header">
+ <p class="bc">
+ 3. This matches (#Header .bc).
+ <b class="cd"> 4. This matches (#Header .bc .cd).</b>
+ </p>
+ </div>
+
+ <div id="Footer">
+ <p class="bc">
+ 5. This matches (#Footer .bc).
+ <b class="cd"> 6. This matches (#Footer .bc .cd).</b>
+ </p>
+ </div>
+
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/indexResolveIDAttributes.html
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/styleIDAttributes.css
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/styleIDAttributes.css (rev 0)
+++ trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/styleIDAttributes.css 2012-07-04 13:32:39 UTC (rev 42386)
@@ -0,0 +1,11 @@
+.bc {background-color: aqua;}
+
+.bc .cd {background-color: green;}
+
+#Header .bc {background-color: yellow;}
+
+#Header .bc .cd {background-color: black;}
+
+#Footer .bc {background-color: blue;}
+
+#Footer .bc .cd {background-color: brown;}
Property changes on: trunk/jst/tests/org.jboss.tools.jst.text.ext.test/projects/OpenOnTest/WebContent/styleIDAttributes.css
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/jst/tests/org.jboss.tools.jst.text.ext.test/src/org/jboss/tools/jst/text/ext/test/CSSStylesheetOpenOnTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.text.ext.test/src/org/jboss/tools/jst/text/ext/test/CSSStylesheetOpenOnTest.java 2012-07-04 09:19:35 UTC (rev 42385)
+++ trunk/jst/tests/org.jboss.tools.jst.text.ext.test/src/org/jboss/tools/jst/text/ext/test/CSSStylesheetOpenOnTest.java 2012-07-04 13:32:39 UTC (rev 42386)
@@ -40,6 +40,7 @@
private static final String SECOND_IN_A_ROW_PAGE_NAME = PROJECT_NAME+"/WebContent/indexWithSecondClassInRule.html";
private static final String RESOLVE_SELECTOR_PAGE_NAME = PROJECT_NAME+"/WebContent/indexResolveSelector.html";
private static final String PARENT_TO_CHILD_RESTRICTIONS_RESOLVE_SELECTOR_PAGE_NAME = PROJECT_NAME+"/WebContent/indexParentToChildRestrictions.html";
+ private static final String RESOLVE_ID_ATTRIBUTES_PAGE_NAME = PROJECT_NAME+"/WebContent/indexResolveIDAttributes.html";
public IProject project = null;
@@ -449,6 +450,86 @@
}
}
+ public void testCSSClassResolveIDAttributesOpenOn() throws PartInitException, BadLocationException {
+ HashSet<IEditorPart> openedEditors = new HashSet<IEditorPart>();
+
+ // CSS class names to be tested are placed one by one,
+ // so, for each next test we'll continue to search in document
+ // (We'll not search from beginning each time)
+ //
+ // Position to continue the search from
+ int startFrom = 0;
+
+ // 'class="' - is the string to search
+ final String TEXT_TO_SEARCH = "class=\"";
+
+ // Valid CSS Stylesheet to be opened
+ final String VALID_CSS_EDITOR_NAME = "styleIDAttributes.css";
+
+ // Valid values for Text Selection after the open on is performed
+ final String[] VALID_TEXT_SELECTIONS = new String[] {
+ ".bc {background-color: aqua;}",
+ ".bc .cd {background-color: green;}",
+ "#Header .bc {background-color: yellow;}",
+ "#Header .bc .cd {background-color: black;}",
+ "#Footer .bc {background-color: blue;}",
+ "#Footer .bc .cd {background-color: brown;}"
+ };
+
+ for (int i = 0; i < VALID_TEXT_SELECTIONS.length; i++) {
+ IEditorPart editor = WorkbenchUtils.openEditor(RESOLVE_ID_ATTRIBUTES_PAGE_NAME);
+ if (editor != null) openedEditors.add(editor);
+ try {
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+
+ IDocument document = viewer.getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(startFrom,
+ TEXT_TO_SEARCH, true, true, false, false);
+ assertNotNull("Attribute: " + TEXT_TO_SEARCH + " not found whyle search starting from " + startFrom, reg);
+
+ startFrom = reg.getOffset() + reg.getLength();
+
+ IHyperlink[] links = HyperlinkDetector.getInstance().detectHyperlinks(viewer, new Region(startFrom, 0), true); // new Region(reg.getOffset() + reg.getLength(), 0)
+
+ assertTrue("Hyperlinks not found for position " + startFrom,(links != null && links.length > 0));
+
+ boolean found = false;
+ for(IHyperlink link : links){
+ assertNotNull(link.toString());
+
+ link.open();
+
+ IEditorPart resultEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if (resultEditor != null) openedEditors.add(resultEditor);
+ if(VALID_CSS_EDITOR_NAME.equals(resultEditor.getTitle())){
+ StructuredTextEditor stEditor = null;
+ if (resultEditor instanceof StructuredTextEditor) {
+ stEditor = (StructuredTextEditor)resultEditor;
+ } else if (resultEditor instanceof JSPMultiPageEditor) {
+ stEditor = ((JSPMultiPageEditor)resultEditor).getSourceEditor();
+ }
+ assertNotNull("Unexpected Editor is openned: " + resultEditor.getTitle() + " [" + resultEditor.getClass().getName() + "]", stEditor);
+ ISelection selection = stEditor.getSelectionProvider().getSelection();
+ assertFalse("Required CSS Rule is not selected", selection.isEmpty());
+ if (selection instanceof TextSelection) {
+ TextSelection textSelection = (TextSelection)selection;
+ String selectionText = stEditor.getTextViewer().getDocument().get(textSelection.getOffset(), textSelection.getLength());
+ assertTrue("Required CSS Rule is not selected",
+ (VALID_TEXT_SELECTIONS[i].equalsIgnoreCase(selectionText)));
+ found = true;
+ break;
+ }
+ }
+ }
+ assertTrue("OpenOn have not opened a valid selection in " + VALID_CSS_EDITOR_NAME + " editor",found);
+ } finally {
+ closeEditors(openedEditors);
+ }
+ }
+ }
+
protected void closeEditors (HashSet<IEditorPart> editors) {
if (editors == null || editors.isEmpty())
return;
More information about the jbosstools-commits
mailing list