diff options
author | nitind | 2010-12-01 01:41:19 +0000 |
---|---|---|
committer | nitind | 2010-12-01 01:41:19 +0000 |
commit | 9fc918ad3ccb3ff730c985fdc8fa95cd2d216a3b (patch) | |
tree | fb8c495496ed6d06120d40970582e477c0c1cccb | |
parent | cf09a194d955056cc3da352146a1ad153a8b66e9 (diff) | |
download | webtools.sourceediting-9fc918ad3ccb3ff730c985fdc8fa95cd2d216a3b.tar.gz webtools.sourceediting-9fc918ad3ccb3ff730c985fdc8fa95cd2d216a3b.tar.xz webtools.sourceediting-9fc918ad3ccb3ff730c985fdc8fa95cd2d216a3b.zip |
[nobug] avoid cyclic load attempts on SSE model
-rw-r--r-- | bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java index b101269c9f..b295d824c5 100644 --- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java +++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/format/FormattingStrategyJSDT.java @@ -15,11 +15,12 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.core.filebuffers.FileBuffers; +import org.eclipse.core.filebuffers.ITextFileBuffer; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -213,13 +214,11 @@ public class FormattingStrategyJSDT extends ContextBasedFormattingStrategy { private Map getProjectOptions(IDocument baseDocument) { IJavaScriptProject javaProject = null; - IDOMModel xmlModel = null; Map options = null; - try { - xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(baseDocument); - String baseLocation = xmlModel.getBaseLocation(); + ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(baseDocument); + if (buffer != null) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IPath filePath = new Path(baseLocation); + IPath filePath = buffer.getLocation(); IProject project = null; if (filePath.segmentCount() > 0) { project = root.getProject(filePath.segment(0)); @@ -227,14 +226,13 @@ public class FormattingStrategyJSDT extends ContextBasedFormattingStrategy { if (project != null) { javaProject = JavaScriptCore.create(project); } - } finally { - if (xmlModel != null) { - xmlModel.releaseFromRead(); - } } if (javaProject != null) { options = javaProject.getOptions(true); } + if (options == null) { + options = JavaScriptCore.getOptions(); + } return options; } |