Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbchilds2007-05-15 23:57:10 +0000
committerbchilds2007-05-15 23:57:10 +0000
commit33a109c355dbc932d6204eca91471cf67432de0a (patch)
tree1aa5d426360af95730e60f4afc205a7b30de7664 /bundles/org.eclipse.wst.jsdt.web.ui/src/org
parent8f09714a517c5270e58adc6b1c0bad8078ece904 (diff)
downloadwebtools.sourceediting-33a109c355dbc932d6204eca91471cf67432de0a.tar.gz
webtools.sourceediting-33a109c355dbc932d6204eca91471cf67432de0a.tar.xz
webtools.sourceediting-33a109c355dbc932d6204eca91471cf67432de0a.zip
Updates for breakpoints (removed JSP usage).
Fixes where model wasn't being released.
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.web.ui/src/org')
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/AbstractBreakpointProvider.java311
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaBreakpointProvider.java111
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaScriptBreakpointProvider.java88
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java204
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java65
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java5
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java5
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JSPFindOccurrencesProcessor.java5
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java3
-rw-r--r--bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java32
10 files changed, 29 insertions, 800 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/AbstractBreakpointProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/AbstractBreakpointProvider.java
deleted file mode 100644
index 35c274d542..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/AbstractBreakpointProvider.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMNodeWrapper;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Abstract breakpoint provider class which implements breakpoint provider
- * interface.
- *
- * This is a temporary class for JavaBreakpointProvider and
- * JavaScriptBreakpointProvider, and should be refactored to separate Java and
- * JavaScript parts.
- */
-public abstract class AbstractBreakpointProvider implements IBreakpointProvider {
-
- protected static final int END_OF_LINE = -1;
- protected static final int JAVA = 1;
- protected static final int JAVASCRIPT = 2;
- private static final String[] JAVASCRIPT_LANGUAGE_KEYS = new String[] {
- "javascript", "javascript1.0", "javascript1.1_3", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "javascript1.2", "javascript1.3", "javascript1.4", "javascript1.5", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- "javascript1.6", "jscript", "sashscript" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String JSP_DIRECTIVE_PAGE = "jsp:directive.page"; //$NON-NLS-1$
-
- protected static final int NO_VALID_CONTENT = -2;
- protected static final int UNSUPPORTED = 0;
-
- protected static boolean contains(String[] haystack, String needle) {
- for (int i = 0; i < haystack.length; i++) {
- if (haystack[i].equals(needle)) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * Return the page language
- */
- protected static int getPageLanguage(Document doc) {
- if (doc == null) {
- return UNSUPPORTED;
- }
-
- NodeList pageDirectives = doc.getElementsByTagName(JSP_DIRECTIVE_PAGE);
- // Search for first language directive
- for (int i = 0; i < pageDirectives.getLength(); i++) {
- Node child = pageDirectives.item(i);
- Node languageAttr = child.getAttributes().getNamedItem("language"); //$NON-NLS-1$
- if (languageAttr != null) {
- String pageLanguage = languageAttr.getNodeValue();
- if (pageLanguage == null || pageLanguage.length() == 0) {
- return UNSUPPORTED;
- }
- pageLanguage = pageLanguage.toLowerCase();
- if (contains(JAVASCRIPT_LANGUAGE_KEYS, pageLanguage)) {
- return JAVASCRIPT;
- } else if (pageLanguage.equals("java")) {
- return JAVA;
- } else {
- return UNSUPPORTED;
- }
- }
- }
- return JAVA; // Java is default if no language directive
- }
-
- /*
- * Search the RegionContainer's regions looking for JSP content. If valid
- * content is found, return the position >= 0 If no valid content is found,
- * return NO_VALID_CONTENT. If a region starts after the line's endOffset,
- * return END_OF_LINE.
- */
- private static int getValidRegionPosition(IStructuredModel model,
- ITextRegionCollection regionContainer, int startOffset,
- int endOffset) {
-
- ITextRegionList regions = regionContainer.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (region instanceof ITextRegionCollection) {
- int validPosition = getValidRegionPosition(model,
- (ITextRegionCollection) region, startOffset, endOffset);
- if (validPosition == END_OF_LINE || validPosition >= 0) {
- return validPosition;
- }
- } else {
- // region must be at least partially on selected line
- if (regionContainer.getEndOffset(region) > startOffset) {
-
- int regionStartOffset = regionContainer
- .getStartOffset(region);
- // if region starts after line's endOffset, we're done
- // searching
- if (regionStartOffset > endOffset) {
- return END_OF_LINE;
- }
-
- // If region is JSP content, make sure the language is
- // Java not Javascript by
- // checking the content assist adapter's type.
- if (region.getType().equals(
- "DOMJSPRegionContexts.JSP_CONTENT")) {
- // DWM: this logic is not incorrect ... given changes
- // to adapters, etc.
- // but probably don't need anything here, since both
- // Java and JavaScript
- // are supported in V5.
-
- // nsd_TODO: verify this!!!
-
- // INodeNotifier notifier =
- // (INodeNotifier)model.getNode(region.getStartOffset());
- // IAdapterFactory factory =
- // model.getFactoryRegistry().getFactoryFor(ContentAssistAdapter.class);
- // if(factory instanceof
- // HTMLContentAssistAdapterFactory) {
- // INodeAdapter adapter =
- // ((HTMLContentAssistAdapterFactory)factory).createAdapter(notifier,
- // region);
- // if(adapter != null && adapter instanceof
- // JSPJavaContentAssistAdapter)
-
- if (regionStartOffset > startOffset) {
- return regionStartOffset;
- } else {
- return startOffset;
- // }
- }
- }
- // a custom tag, jsp:useBean, getproperty or setproperty
- // statement is also a valid breakpoint location
- else if (region.getType().equals(
- DOMRegionContext.XML_TAG_NAME)
- && (isCustomTagRegion(model
- .getIndexedRegion(regionStartOffset))
- || regionContainer.getText(region).equals(
- "JSP12Namespace.ElementName.USEBEAN")
- || regionContainer
- .getText(region)
- .equals(
- "JSP12Namespace.ElementName.GETPROPERTY") || regionContainer
- .getText(region)
- .equals(
- "JSP12Namespace.ElementName.SETPROPERTY"))) {
-
- if (regionStartOffset > startOffset) {
- return regionStartOffset;
- } else {
- return startOffset;
- }
- } else {
- // Defect #241090, the Text Nodes inside of JSP
- // scriptlets, expressions, and declarations are valid
- // breakpoint-able locations
- boolean isCodeNode = false;
- IndexedRegion node = model
- .getIndexedRegion(regionStartOffset);
- if (node != null && node instanceof Node) {
- Node domNode = (Node) node;
- Node root = domNode.getOwnerDocument()
- .getDocumentElement();
- if (root != null
- && root.getNodeName().equals(
- "JSP12Namespace.ElementName.ROOT")
- && domNode.getNodeType() == Node.TEXT_NODE
- && domNode.getParentNode() != null) {
- String parentName = domNode.getParentNode()
- .getNodeName();
- isCodeNode = parentName
- .equals("JSP12Namespace.ElementName.SCRIPTLET")
- || parentName
- .equals("JSP12Namespace.ElementName.EXPRESSION")
- || parentName
- .equals("JSP12Namespace.ElementName.DECLARATION");
- }
- }
- if (isCodeNode) {
- if (regionStartOffset > startOffset) {
- return regionStartOffset;
- } else {
- return startOffset;
- }
- }
- }
- }
- }
- }
- return NO_VALID_CONTENT;
- }
-
- private static boolean isCustomTagRegion(IndexedRegion node) {
-
- if (node instanceof Element) {
- Element xmlElement = (Element) node;
- ModelQuery mq = ModelQueryUtil.getModelQuery(xmlElement
- .getOwnerDocument());
- CMElementDeclaration decl = mq.getCMElementDeclaration(xmlElement);
- if (decl instanceof CMNodeWrapper) {
- CMNode cmNode = ((CMNodeWrapper) decl).getOriginNode();
- //return cmNode instanceof TLDElementDeclaration;
- }
- }
- return false;
- }
-
- private ISourceEditingTextTools fSourceEditingTextTools;
-
- protected IResource getEditorInputResource(IEditorInput input) {
- IResource resource = (IResource) input.getAdapter(IFile.class);
- if (resource == null) {
- resource = (IResource) input.getAdapter(IResource.class);
- }
- return resource;
- }
-
- public ISourceEditingTextTools getSourceEditingTextTools() {
- return fSourceEditingTextTools;
- }
-
- protected int getValidPosition(IDocument idoc, int lineNumber) {
- if (!(getSourceEditingTextTools() instanceof IDOMSourceEditingTextTools)) {
- return NO_VALID_CONTENT;
- }
- if (idoc == null) {
- return NO_VALID_CONTENT;
- }
-
- int startOffset, endOffset;
- try {
- startOffset = idoc.getLineOffset(lineNumber - 1);
- endOffset = idoc.getLineOffset(lineNumber) - 1;
-
- if (idoc == null) {
- return NO_VALID_CONTENT;
- }
- String lineText = idoc.get(startOffset, endOffset - startOffset)
- .trim();
-
- // blank lines or lines with only an open or close brace or
- // scriptlet tag cannot have a breakpoint
- if (lineText.equals("") || lineText.equals("{") || //$NON-NLS-2$//$NON-NLS-1$
- lineText.equals("}") || lineText.equals("<%")) {
- return NO_VALID_CONTENT;
- }
- } catch (BadLocationException e) {
- return NO_VALID_CONTENT;
- }
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) idoc)
- .getRegionAtCharacterOffset(startOffset);
- // go through the node's regions looking for JSP content
- // until reaching the end of the line
- while (flatNode != null) {
- int validPosition = getValidRegionPosition(
- ((IDOMDocument) ((IDOMSourceEditingTextTools) getSourceEditingTextTools())
- .getDOMDocument()).getModel(), flatNode,
- startOffset, endOffset);
-
- if (validPosition == END_OF_LINE) {
- return NO_VALID_CONTENT;
- }
-
- if (validPosition >= 0) {
- return validPosition;
- }
-
- flatNode = flatNode.getNext();
- }
- return NO_VALID_CONTENT;
- }
-
- public void setSourceEditingTextTools(
- ISourceEditingTextTools sourceEditingTextTools) {
- fSourceEditingTextTools = sourceEditingTextTools;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaBreakpointProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaBreakpointProvider.java
deleted file mode 100644
index a90d0c6936..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaBreakpointProvider.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.jsdt.debug.core.JDIDebugModel;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * A BreakpointProvider supporting server-side Java as a JSP language
- *
- * @deprecated
- */
-@Deprecated
-public class JavaBreakpointProvider extends AbstractBreakpointProvider {
-
- /*
- * @param res @return String
- */
- private static final String getTypeName(IResource res) {
- IPath path = res.getFullPath();
- // Assume under Web Content folder if more than 2 segments
- if (path.segmentCount() > 2) {
- path = path.removeFirstSegments(2);
- } else {
- path = path.removeFirstSegments(1);
- }
- String typeName = path.toString().replace(IPath.SEPARATOR, '.');
- if (res.getFileExtension() != null) {
- typeName = typeName.substring(0, typeName.lastIndexOf('.'));
- }
- return typeName;
- }
-
- public IStatus addBreakpoint(IDocument document, IEditorInput input,
- int lineNumber, int offset) throws CoreException {
- int pos = getValidPosition(document, lineNumber);
- if (pos != NO_VALID_CONTENT) {
- IResource res = getEditorInputResource(input);
- if (res != null) {
- String typeName = getTypeName(res);
- try {
- JDIDebugModel.createLineBreakpoint(res, typeName,
- lineNumber, pos, pos, 0, true, null);
- } catch (CoreException e) {
- return e.getStatus();
- }
- }
- }
- return new Status(IStatus.OK, JSPUIPlugin.ID, IStatus.OK,
- JSPUIMessages.OK, null);
- }
-
- public boolean canAddBreakpoint(IDocument document, IEditorInput input,
- Node node, int lineNumber, int offset) {
- IResource res = input instanceof IFileEditorInput ? ((IFileEditorInput) input)
- .getFile()
- : null;
- Document doc = null;
- if (getSourceEditingTextTools() instanceof IDOMSourceEditingTextTools) {
- doc = ((IDOMSourceEditingTextTools) getSourceEditingTextTools())
- .getDOMDocument();
- }
-
- return res != null && !isBreakpointExist(res, lineNumber)
- && isValidPosition(document, lineNumber)
- && (getPageLanguage(doc) == JAVA);
- }
-
- public IResource getResource(IEditorInput input) {
- return getEditorInputResource(input);
- }
-
- /*
- * @param res @param lineNumber @return boolean
- */
- private boolean isBreakpointExist(IResource res, int lineNumber) {
- try {
- return JDIDebugModel.lineBreakpointExists(getTypeName(res),
- lineNumber) != null;
- } catch (CoreException e) {
- return false;
- }
- }
-
- /*
- * @param doc @param idoc @param lineNumber @return boolean
- */
- private boolean isValidPosition(IDocument idoc, int lineNumber) {
- return getValidPosition(idoc, lineNumber) != NO_VALID_CONTENT;
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaScriptBreakpointProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaScriptBreakpointProvider.java
deleted file mode 100644
index 17d8577788..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaScriptBreakpointProvider.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointManager;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.w3c.dom.Document;
-
-/**
- * A IBreakpointProvider supporting server-side JavaScript as a JSP language
- *
- */
-public class JavaScriptBreakpointProvider extends AbstractBreakpointProvider {
- public boolean canAddBreakpoint(IDocument document, IEditorInput input,
- int lineNumber, int offset) {
- IResource res = getEditorInputResource(input);
- Document doc = null;
- return res != null && !isBreakpointExist(res, lineNumber)
- && isValidPosition(document, lineNumber)
- && (getPageLanguage(doc) != JAVA);
- }
-
- public IStatus addBreakpoint(IDocument document, IEditorInput input,
- int lineNumber, int offset) {
- int pos = getValidPosition(document, lineNumber);
- if (pos != NO_VALID_CONTENT
- && canAddBreakpoint(document, input, lineNumber, offset)) {
- IResource res = getEditorInputResource(input);
- if (res != null) {
- new JavascriptLineBreakpoint(res, lineNumber, pos, pos);
- }
- }
- return new Status(IStatus.OK, JSPUIPlugin.ID, IStatus.OK,
- JSPUIMessages.OK, null);
- }
-
- /*
- * @param res @param lineNumber @return boolean
- */
- private boolean isBreakpointExist(IResource res, int lineNumber) {
- IBreakpointManager manager = DebugPlugin.getDefault()
- .getBreakpointManager();
- IBreakpoint[] breakpoints = manager.getBreakpoints();
- for (int i = 0; i < breakpoints.length; i++) {
- if (!(breakpoints[i] instanceof JavascriptLineBreakpoint)) {
- continue;
- }
- JavascriptLineBreakpoint breakpoint = (JavascriptLineBreakpoint) breakpoints[i];
- try {
- if (breakpoint.getResource().equals(res)
- && breakpoint.getLineNumber() == lineNumber) {
- return true;
- }
- } catch (CoreException e) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * @param doc @param idoc @param lineNumber @return boolean
- */
- private boolean isValidPosition(IDocument idoc, int lineNumber) {
- return getValidPosition(idoc, lineNumber) != NO_VALID_CONTENT;
- }
-
- public IResource getResource(IEditorInput input) {
- return getEditorInputResource(input);
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java
deleted file mode 100644
index a36c994e8e..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavaStratumBreakpointProvider.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.wst.jsdt.debug.core.JDIDebugModel;
-import org.eclipse.wst.jsdt.web.core.text.IJSPPartitions;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIMessages;
-import org.eclipse.wst.jsdt.web.ui.internal.JSPUIPlugin;
-import org.eclipse.wst.sse.ui.internal.StructuredResourceMarkerAnnotationModel;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider;
-
-/**
- * A IBreakpointProvider supporting JSP breakpoints for a Non-Java Language
- * Source JSP page
- */
-public class JavaStratumBreakpointProvider implements IBreakpointProvider,
- IExecutableExtension {
- private String fClassPattern = null;
-
- public IStatus addBreakpoint(IDocument document, IEditorInput input,
- int editorLineNumber, int offset) throws CoreException {
- // check if there is a valid position to set breakpoint
- int pos = getValidPosition(document, editorLineNumber);
- IStatus status = null;
- if (pos >= 0) {
- IResource res = getResourceFromInput(input);
- if (res != null) {
- String path = null; // res.getName();//
- // res.getFullPath().removeFirstSegments(2).toString();
- IBreakpoint point = JDIDebugModel
- .createStratumBreakpoint(
- res,
- "JSP", res.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, null); //$NON-NLS-1$
- if (point == null) {
- status = new Status(IStatus.ERROR, JSPUIPlugin.ID,
- IStatus.ERROR, "unsupported input type", null); //$NON-NLS-1$
- }
- } else if (input instanceof IStorageEditorInput) {
- // For non-resources, use the workspace root and a coordinated
- // attribute that is used to
- // prevent unwanted (breakpoint) markers from being loaded
- // into the editors.
- res = ResourcesPlugin.getWorkspace().getRoot();
- String id = input.getName();
- if (input instanceof IStorageEditorInput
- && ((IStorageEditorInput) input).getStorage() != null
- && ((IStorageEditorInput) input).getStorage()
- .getFullPath() != null) {
- id = ((IStorageEditorInput) input).getStorage()
- .getFullPath().toString();
- }
- Map attributes = new HashMap();
- attributes
- .put(
- StructuredResourceMarkerAnnotationModel.SECONDARY_ID_KEY,
- id);
- String path = null;
- IBreakpoint point = JDIDebugModel
- .createStratumBreakpoint(
- res,
- "JSP", input.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, attributes); //$NON-NLS-1$
- if (point == null) {
- status = new Status(IStatus.ERROR, JSPUIPlugin.ID,
- IStatus.ERROR, "unsupported input type", null); //$NON-NLS-1$
- }
- }
- }
- if (status == null) {
- status = new Status(IStatus.OK, JSPUIPlugin.ID, IStatus.OK,
- JSPUIMessages.OK, null);
- }
- return status;
- }
-
- private String getClassPattern(IResource resource) {
- if (resource != null) {
- String shortName = resource.getName();
- String extension = resource.getFileExtension();
- if (extension != null
- && extension.length() > shortName.length() - 1) {
- shortName = shortName.substring(0, shortName.length()
- - extension.length() - 1);
- }
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154475
- */
- return fClassPattern + ",_" + shortName;
- }
- return fClassPattern;
- }
-
- public IResource getResource(IEditorInput input) {
- return getResourceFromInput(input);
- }
-
- private IResource getResourceFromInput(IEditorInput input) {
- IResource resource = (IResource) input.getAdapter(IFile.class);
- if (resource == null) {
- resource = (IResource) input.getAdapter(IResource.class);
- }
- return resource;
- }
-
- /**
- * Finds a valid position somewhere on lineNumber in document, idoc, where a
- * breakpoint can be set and returns that position. -1 is returned if a
- * position could not be found.
- *
- * @param idoc
- * @param editorLineNumber
- * @return position to set breakpoint or -1 if no position could be found
- */
- private int getValidPosition(IDocument idoc, int editorLineNumber) {
- int result = -1;
- if (idoc != null) {
-
- int startOffset = 0;
- int endOffset = 0;
- try {
- IRegion line = idoc.getLineInformation(editorLineNumber - 1);
- startOffset = line.getOffset();
- endOffset = Math.max(line.getOffset(), line.getOffset()
- + line.getLength());
-
- String lineText = idoc
- .get(startOffset, endOffset - startOffset).trim();
-
- // blank lines or lines with only an open or close brace or
- // scriptlet tag cannot have a breakpoint
- if (lineText.equals("") || lineText.equals("{") || //$NON-NLS-1$ //$NON-NLS-2$
- lineText.equals("}") || lineText.equals("<%")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- result = -1;
- } else {
- // get all partitions for current line
- ITypedRegion[] partitions = null;
-
- partitions = idoc.computePartitioning(startOffset,
- endOffset - startOffset);
-
- for (int i = 0; i < partitions.length; ++i) {
- String type = partitions[i].getType();
- // if found jsp java content, jsp directive tags,
- // custom
- // tags,
- // return that position
- if (type == IJSPPartitions.JSP_CONTENT_JAVA
- || type == IJSPPartitions.JSP_DIRECTIVE) {
- result = partitions[i].getOffset();
- }
- }
- }
- } catch (BadLocationException e) {
- result = -1;
- }
- }
-
- return result;
- }
-
- /**
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
- * java.lang.String, java.lang.Object)
- */
- public void setInitializationData(IConfigurationElement config,
- String propertyName, Object data) throws CoreException {
- if (data != null) {
- if (data instanceof String && data.toString().length() > 0) {
- fClassPattern = (String) data;
- }
- }
- }
-
- public void setSourceEditingTextTools(ISourceEditingTextTools tools) {
- // not used
- }
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java
deleted file mode 100644
index 09c92bd8e2..0000000000
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Jul 20, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.jsdt.web.ui.internal.breakpointproviders;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @author davidw
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class JavascriptLineBreakpoint {
-
- /**
- * @param res
- * @param lineNumber
- * @param pos
- * @param pos1
- */
- public JavascriptLineBreakpoint(IResource res, int lineNumber, int pos,
- int pos1) {
-
- // TODO Should be deleted? Along with calling class?
- }
-
- /**
- *
- */
- public JavascriptLineBreakpoint() {
- super();
- }
-
- /**
- *
- */
- public IResource getResource() throws CoreException {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @return
- */
- public int getLineNumber() {
- // TODO Auto-generated method stub
- return 0;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java
index 60dc2e328c..49ed7afdf0 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/contentassist/JSDTContentAssistant.java
@@ -57,10 +57,11 @@ public class JSDTContentAssistant extends AbstractContentAssistProcessor {
IDOMModel xmlModel = null;
- xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
+
try {
- IDOMDocument xmlDoc = xmlModel.getDocument();
+ xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());
+ IDOMDocument xmlDoc = xmlModel.getDocument();
if (fTranslationAdapter == null) {
fTranslationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java
index 371b4ca6a4..2c3b93052f 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/refactoring/JSPJavaSelectionProvider.java
@@ -34,9 +34,10 @@ class JSPJavaSelectionProvider {
if (selection instanceof ITextSelection) {
ITextSelection textSelection = (ITextSelection) selection;
// get the JSP translation object for this editor's document
- IStructuredModel model = StructuredModelManager.getModelManager()
- .getExistingModelForRead(document);
+ IStructuredModel model = null;
try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
if (model instanceof IDOMModel) {
IDOMModel xmlModel = (IDOMModel) model;
IDOMDocument xmlDoc = xmlModel.getDocument();
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JSPFindOccurrencesProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JSPFindOccurrencesProcessor.java
index 4948819e14..736ea0c413 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JSPFindOccurrencesProcessor.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/java/search/JSPFindOccurrencesProcessor.java
@@ -68,9 +68,10 @@ public class JSPFindOccurrencesProcessor extends FindOccurrencesProcessor {
IDocument document, ITextSelection selection) {
IJavaElement[] elements = new IJavaElement[0];
// get JSP translation object for this viewer's document
- IStructuredModel model = StructuredModelManager.getModelManager()
- .getExistingModelForRead(document);
+ IStructuredModel model = null;
try {
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
if (model != null && model instanceof IDOMModel) {
IDOMDocument xmlDoc = ((IDOMModel) model).getDocument();
JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
index 389c696704..b18180edf7 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/internal/taginfo/JSDTHoverProcessor.java
@@ -110,8 +110,9 @@ public class JSDTHoverProcessor extends AbstractHoverProcessor {
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
// get JSP translation object for this viewer's document
- IDOMModel xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
+ IDOMModel xmlModel = null;
try {
+ xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
if (xmlModel != null) {
IDOMDocument xmlDoc = xmlModel.getDocument();
JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
diff --git a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
index 6f3ddeb161..69d8d8f876 100644
--- a/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
+++ b/bundles/org.eclipse.wst.jsdt.web.ui/src/org/eclipse/wst/jsdt/web/ui/views/contentoutline/JFaceNodeAdapterForJs.java
@@ -104,7 +104,7 @@ public class JFaceNodeAdapterForJs extends JFaceNodeAdapterForHTML {
IJavaElement[] result = null;
IDocument viewerDoc = null;
-
+ IDOMDocument xmlDoc=null;
try {
if (modelManager != null) {
IStructuredDocument doc = ((NodeImpl) node).getStructuredDocument();
@@ -112,33 +112,37 @@ public class JFaceNodeAdapterForJs extends JFaceNodeAdapterForHTML {
model = modelManager.getExistingModelForRead(doc);
}
IDOMModel domModel = (IDOMModel) model;
- IDOMDocument xmlDoc = domModel.getDocument();
+ xmlDoc = domModel.getDocument();
+
+
+
+ } catch (Exception e) {
+ Logger.logException(e);
+ } finally {
+ if (model != null) {
+ // model.changedModel();
+ model.releaseFromRead();
+ }
+ }
+ if (xmlDoc==null)
+ return null;
+
viewerDoc = xmlDoc.getStructuredDocument();
JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
translation = translationAdapter.getJSPTranslation();
-
-
int startOffset = 0;
int endOffset = 0;
int type = node.getNodeType();
if (node.getNodeType() == Node.TEXT_NODE && (node instanceof NodeImpl) && translation != null) {
startOffset = ((NodeImpl) node).getStartOffset();
endOffset = ((NodeImpl) node).getEndOffset();
-
result = translation.getAllElementsFromJspRange(startOffset, endOffset);
-
}
+
if (result == null)
return null;
- } catch (Exception e) {
- Logger.logException(e);
- } finally {
- if (model != null) {
- // model.changedModel();
- model.releaseFromRead();
- }
- }
+
Object[] newResults=new Object[result.length];
for (int i = 0; i < result.length; i++) {

Back to the top