View | Details | Raw Unified | Return to bug 179000
Collapse All | Expand All

(-)eval/org/eclipse/jdt/internal/eval/EvaluationContext.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 514-519 Link Here
514
	}
514
	}
515
	return this.codeSnippetBinary;
515
	return this.codeSnippetBinary;
516
}
516
}
517
public char[] getVarClassName() {
518
	if (installedVars == null) return CharOperation.NO_CHAR;
519
	return CharOperation.concat(installedVars.packageName, installedVars.className, '.');
520
}
517
/**
521
/**
518
 * Creates a new global variable with the given name, type and initializer.
522
 * Creates a new global variable with the given name, type and initializer.
519
 * If the variable is not initialized, the initializer can be null.
523
 * If the variable is not initialized, the initializer can be null.
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java (-5 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 164-180 Link Here
164
						if (CharOperation.equals(packageName, CodeSnippetToCuMapper.this.snippetPackageName) 
164
						if (CharOperation.equals(packageName, CodeSnippetToCuMapper.this.snippetPackageName) 
165
								&& (CharOperation.equals(className, CodeSnippetToCuMapper.this.snippetClassName)
165
								&& (CharOperation.equals(className, CodeSnippetToCuMapper.this.snippetClassName)
166
									|| CharOperation.equals(className, CodeSnippetToCuMapper.this.snippetVarClassName))) return;
166
									|| CharOperation.equals(className, CodeSnippetToCuMapper.this.snippetVarClassName))) return;
167
						
168
						if (CharOperation.equals(packageName, PACKAGE_NAME) 
169
								&& CharOperation.equals(className, ROOT_CLASS_NAME)) return;
167
					}
170
					}
168
					break;
171
					break;
169
				case CompletionProposal.METHOD_REF:
172
				case CompletionProposal.METHOD_REF:
170
				case CompletionProposal.METHOD_DECLARATION:
173
				case CompletionProposal.METHOD_DECLARATION:
171
					// Remove completion on generated method
174
					// Remove completion on generated method
172
					char[] declaringTypePackageName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature());
175
					char[] declaringTypePackageName = Signature.getSignatureQualifier(proposal.getDeclarationSignature());
173
					char[] declaringTypeName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature());
176
					char[] declaringTypeName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature());
174
					char[] selector = proposal.getName();
177
					
175
					if (CharOperation.equals(declaringTypePackageName, CodeSnippetToCuMapper.this.snippetPackageName) 
178
					if (CharOperation.equals(declaringTypePackageName, CodeSnippetToCuMapper.this.snippetPackageName) 
176
							&& CharOperation.equals(declaringTypeName, CodeSnippetToCuMapper.this.snippetClassName)
179
							&& CharOperation.equals(declaringTypeName, CodeSnippetToCuMapper.this.snippetClassName)) return;
177
							&& CharOperation.equals(selector, "run".toCharArray())) return; //$NON-NLS-1$
180
					
181
					if (CharOperation.equals(declaringTypePackageName, PACKAGE_NAME) 
182
							&& CharOperation.equals(declaringTypeName, ROOT_CLASS_NAME)) return;
178
					break;
183
					break;
179
			}
184
			}
180
			originalRequestor.accept(proposal);
185
			originalRequestor.accept(proposal);
(-)model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 272-277 Link Here
272
protected INameEnvironment getBuildNameEnvironment() {
272
protected INameEnvironment getBuildNameEnvironment() {
273
	return new NameEnvironment(getProject());
273
	return new NameEnvironment(getProject());
274
}
274
}
275
public char[] getVarClassName() {
276
	return this.context.getVarClassName();
277
}
275
278
276
/**
279
/**
277
 * @see org.eclipse.jdt.core.eval.IEvaluationContext#getImports()
280
 * @see org.eclipse.jdt.core.eval.IEvaluationContext#getImports()
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+41 lines)
Lines 19-24 Link Here
19
import org.eclipse.jdt.core.ICompilationUnit;
19
import org.eclipse.jdt.core.ICompilationUnit;
20
import org.eclipse.jdt.core.eval.IEvaluationContext;
20
import org.eclipse.jdt.core.eval.IEvaluationContext;
21
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
21
import org.eclipse.jdt.internal.codeassist.RelevanceConstants;
22
import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper;
22
23
23
import junit.framework.*;
24
import junit.framework.*;
24
25
Lines 44-49 Link Here
44
public void tearDownSuite() throws Exception {
45
public void tearDownSuite() throws Exception {
45
	super.tearDownSuite();
46
	super.tearDownSuite();
46
}
47
}
48
private String getVarClassSignature(IEvaluationContext context) {
49
	char[] varClassName = ((EvaluationContextWrapper)context).getVarClassName();
50
	return Signature.createTypeSignature(varClassName, true);
51
}
47
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311
52
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=164311
48
public void testBug164311() throws JavaModelException {
53
public void testBug164311() throws JavaModelException {
49
	this.workingCopies = new ICompilationUnit[1];
54
	this.workingCopies = new ICompilationUnit[1];
Lines 14046-14051 Link Here
14046
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"}",
14051
			"toString[METHOD_REF]{toString(), Ljava.lang.Object;, ()Ljava.lang.String;, toString, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED)+"}",
14047
			requestor.getResults());
14052
			requestor.getResults());
14048
}
14053
}
14054
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=179000
14055
public void testEvaluationContextCompletion6() throws JavaModelException {
14056
	this.workingCopies = new ICompilationUnit[1];
14057
	this.workingCopies[0] = getWorkingCopy(
14058
		"/Completion/src/test/TestEvaluationContextCompletion6.java",
14059
		"package test;"+
14060
		"public class TestEvaluationContextCompletion6 {\n"+
14061
		"}");
14062
	
14063
	String start = "";
14064
	IJavaProject javaProject = getJavaProject("Completion");
14065
	IEvaluationContext context = javaProject.newEvaluationContext();
14066
	
14067
	context.newVariable( "Object", "someVariable", null );
14068
	
14069
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false);
14070
	context.codeComplete(start, start.length(), requestor, this.wcOwner);
14071
	
14072
	int startOffset = start.length();
14073
	int endOffset = startOffset;
14074
	
14075
	assertResults(
14076
			"completion offset="+endOffset+"\n"+
14077
			"completion range=["+startOffset+", "+(endOffset)+"]\n"+
14078
			"completion token=\"\"\n"+
14079
			"completion token kind=TOKEN_KIND_NAME\n"+
14080
			"expectedTypesSignatures=null\n"+
14081
			"expectedTypesKeys=null",
14082
            requestor.getContext());
14083
	
14084
	String varClassSignature = getVarClassSignature(context);
14085
    
14086
	assertResults(
14087
			"someVariable[FIELD_REF]{someVariable, "+varClassSignature+", Ljava.lang.Object;, someVariable, null, "+(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED)+"}",
14088
			requestor.getResults());
14089
}
14049
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14090
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=152123
14050
public void testFavoriteImports001() throws JavaModelException {
14091
public void testFavoriteImports001() throws JavaModelException {
14051
	this.workingCopies = new ICompilationUnit[2];
14092
	this.workingCopies = new ICompilationUnit[2];

Return to bug 179000