Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2009-04-06 17:23:55 -0400
committerMike Kucera2009-04-06 17:23:55 -0400
commit6143779d73ad20bc53064fe2c83e31957c69536e (patch)
tree3b55145e31a8ec0d04907e5e28bee67aec19ea77 /lrparser/org.eclipse.cdt.core.lrparser
parentbefb3fc080aa3b8fcb803811f3d373c36b8b73ad (diff)
downloadorg.eclipse.cdt-6143779d73ad20bc53064fe2c83e31957c69536e.tar.gz
org.eclipse.cdt-6143779d73ad20bc53064fe2c83e31957c69536e.tar.xz
org.eclipse.cdt-6143779d73ad20bc53064fe2c83e31957c69536e.zip
[271380] NPE when invoking content assist using LR parser
Diffstat (limited to 'lrparser/org.eclipse.cdt.core.lrparser')
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java15
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java4
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java6
3 files changed, 13 insertions, 12 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
index 104239da8c..ae4c7af7dd 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/ASTCompletionNode.java
@@ -46,12 +46,11 @@ public class ASTCompletionNode implements IASTCompletionNode {
/**
* Creates a completion node.
- * @throws NullPointerException if tu is null
- * @throws IllegalArgumentException if prefix is the empty string, it should be null instead
+ * @param prefix The completion prefix, set to null if the empty string is passed.
*/
public ASTCompletionNode(String prefix, IASTTranslationUnit tu) {
if("".equals(prefix)) //$NON-NLS-1$
- throw new IllegalArgumentException("prefix cannot be the empty string"); //$NON-NLS-1$
+ prefix = null;
this.prefix = prefix;
this.tu = tu;
@@ -89,14 +88,12 @@ public class ASTCompletionNode implements IASTCompletionNode {
public String getPrefix() {
return prefix;
}
+
+ public void setTranslationUnit(IASTTranslationUnit tu) {
+ this.tu = tu;
+ }
public IASTTranslationUnit getTranslationUnit() {
- if(names.isEmpty())
- return null;
-
- if(tu == null)
- tu = names.get(0).getTranslationUnit();
-
return tu;
}
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java
index 6e53c83a40..beb2ee3075 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/AbstractParserAction.java
@@ -112,7 +112,6 @@ public abstract class AbstractParserAction {
*/
protected void addNameToCompletionNode(IASTName name, String prefix) {
if(completionNode == null) {
- prefix = (prefix == null || prefix.length() == 0) ? null : prefix;
completionNode = newCompletionNode(prefix);
}
@@ -120,10 +119,9 @@ public abstract class AbstractParserAction {
}
public ASTCompletionNode newCompletionNode(String prefix) {
- return new ASTCompletionNode((prefix == null || prefix.length() == 0) ? null : prefix);
+ return new ASTCompletionNode(prefix);
}
-
/**
* Returns the completion node if this is a completion parse, null otherwise.
*/
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
index e991a59871..36534d7d6a 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java
@@ -176,6 +176,12 @@ public abstract class BuildASTParserAction extends AbstractParserAction {
}
+ @Override
+ public ASTCompletionNode newCompletionNode(String prefix) {
+ return new ASTCompletionNode(prefix, tu);
+ }
+
+
/**
* Removes ambiguity nodes from the AST by resolving them.
*

Back to the top