Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 195352 Details for
Bug 345334
CodeSnippet's run method is missing @Override annotation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + updated regression tests
patch_345334.txt (text/plain), 10.18 KB, created by
Olivier Thomann
on 2011-05-11 10:11:28 EDT
(
hide
)
Description:
Proposed fix + updated regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-05-11 10:11:28 EDT
Size:
10.18 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java,v >retrieving revision 1.30 >diff -u -r1.30 CodeSnippetEvaluator.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java 7 Mar 2009 01:08:09 -0000 1.30 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java 11 May 2011 14:10:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,6 +12,7 @@ > > import java.util.Map; > >+import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.compiler.*; > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.Compiler; >@@ -188,7 +189,8 @@ > this.context.localVariableTypeNames, > this.context.localVariableModifiers, > this.context.declaringTypeName, >- this.context.lineSeparator >+ this.context.lineSeparator, >+ CompilerOptions.versionToJdkLevel(this.options.get(JavaCore.COMPILER_SOURCE)) > ); > > } >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java,v >retrieving revision 1.69 >diff -u -r1.69 CodeSnippetToCuMapper.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 7 Jan 2010 20:18:48 -0000 1.69 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java 11 May 2011 14:10:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,8 +16,8 @@ > import org.eclipse.jdt.core.Flags; > import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.core.compiler.*; >-import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.internal.codeassist.ISelectionRequestor; >+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > > /** > * Maps back and forth a code snippet to a compilation unit. >@@ -56,11 +56,24 @@ > // Mapping of external local variables > char[][] localVarNames; > char[][] localVarTypeNames; >+ >+ long sourceVersion; > > /** > * Rebuild source in presence of external local variables > */ >- public CodeSnippetToCuMapper(char[] codeSnippet, char[] packageName, char[][] imports, char[] className, char[] varClassName, char[][] localVarNames, char[][] localVarTypeNames, int[] localVarModifiers, char[] declaringTypeName, String lineSeparator) { >+ public CodeSnippetToCuMapper( >+ char[] codeSnippet, >+ char[] packageName, >+ char[][] imports, >+ char[] className, >+ char[] varClassName, >+ char[][] localVarNames, >+ char[][] localVarTypeNames, >+ int[] localVarModifiers, >+ char[] declaringTypeName, >+ String lineSeparator, >+ long sourceVersion) { > this.codeSnippet = codeSnippet; > this.snippetPackageName = packageName; > this.snippetImports = imports; >@@ -69,6 +82,7 @@ > this.localVarNames = localVarNames; > this.localVarTypeNames = localVarTypeNames; > this.snippetDeclaringTypeName = declaringTypeName; >+ this.sourceVersion = sourceVersion; > buildCUSource(lineSeparator); > } > private void buildCUSource(String lineSeparator) { >@@ -129,6 +143,9 @@ > } > } > // run() method declaration >+ if (this.sourceVersion >= ClassFileConstants.JDK1_6) { >+ buffer.append("@Override "); //$NON-NLS-1$ >+ } > buffer.append("public void run() throws Throwable {").append(lineSeparator); //$NON-NLS-1$ > this.lineNumberOffset++; > this.startPosOffset = buffer.length(); >Index: eval/org/eclipse/jdt/internal/eval/EvaluationContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java,v >retrieving revision 1.65 >diff -u -r1.65 EvaluationContext.java >--- eval/org/eclipse/jdt/internal/eval/EvaluationContext.java 20 May 2010 14:12:00 -0000 1.65 >+++ eval/org/eclipse/jdt/internal/eval/EvaluationContext.java 11 May 2011 14:10:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,6 +16,7 @@ > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jdt.core.CompletionRequestor; > import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.WorkingCopyOwner; > import org.eclipse.jdt.core.compiler.*; > import org.eclipse.jdt.internal.codeassist.CompletionEngine; >@@ -28,6 +29,7 @@ > import org.eclipse.jdt.internal.compiler.env.IBinaryType; > import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; > import org.eclipse.jdt.internal.compiler.env.INameEnvironment; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; > import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; > import org.eclipse.jdt.internal.compiler.util.SuffixConstants; >@@ -128,6 +130,7 @@ > // Do nothing > } > final char[] className = "CodeSnippetCompletion".toCharArray(); //$NON-NLS-1$ >+ final long sourceVersion = CompilerOptions.versionToJdkLevel(options.get(JavaCore.COMPILER_SOURCE)); > final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper( > codeSnippet, > this.packageName, >@@ -138,7 +141,8 @@ > this.localVariableTypeNames, > this.localVariableModifiers, > this.declaringTypeName, >- this.lineSeparator >+ this.lineSeparator, >+ sourceVersion > ); > ICompilationUnit sourceUnit = new ICompilationUnit() { > public char[] getFileName() { >@@ -570,6 +574,7 @@ > WorkingCopyOwner owner) { > > final char[] className = "CodeSnippetSelection".toCharArray(); //$NON-NLS-1$ >+ final long sourceVersion = CompilerOptions.versionToJdkLevel(options.get(JavaCore.COMPILER_SOURCE)); > final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper( > codeSnippet, > this.packageName, >@@ -580,7 +585,8 @@ > this.localVariableTypeNames, > this.localVariableModifiers, > this.declaringTypeName, >- this.lineSeparator >+ this.lineSeparator, >+ sourceVersion > ); > ICompilationUnit sourceUnit = new ICompilationUnit() { > public char[] getFileName() { >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java,v >retrieving revision 1.19 >diff -u -r1.19 CodeSnippetTest.java >--- src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java 28 Apr 2009 17:17:55 -0000 1.19 >+++ src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java 11 May 2011 14:10:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,11 +10,14 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.eval; > >+import java.util.Map; >+ > import junit.framework.Test; > > import org.eclipse.jdt.core.compiler.CategorizedProblem; > import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; > import org.eclipse.jdt.internal.eval.EvaluationResult; > import org.eclipse.jdt.internal.eval.IRequestor; >@@ -43,6 +46,21 @@ > public static Test suite() { > return setupSuite(testClass()); > } >+public Map getCompilerOptions() { >+ Map defaultOptions = super.getCompilerOptions(); >+ defaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); >+ defaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); >+ defaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); >+ defaultOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ defaultOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE); >+ defaultOptions.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING); >+ defaultOptions.put(CompilerOptions.OPTION_ReportLocalVariableHiding, CompilerOptions.WARNING); >+ defaultOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE); >+ defaultOptions.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, CompilerOptions.WARNING); >+ defaultOptions.put(CompilerOptions.OPTION_ReportMissingOverrideAnnotation, CompilerOptions.ERROR); >+ defaultOptions.put(CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, CompilerOptions.ERROR); >+ return defaultOptions; >+} > /** > * Tests code snippet that throws a checked exception. > * (Regression test for 1G0T5XK)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 345334
:
195352
|
195378