1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-09 19:43:27 +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.
* @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;
}

View file

@ -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.
*/

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.
*