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 54481 Details for
Bug 165783
[ast rewrite] Import declaration static property can not be set correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Test case illustrating the problem
ASTImportStaticFlagTest.java (text/plain), 2.53 KB, created by
Dmitry Denisov
on 2006-11-24 09:52:24 EST
(
hide
)
Description:
Test case illustrating the problem
Filename:
MIME Type:
Creator:
Dmitry Denisov
Created:
2006-11-24 09:52:24 EST
Size:
2.53 KB
patch
obsolete
>package org.eclipse.emf.test.tools.merger.ast; > >import java.util.Hashtable; > >import junit.framework.TestCase; > >import org.eclipse.jdt.core.JavaCore; >import org.eclipse.jdt.core.dom.AST; >import org.eclipse.jdt.core.dom.ASTParser; >import org.eclipse.jdt.core.dom.CompilationUnit; >import org.eclipse.jdt.core.dom.ImportDeclaration; >import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; >import org.eclipse.jface.text.BadLocationException; >import org.eclipse.jface.text.Document; >import org.eclipse.text.edits.MalformedTreeException; >import org.eclipse.text.edits.TextEdit; > >/** > * Tests setting / clearing static flags of import declarations. > */ >public class ASTImportStaticFlagTest extends TestCase >{ > protected String source = > "package org.eclipse;\n" + > "import static org.eclipse.ClassA.A;\n" + > "import org.eclipse.ClassB.B;\n" + > "class X {}"; > > protected String expectedSource = > "package org.eclipse;\n" + > "import org.eclipse.ClassA.A;\n" + > "import static org.eclipse.ClassB.B;\n" + > "class X {}"; > > protected CompilationUnit cu; > > @Override > protected void setUp() throws Exception > { > adjustCompilerOptions(); > cu = parse(source); > } > > public void testChangeImportStaticFlags() throws MalformedTreeException, BadLocationException > { > ASTRewrite rewriter = ASTRewrite.create(cu.getAST()); > > ImportDeclaration importDeclaration1 = (ImportDeclaration)cu.imports().get(0); > ImportDeclaration importDeclaration2 = (ImportDeclaration)cu.imports().get(1); > > assertTrue(Boolean.TRUE.equals(rewriter.get(importDeclaration1, ImportDeclaration.STATIC_PROPERTY))); > assertTrue(Boolean.FALSE.equals(rewriter.get(importDeclaration2, ImportDeclaration.STATIC_PROPERTY))); > > rewriter.set(importDeclaration1, ImportDeclaration.STATIC_PROPERTY, false, null); > rewriter.set(importDeclaration2, ImportDeclaration.STATIC_PROPERTY, true, null); > > Document doc = new Document(source); > TextEdit edit = rewriter.rewriteAST(doc, null); > edit.apply(doc); > > assertEquals(expectedSource, doc.get()); > } > > protected CompilationUnit parse(String source) > { > ASTParser parser = ASTParser.newParser(AST.JLS3); > parser.setSource(source.toCharArray()); > return (CompilationUnit) parser.createAST(null); > } > > protected void adjustCompilerOptions() > { > Hashtable options = JavaCore.getOptions(); > options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); > JavaCore.setOptions(options); > } >}
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 Raw
Actions:
View
Attachments on
bug 165783
: 54481