use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project liferay-ide by liferay.
the class JSPFileWTP method createSearchResult.
@Override
protected SearchResult createSearchResult(String searchContext, int startOffset, int endOffset, int startLine, int endLine, boolean fullMatch) {
IDOMModel jspModel = null;
try {
int jspStartOffset = _translation.getJspOffset(startOffset);
int jspEndOffset = _translation.getJspOffset(endOffset);
jspModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(_translation.getJspFile());
IDOMDocument domDocument = jspModel.getDocument();
IStructuredDocument structuredDocument = domDocument.getStructuredDocument();
int jspStartLine = structuredDocument.getLineOfOffset(jspStartOffset) + 1;
int jspEndLine = structuredDocument.getLineOfOffset(jspEndOffset) + 1;
return super.createSearchResult(searchContext, jspStartOffset, jspEndOffset, jspStartLine, jspEndLine, fullMatch);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jspModel != null) {
jspModel.releaseFromRead();
}
}
return super.createSearchResult(searchContext, startOffset, endOffset, startLine, endLine, fullMatch);
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project liferay-ide by liferay.
the class AlloyJSPDocumentLoader method newEncodedDocument.
@Override
protected IEncodedDocument newEncodedDocument() {
IEncodedDocument retval = super.newEncodedDocument();
if (retval instanceof IStructuredDocument) {
IStructuredDocument doc = (IStructuredDocument) retval;
RegionParser parser = doc.getParser();
if (parser instanceof BlockTagParser) {
BlockTagParser blockParser = (BlockTagParser) parser;
BlockMarker bm = new BlockMarker("aui:script", null, DOMRegionContext.BLOCK_TEXT, false);
blockParser.addBlockMarker(bm);
}
}
return retval;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class DocumentRegionProcessor method uninstall.
/**
* @see org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor#uninstall()
*/
public void uninstall() {
if (isInstalled()) {
IReconcilingStrategy validatorStrategy = getValidatorStrategy();
if (validatorStrategy != null) {
if (validatorStrategy instanceof IReleasable)
((IReleasable) validatorStrategy).release();
}
if (fSpellcheckStrategy != null) {
fSpellcheckStrategy.setDocument(null);
fSpellcheckStrategy = null;
}
fReconcileListeners = new ISourceReconcilingListener[0];
if (getDocument() instanceof IStructuredDocument) {
RegionParser parser = ((IStructuredDocument) getDocument()).getParser();
if (parser instanceof StructuredDocumentRegionParser) {
((StructuredDocumentRegionParser) parser).removeStructuredDocumentRegionHandler(fResetHandler);
}
}
}
super.uninstall();
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class CSSModelParser method getStructuredDocumentRegionList.
/**
*/
private IStructuredDocumentRegionList getStructuredDocumentRegionList(int start, int end) {
IStructuredDocumentRegionList nodeList = null;
if (0 <= start && start <= end) {
ICSSModel model = fDocument.getModel();
if (model instanceof CSSModelImpl) {
IStructuredDocument structuredDocument = ((CSSModelImpl) model).getStructuredDocument();
if (structuredDocument != null) {
IStructuredDocumentRegion startNode = structuredDocument.getRegionAtCharacterOffset(start);
IStructuredDocumentRegion endNode = structuredDocument.getRegionAtCharacterOffset(end - 1);
if (startNode != null && endNode != null) {
nodeList = new CoreNodeList(startNode, endNode);
}
}
}
}
return nodeList;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument in project webtools.sourceediting by eclipse.
the class AttrFormatter method formatPre.
/**
*/
protected void formatPre(ICSSNode node, StringBuffer source) {
ICSSAttr attr = (ICSSAttr) node;
CSSCleanupStrategy stgy = getCleanupStrategy(node);
int end = ((IndexedRegion) node).getEndOffset();
if (end > 0) {
// format source
int start = ((IndexedRegion) node).getStartOffset();
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
if (attr.getName().equals(ICSSStyleRule.SELECTOR) || attr.getName().equals(ICSSPageRule.SELECTOR)) {
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBetween(node, regions[i - 1], regions[i], source);
source.append(decoratedRegion(regions[i], 0, stgy));
}
} else if (attr.getName().equals(ICSSImportRule.HREF)) {
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedPropValueRegion(regions[i], stgy));
}
} else if (attr.getName().equals(ICSSCharsetRule.ENCODING)) {
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedIdentRegion(regions[i], stgy));
}
} else if (attr.getName().equals(ICSSStyleDeclItem.IMPORTANT)) {
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedPropValueRegion(regions[i], stgy));
}
} else if (attr.getName() == null || attr.getName().length() == 0) {
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedIdentRegion(regions[i], stgy));
}
} else {
// counter attributes
for (int i = 0; i < regions.length; i++) {
if (i != 0)
appendSpaceBefore(node, regions[i], source);
source.append(decoratedPropValueRegion(regions[i], stgy));
}
}
} else {
// generate source
Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences();
String value = attr.getValue();
if (value == null)
// $NON-NLS-1$
value = "";
if (attr.getName().equals(ICSSStyleRule.SELECTOR) || attr.getName().equals(ICSSPageRule.SELECTOR)) {
} else if (attr.getName().equals(ICSSImportRule.HREF)) {
String uri = org.eclipse.wst.css.core.internal.util.CSSLinkConverter.stripFunc(value);
// $NON-NLS-2$//$NON-NLS-1$
String func = preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER ? "URL(" : "url(";
if (preferences.getBoolean(CSSCorePreferenceNames.FORMAT_QUOTE_IN_URI)) {
String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
quote = CSSUtil.detectQuote(uri, quote);
// $NON-NLS-1$
value = func + quote + uri + quote + ")";
} else {
// $NON-NLS-1$
value = func + uri + ")";
}
} else if (attr.getName().equals(ICSSCharsetRule.ENCODING)) {
String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
if (// $NON-NLS-2$//$NON-NLS-1$
!value.startsWith("\"") && !value.startsWith("\'"))
value = quote + value;
if (// $NON-NLS-2$//$NON-NLS-1$
!value.endsWith("\"") && !value.endsWith("\'"))
value = value + quote;
} else if (attr.getName().equals(ICSSStyleDeclItem.IMPORTANT)) {
if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
value = value.toUpperCase();
else
value = value.toLowerCase();
} else if (attr.getName() == null || attr.getName().length() == 0) {
if (CSSCorePlugin.getDefault().getPluginPreferences().getInt(CSSCorePreferenceNames.CASE_IDENTIFIER) == CSSCorePreferenceNames.UPPER)
value = value.toUpperCase();
else
value = value.toLowerCase();
} else {
if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_VALUE) == CSSCorePreferenceNames.UPPER)
value = value.toUpperCase();
else
value = value.toLowerCase();
}
source.append(value);
}
}
Aggregations