summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2013-04-22 18:51:34 (EDT)
committercbateman2013-04-22 18:51:34 (EDT)
commit4571e58a2c343290829b90d8b23eecbbc7991a45 (patch)
treef9ee043d6a9d1807de0668f78ecfde56dabac4b4
parenteb98560f04e8999462853ab6143ecea32480b32a (diff)
downloadwebtools.jsf-4571e58a2c343290829b90d8b23eecbbc7991a45.zip
webtools.jsf-4571e58a2c343290829b90d8b23eecbbc7991a45.tar.gz
webtools.jsf-4571e58a2c343290829b90d8b23eecbbc7991a45.tar.bz2
Null checks to cover 392381 and 390867.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java40
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java67
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/SymbolResolveUtil.java4
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/ElementCMAdapter.java54
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/NamespaceCMAdapter.java2
5 files changed, 100 insertions, 67 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java
index 78c3c6c..7a3e961 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/ContentAssistParser.java
@@ -116,6 +116,10 @@ public final class ContentAssistParser
}
private static String substring(String s, Region r) {
+ if (s == null && s.isEmpty())
+ {
+ return ""; //$NON-NLS-1$
+ }
return s.substring(r.getOffset(), r.getOffset() + r.getLength());
}
@@ -166,27 +170,29 @@ public final class ContentAssistParser
* @param context - IStructuredDocumentContext
* @return symbol and symbol region if resolved, null otherwise
*/
- public SymbolInfo getSymbolInfo(IStructuredDocumentContext context) {
- if (_prefixResolved && _symbolStartPos < _symbolEndPos) {
- Region region = new Region(_symbolStartPos - 1, _symbolEndPos - _symbolStartPos + 1);
+ public SymbolInfo getSymbolInfo(IStructuredDocumentContext context)
+ {
+ if (_prefixResolved && _symbolStartPos < _symbolEndPos)
+ {
+ Region region = new Region(_symbolStartPos - 1, _symbolEndPos - _symbolStartPos + 1);
ISymbol symbol = null;
- switch (_prefixType) {
- case ContentAssistStrategy.PREFIX_TYPE_ID_COMPLETION:
- symbol = SymbolResolveUtil.getSymbolForVariable(context, substring(_fullText, region));
- break;
- case ContentAssistStrategy.PREFIX_TYPE_DOT_COMPLETION:
- symbol = SymbolResolveUtil.getSymbolForVariableSuffixExpr(context, _symbolPrefix + "." + substring(_fullText, region), _symbolEndPos == _fullText.length()); //$NON-NLS-1$
- break;
- }
- if (symbol != null) {
- return new SymbolInfo(symbol, region);
+ switch (_prefixType)
+ {
+ case ContentAssistStrategy.PREFIX_TYPE_ID_COMPLETION:
+ symbol = SymbolResolveUtil.getSymbolForVariable(context, substring(_fullText, region));
+ break;
+ case ContentAssistStrategy.PREFIX_TYPE_DOT_COMPLETION:
+ symbol = SymbolResolveUtil.getSymbolForVariableSuffixExpr(context, _symbolPrefix
+ + "." + substring(_fullText, region), _symbolEndPos == (_fullText != null ? _fullText.length():0)); //$NON-NLS-1$
+ break;
}
- }
- return null;
+ if (symbol != null) { return new SymbolInfo(symbol, region); }
+ }
+ return null;
}
private String getProposalStart() {
- if (_symbolStartPos <= _relativePos) {
+ if (_symbolStartPos <= _relativePos && _fullText != null) {
return _fullText.substring(_symbolStartPos - 1, _relativePos - 1);
}
return ""; //$NON-NLS-1$
@@ -335,7 +341,7 @@ public final class ContentAssistParser
Object retValue = node.childrenAccept(this, data);
- if (!_prefixResolved)
+ if (!_prefixResolved && _fullText!=null)
{
// if we haven't resolved the prefix yet, then we need
// to append this suffix value
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java
index ff58d1b..0f8a49a 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/FunctionCompletionStrategy.java
@@ -61,43 +61,46 @@ public class FunctionCompletionStrategy extends ContentAssistStrategy
StructuredDocumentSymbolResolverFactory.getInstance().
getSymbolContextResolver(context);
- final ISymbol symbol = SymbolResolveUtil.getSymbolForVariableSuffixExpr(context, getValue(), false);
-
- // if we get a completion symbol, get it's proposals
- if (symbol instanceof IObjectSymbol)
+ String text = getValue();
+ if (text != null)
{
- final List expectedMethodBindings = new ArrayList();
- final ISymbol[] suffixes = getSymbols((IObjectSymbol) symbol,
- context,
- symbolResolver,
- expectedMethodBindings);
-
- final ComposedAdapterFactory factory =
- new ComposedAdapterFactory(
- ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final IProposalCreationFactory creationInfo =
- new MyProposalFactory(context, getProposalStart().length(),
- expectedMethodBindings);
-
- completionList = new ArrayList<ICompletionProposal>();
- for (final ISymbol propSymbol : suffixes) {
- final Object provider =
- factory.adapt(propSymbol, IContentProposalProvider.class);
-
- if (provider instanceof IContentProposalProvider)
- {
- final ICompletionProposal[] proposal =
- ((IContentProposalProvider) provider).
- getProposals(propSymbol, creationInfo);
- if (proposal != null)
+ final ISymbol symbol = SymbolResolveUtil.getSymbolForVariableSuffixExpr(context, getValue(), false);
+
+ // if we get a completion symbol, get it's proposals
+ if (symbol instanceof IObjectSymbol)
+ {
+ final List expectedMethodBindings = new ArrayList();
+ final ISymbol[] suffixes = getSymbols((IObjectSymbol) symbol,
+ context,
+ symbolResolver,
+ expectedMethodBindings);
+
+ final ComposedAdapterFactory factory =
+ new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ final IProposalCreationFactory creationInfo =
+ new MyProposalFactory(context, getProposalStart().length(),
+ expectedMethodBindings);
+
+ completionList = new ArrayList<ICompletionProposal>();
+ for (final ISymbol propSymbol : suffixes) {
+ final Object provider =
+ factory.adapt(propSymbol, IContentProposalProvider.class);
+
+ if (provider instanceof IContentProposalProvider)
{
- addProposalsMatchingProposalStart(completionList,
- proposal);
+ final ICompletionProposal[] proposal =
+ ((IContentProposalProvider) provider).
+ getProposals(propSymbol, creationInfo);
+ if (proposal != null)
+ {
+ addProposalsMatchingProposalStart(completionList,
+ proposal);
+ }
}
}
}
- }
-
+ }
return Collections.unmodifiableList(completionList);
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/SymbolResolveUtil.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/SymbolResolveUtil.java
index 29b1518..f2480b6 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/SymbolResolveUtil.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/core/internal/contentassist/el/SymbolResolveUtil.java
@@ -73,6 +73,10 @@ public class SymbolResolveUtil {
public static ISymbol getSymbolForVariableSuffixExpr(
final IStructuredDocumentContext context, final String fullName,
final boolean isLastSuffix) {
+ if (fullName == null)
+ {
+ return null;
+ }
String[] ids = fullName.split("\\."); //$NON-NLS-1$
// if no suffixes, only one id
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/ElementCMAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/ElementCMAdapter.java
index b38e431..6cc8e49 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/ElementCMAdapter.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/ElementCMAdapter.java
@@ -3,6 +3,7 @@
*/
package org.eclipse.jst.jsf.facelet.core.internal.cm;
+import java.util.Collections;
import java.util.Iterator;
import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.ITagElement;
@@ -20,6 +21,7 @@ class ElementCMAdapter implements CMElementDeclaration, CMNamedNodeMap
ElementCMAdapter(final ITagElement tagElement, final TagInfo tldTagInfo)
{
+ assert tagElement != null;
_tagElement = tagElement;
_tLDTagInfo = tldTagInfo;
}
@@ -51,7 +53,6 @@ class ElementCMAdapter implements CMElementDeclaration, CMNamedNodeMap
public CMNamedNodeMap getLocalElements()
{
- // TODO Auto-generated method stub
return null;
}
@@ -79,7 +80,11 @@ class ElementCMAdapter implements CMElementDeclaration, CMNamedNodeMap
public Object getProperty(final String propertyName)
{
- return _tLDTagInfo.getTagProperty(_tagElement.getName(), propertyName);
+ if (_tLDTagInfo != null)
+ {
+ return _tLDTagInfo.getTagProperty(_tagElement.getName(), propertyName);
+ }
+ return null;
}
public boolean supports(final String propertyName)
@@ -106,42 +111,57 @@ class ElementCMAdapter implements CMElementDeclaration, CMNamedNodeMap
public int getLength()
{
- final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
-
- if (map != null)
+ if (_tLDTagInfo != null)
{
- return map.getLength();
+ final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
+
+ if (map != null)
+ {
+ return map.getLength();
+ }
}
-
return 0;
}
public CMNode getNamedItem(final String name)
{
- final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
-
- if (map != null)
+ if (_tLDTagInfo != null)
{
- return map.getNamedItem(name);
+ final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
+
+ if (map != null)
+ {
+ return map.getNamedItem(name);
+ }
}
return null;
}
public CMNode item(final int index)
{
- final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
-
- if (map != null)
+ if (_tLDTagInfo != null)
{
- return map.item(index);
+ final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
+
+ if (map != null)
+ {
+ return map.item(index);
+ }
}
return null;
}
public Iterator<?> iterator()
{
- final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
- return map.iterator();
+ if (_tLDTagInfo != null)
+ {
+ final CMNamedNodeMap map = _tLDTagInfo.getAttributes(_tagElement.getName());
+ if (map != null)
+ {
+ return map.iterator();
+ }
+ }
+ return Collections.EMPTY_LIST.iterator();
}
} \ No newline at end of file
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/NamespaceCMAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/NamespaceCMAdapter.java
index 0732f19..494f72b 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/NamespaceCMAdapter.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/NamespaceCMAdapter.java
@@ -76,7 +76,7 @@ import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
for (int i = 0; it.hasNext(); i++)
{
final ITagElement tagElement = (ITagElement) it.next();
- if (i == index)
+ if (i == index && tagElement != null)
{
ElementCMAdapter element = _elements.get(tagElement.getName());