1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 03:53:21 +02:00

[271380] NPE when invoking content assist using LR parser

This commit is contained in:
Mike Kucera 2009-04-06 21:23:55 +00:00
parent befb3fc080
commit 6143779d73
3 changed files with 13 additions and 12 deletions

View file

@ -46,12 +46,11 @@ public class ASTCompletionNode implements IASTCompletionNode {
/** /**
* Creates a completion node. * Creates a completion node.
* @throws NullPointerException if tu is null * @param prefix The completion prefix, set to null if the empty string is passed.
* @throws IllegalArgumentException if prefix is the empty string, it should be null instead
*/ */
public ASTCompletionNode(String prefix, IASTTranslationUnit tu) { public ASTCompletionNode(String prefix, IASTTranslationUnit tu) {
if("".equals(prefix)) //$NON-NLS-1$ if("".equals(prefix)) //$NON-NLS-1$
throw new IllegalArgumentException("prefix cannot be the empty string"); //$NON-NLS-1$ prefix = null;
this.prefix = prefix; this.prefix = prefix;
this.tu = tu; this.tu = tu;
@ -90,13 +89,11 @@ public class ASTCompletionNode implements IASTCompletionNode {
return prefix; return prefix;
} }
public void setTranslationUnit(IASTTranslationUnit tu) {
this.tu = tu;
}
public IASTTranslationUnit getTranslationUnit() { public IASTTranslationUnit getTranslationUnit() {
if(names.isEmpty())
return null;
if(tu == null)
tu = names.get(0).getTranslationUnit();
return tu; return tu;
} }

View file

@ -112,7 +112,6 @@ public abstract class AbstractParserAction {
*/ */
protected void addNameToCompletionNode(IASTName name, String prefix) { protected void addNameToCompletionNode(IASTName name, String prefix) {
if(completionNode == null) { if(completionNode == null) {
prefix = (prefix == null || prefix.length() == 0) ? null : prefix;
completionNode = newCompletionNode(prefix); completionNode = newCompletionNode(prefix);
} }
@ -120,10 +119,9 @@ public abstract class AbstractParserAction {
} }
public ASTCompletionNode newCompletionNode(String prefix) { 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. * Returns the completion node if this is a completion parse, null otherwise.
*/ */

View file

@ -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. * Removes ambiguity nodes from the AST by resolving them.
* *