Code example for StringWriter

Methods: toStringwrite

0
        ch= getRefactorChanges(cpp2, offset2, "CCC");  //$NON-NLS-1$
        assertTotalChanges(2, ch);
    } 
     
    public void testIncludeGuard() throws Exception { 
        StringWriter writer = new StringWriter();
        writer.write("#ifndef _guard            \n"); //$NON-NLS-1$
        writer.write("#define _guard            \n"); //$NON-NLS-1$
        writer.write(" int HALLO                \n"); //$NON-NLS-1$
        writer.write("#endif /* _guard */       \n"); //$NON-NLS-1$
        String contents = writer.toString();
        IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
         
        int offset1= contents.indexOf("_guard"); //$NON-NLS-1$
        int offset2= contents.indexOf("_guard", offset1+1); //$NON-NLS-1$
        Change ch= getRefactorChanges(cpp, offset2, "WELT");  //$NON-NLS-1$
        assertTotalChanges(2, 0, 1, ch);
        int off= offset1;
        assertChange(ch, cpp, off, 6, "WELT"); //$NON-NLS-1$
        off= contents.indexOf("_guard", off+1); //$NON-NLS-1$
Contextual code suggestions in your IDE  Get Codota for Java