[166909] CSS Formatter invalidates certain constructs
[110539] formatting breaks rules with multiple classes for elements
[93037] properties view adds extra ; when add new property
[111569] Cleanup Document for CSS file inserts extra semicolon
[146198] Attribute specifiers are being broken by the CSS formatter
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java
index 2ee8423..b9f71e3 100644
--- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/AbstractCSSSourceFormatter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 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
@@ -320,7 +320,7 @@
String text = region.getText();
String type = region.getType();
- if (type == CSSRegionContexts.CSS_STRING || type == CSSRegionContexts.CSS_URI)
+ if (type == CSSRegionContexts.CSS_STRING || type == CSSRegionContexts.CSS_URI || type == CSSRegionContexts.CSS_DECLARATION_VALUE_URI)
return decoratedRegion(region, 2, stgy);
if (isCleanup()) {
if (stgy.getPropValueCase() != CSSCleanupStrategy.ASIS) {
@@ -346,7 +346,8 @@
Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
String text = region.getText();
- if (region.getType() == CSSRegionContexts.CSS_URI) {
+ String regionType = region.getType();
+ if (regionType == CSSRegionContexts.CSS_URI || regionType == CSSRegionContexts.CSS_DECLARATION_VALUE_URI) {
String uri = CSSLinkConverter.stripFunc(text);
boolean prefIsUpper = preferences.getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER;
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java
index c1aed20..04a6730 100644
--- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/DefaultCSSSourceFormatter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 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
@@ -43,12 +43,12 @@
String nextType = next.getType();
if (CSSRegionUtil.isSelectorBegginingType(prevType) && CSSRegionUtil.isSelectorBegginingType(nextType)) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=73990
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=110539
// Formatting CSS file splits element.class into element . class
- if ((prevType == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME && (nextType == CSSRegionContexts.CSS_SELECTOR_CLASS || nextType == CSSRegionContexts.CSS_SELECTOR_ID)) || ((prevType == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || prevType == CSSRegionContexts.CSS_SELECTOR_CLASS) && nextType == CSSRegionContexts.CSS_SELECTOR_PSEUDO)) {
+ if (((prevType == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || prevType == CSSRegionContexts.CSS_SELECTOR_CLASS || prevType == CSSRegionContexts.CSS_SELECTOR_ID) && (nextType == CSSRegionContexts.CSS_SELECTOR_CLASS || nextType == CSSRegionContexts.CSS_SELECTOR_ID)) || ((prevType == CSSRegionContexts.CSS_SELECTOR_ELEMENT_NAME || prevType == CSSRegionContexts.CSS_SELECTOR_CLASS) && nextType == CSSRegionContexts.CSS_SELECTOR_PSEUDO) || (nextType == CSSRegionContexts.CSS_SELECTOR_ATTRIBUTE_START)) {
// Individually, SELECTOR_ELEMENT_NAME, SELECTOR_CLASS, and SELECTOR_ID can all be beginning types.
- // But, we should not insert a space in between when SELECTOR_ELEMENT_NAME is followed by SELECTOR_CLASS, or when
- // SELECTOR_ELEMENT_NAME is followed by SELECTOR_ID.
- // For example: H1.pastoral and H1#z98y
+ // But, we should not insert a space in between when they are followed by SELECTOR_CLASS or SELECTOR_ID.
+ // For example: H1.pastoral and H1#z98y and .pastoral.other and #myid.myclass
//
// Also, space is now not inserted in between when SELECTOR_ELEMENT_NAME is followed by SELECTOR_PSEUDO, or when
// SELECTOR_CLASS is followed by SELECTOR_PSEUDO.
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java
index ad06635..9179ee2 100644
--- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/formatter/StyleDeclarationFormatter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 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
@@ -69,13 +69,24 @@
for (int i = 0; i < regions.length; i++) {
appendSpaceBefore(node, regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy)); // must
- // be
- // comments
+ // be comments
}
} else if (prev != null && child != null) { // generate source :
- // between two
- // declarations
- source.append(";");//$NON-NLS-1$
+ // between two declarations
+ // BUG93037-properties view adds extra ; when add new property
+ boolean semicolonFound = false;
+ IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
+ int prevStart = (prev != null) ? ((IndexedRegion) prev).getStartOffset() : 0;
+ int prevEnd = (prev != null) ? ((IndexedRegion) prev).getEndOffset() : 0;
+ CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(prevStart, prevEnd - prevStart), stgy);
+ int i = regions.length-1;
+ while (i >= 0 && !semicolonFound) {
+ if (regions[i].getType() == CSSRegionContexts.CSS_DECLARATION_DELIMITER)
+ semicolonFound = true;
+ --i;
+ }
+ if (!semicolonFound)
+ source.append(";");//$NON-NLS-1$
} else if (prev == null) { // generate source : before the first
// declaration
org.eclipse.wst.css.core.internal.util.RegionIterator it = null;