diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java
index f62769c582d..f52d394efc5 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java
@@ -48,13 +48,11 @@ import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
import org.eclipse.cdt.internal.ui.editor.CEditor;
-
/**
* Tests the automatic bracket insertion feature of the CEditor. Also tests
* linked mode along the way.
*/
public class BracketInserterTest extends TestCase {
-
private static final String SRC= "src";
private static final String SEP= "/";
private static final String TU_NAME= "smartedit.cpp";
@@ -77,7 +75,7 @@ public class BracketInserterTest extends TestCase {
" char[] t= args[0];" +
"}\n";
- // document offsets
+ // Document offsets.
private static final int INCLUDE_OFFSET= 9;
private static final int BODY_OFFSET= 212;
private static final int ARGS_OFFSET= 184;
@@ -173,7 +171,7 @@ public class BracketInserterTest extends TestCase {
assertModel(true);
}
- public void testDeletingMultipleParenthesisInertion() throws BadLocationException, CModelException, CoreException {
+ public void testDeletingMultipleParenthesisInsertion() throws BadLocationException, CModelException, CoreException {
setCaret(BODY_OFFSET);
type("((((");
@@ -477,7 +475,6 @@ public class BracketInserterTest extends TestCase {
return false;
}
}.waitForCondition(EditorTestHelper.getActiveDisplay(), 200);
-
}
private int getCaret() {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java
index f97faa49889..1f434202010 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java
@@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.text.contentassist;
import junit.framework.TestSuite;
@@ -22,7 +21,6 @@ public class ContentAssistTestSuite extends TestSuite {
public ContentAssistTestSuite() {
super(ContentAssistTestSuite.class.getName());
- addTest( ContentAssistTests.suite() );
-
+ addTest(ContentAssistTests.suite());
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java
index b67a838ec67..83c2dde9ee5 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.ui.tests.text.contentassist;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.io.StringWriter;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -50,74 +49,74 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
* @author aniefer
*/
public class ContentAssistTests extends BaseUITestCase {
- private final NullProgressMonitor monitor= new NullProgressMonitor();
- static IProject project;
- static ICProject cproject;
- static boolean disabledHelpContributions = false;
+ private final NullProgressMonitor monitor= new NullProgressMonitor();
+ static IProject project;
+ static ICProject cproject;
+ static boolean disabledHelpContributions;
@Override
public void setUp() throws InterruptedException {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
-
+
if (project == null) {
try {
cproject = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
project = cproject.getProject();
waitForIndexer(cproject);
- } catch ( CoreException e ) {
+ } catch (CoreException e) {
/*boo*/
}
if (project == null)
fail("Unable to create project"); //$NON-NLS-1$
}
}
- public ContentAssistTests()
- {
+
+ public ContentAssistTests() {
super();
}
+
/**
* @param name
*/
- public ContentAssistTests(String name)
- {
+ public ContentAssistTests(String name) {
super(name);
}
- private void disableContributions (){
+ private void disableContributions() {
//disable the help books so we don't get proposals we weren't expecting
CHelpBookDescriptor helpBooks[];
- helpBooks = CHelpProviderManager.getDefault().getCHelpBookDescriptors(new ICHelpInvocationContext(){
+ helpBooks = CHelpProviderManager.getDefault().getCHelpBookDescriptors(new ICHelpInvocationContext() {
@Override
- public IProject getProject(){return project;}
+ public IProject getProject() {return project;}
@Override
- public ITranslationUnit getTranslationUnit(){return null;}
+ public ITranslationUnit getTranslationUnit() {return null;}
}
);
for (CHelpBookDescriptor helpBook : helpBooks) {
- if( helpBook != null )
- helpBook.enable( false );
+ if (helpBook != null)
+ helpBook.enable(false);
}
}
public static Test suite() {
TestSuite suite= suite(ContentAssistTests.class, "_");
- suite.addTest( new ContentAssistTests("cleanupProject") ); //$NON-NLS-1$
+ suite.addTest(new ContentAssistTests("cleanupProject")); //$NON-NLS-1$
return suite;
}
public void cleanupProject() throws Exception {
closeAllEditors();
- try{
- project.delete( true, false, monitor );
+ try {
+ project.delete(true, false, monitor);
project = null;
- } catch( Throwable e ){
+ } catch (Throwable e) {
/*boo*/
}
}
@Override
protected void tearDown() throws Exception {
- if( project == null || !project.exists() )
+ if (project == null || !project.exists())
return;
closeAllEditors();
@@ -125,45 +124,46 @@ public class ContentAssistTests extends BaseUITestCase {
// wait for indexer before deleting project to avoid errors in the log
waitForIndexer(cproject);
- IResource [] members = project.members();
+ IResource[] members = project.members();
for (IResource member : members) {
- if( member.getName().equals( ".project" ) || member.getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+ if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
continue;
if (member.getName().equals(".settings"))
continue;
- try{
- member.delete( false, monitor );
- } catch( Throwable e ){
+ try {
+ member.delete(false, monitor);
+ } catch (Throwable e) {
/*boo*/
}
}
}
- protected IFile importFile(String fileName, String contents ) throws Exception{
- //Obtain file handle
+ protected IFile importFile(String fileName, String contents) throws Exception{
+ // Obtain file handle
IFile file = project.getProject().getFile(fileName);
- InputStream stream = new ByteArrayInputStream( contents.getBytes() );
- //Create file input stream
- if( file.exists() )
- file.setContents( stream, false, false, monitor );
- else
- file.create( stream, false, monitor );
+ InputStream stream = new ByteArrayInputStream(contents.getBytes());
+ // Create file input stream
+ if (file.exists()) {
+ file.setContents(stream, false, false, monitor);
+ } else {
+ file.create(stream, false, monitor);
+ }
return file;
}
- protected ICompletionProposal[] getResults( IFile file, int offset ) throws Exception {
- if( !disabledHelpContributions )
+ protected ICompletionProposal[] getResults(IFile file, int offset) throws Exception {
+ if (!disabledHelpContributions)
disableContributions();
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create( file );
+ ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
String buffer = tu.getBuffer().getContents();
IWorkingCopy wc = null;
try{
wc = tu.getWorkingCopy();
- }catch (CModelException e){
+ } catch (CModelException e) {
fail("Failed to get working copy"); //$NON-NLS-1$
}
@@ -181,103 +181,103 @@ public class ContentAssistTests extends BaseUITestCase {
}
public void testBug69334a() throws Exception {
- importFile( "test.h", "class Test{ public : Test( int ); }; \n" ); //$NON-NLS-1$//$NON-NLS-2$
- StringWriter writer = new StringWriter();
- writer.write( "#include \"test.h\" \n"); //$NON-NLS-1$
- writer.write( "Test::Test( int i ) { return; } \n"); //$NON-NLS-1$
- writer.write( "int main() { \n"); //$NON-NLS-1$
- writer.write( " int veryLongName = 1; \n"); //$NON-NLS-1$
- writer.write( " Test * ptest = new Test( very \n"); //$NON-NLS-1$
+ importFile("test.h", "class Test{ public : Test( int ); }; \n"); //$NON-NLS-1$//$NON-NLS-2$
+ StringBuilder buf = new StringBuilder();
+ buf.append("#include \"test.h\" \n"); //$NON-NLS-1$
+ buf.append("Test::Test( int i ) { return; } \n"); //$NON-NLS-1$
+ buf.append("int main() { \n"); //$NON-NLS-1$
+ buf.append(" int veryLongName = 1; \n"); //$NON-NLS-1$
+ buf.append(" Test * ptest = new Test( very \n"); //$NON-NLS-1$
- String code = writer.toString();
- IFile cu = importFile( "test.cpp", code ); //$NON-NLS-1$
+ String code = buf.toString();
+ IFile cu = importFile("test.cpp", code); //$NON-NLS-1$
- ICompletionProposal [] results = getResults( cu, code.indexOf( "very " ) + 4 ); //$NON-NLS-1$
+ ICompletionProposal[] results = getResults(cu, code.indexOf("very ") + 4); //$NON-NLS-1$
- assertEquals( 1, results.length );
- assertEquals( "veryLongName : int", results[0].getDisplayString() ); //$NON-NLS-1$
+ assertEquals(1, results.length);
+ assertEquals("veryLongName : int", results[0].getDisplayString()); //$NON-NLS-1$
}
public void testBug69334b() throws Exception {
- importFile( "test.h", "class Test{ public : Test( int ); }; \n" ); //$NON-NLS-1$//$NON-NLS-2$
- StringWriter writer = new StringWriter();
- writer.write( "#include \"test.h\" \n"); //$NON-NLS-1$
- writer.write( "Test::Test( int i ) { return; } \n"); //$NON-NLS-1$
- writer.write( "int main() { \n"); //$NON-NLS-1$
- writer.write( " int veryLongName = 1; \n"); //$NON-NLS-1$
- writer.write( " Test test( very \n"); //$NON-NLS-1$
+ importFile("test.h", "class Test{ public : Test( int ); }; \n"); //$NON-NLS-1$//$NON-NLS-2$
+ StringBuilder buf = new StringBuilder();
+ buf.append("#include \"test.h\" \n"); //$NON-NLS-1$
+ buf.append("Test::Test( int i ) { return; } \n"); //$NON-NLS-1$
+ buf.append("int main() { \n"); //$NON-NLS-1$
+ buf.append(" int veryLongName = 1; \n"); //$NON-NLS-1$
+ buf.append(" Test test( very \n"); //$NON-NLS-1$
- String code = writer.toString();
- IFile cu = importFile( "test.cpp", code ); //$NON-NLS-1$
+ String code = buf.toString();
+ IFile cu = importFile("test.cpp", code); //$NON-NLS-1$
- ICompletionProposal [] results = getResults( cu, code.indexOf( "very " ) + 4 ); //$NON-NLS-1$
+ ICompletionProposal[] results = getResults(cu, code.indexOf("very ") + 4); //$NON-NLS-1$
- assertEquals( 1, results.length );
- assertEquals( "veryLongName : int", results[0].getDisplayString() ); //$NON-NLS-1$
+ assertEquals(1, results.length);
+ assertEquals("veryLongName : int", results[0].getDisplayString()); //$NON-NLS-1$
}
public void testBug72824() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write( "class Strategy { \n"); //$NON-NLS-1$
- writer.write( "public : \n"); //$NON-NLS-1$
- writer.write( " enum _Ability { IDIOT, NORMAL, CHEAT } ; \n"); //$NON-NLS-1$
- writer.write( " Strategy( _Ability a ) { } \n"); //$NON-NLS-1$
- writer.write( " _Ability getAbility(); \n"); //$NON-NLS-1$
- writer.write( "}; \n"); //$NON-NLS-1$
- writer.write( "int main(){ \n"); //$NON-NLS-1$
+ StringBuilder buf = new StringBuilder();
+ buf.append("class Strategy { \n"); //$NON-NLS-1$
+ buf.append("public : \n"); //$NON-NLS-1$
+ buf.append(" enum _Ability { IDIOT, NORMAL, CHEAT } ; \n"); //$NON-NLS-1$
+ buf.append(" Strategy( _Ability a ) { } \n"); //$NON-NLS-1$
+ buf.append(" _Ability getAbility(); \n"); //$NON-NLS-1$
+ buf.append("}; \n"); //$NON-NLS-1$
+ buf.append("int main(){ \n"); //$NON-NLS-1$
- String code = writer.toString();
+ String code = buf.toString();
String c2 = code + " Strategy *p[3] = { new Strategy( Str \n"; //$NON-NLS-1$
- IFile cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
+ IFile cu = importFile("strategy.cpp", c2); //$NON-NLS-1$
- ICompletionProposal [] results = getResults( cu, c2.indexOf( "Str " ) + 3 ); //$NON-NLS-1$
- assertEquals( 1, results.length );
- assertEquals( "Strategy", results[0].getDisplayString() ); //$NON-NLS-1$
+ ICompletionProposal[] results = getResults(cu, c2.indexOf("Str ") + 3); //$NON-NLS-1$
+ assertEquals(1, results.length);
+ assertEquals("Strategy", results[0].getDisplayString()); //$NON-NLS-1$
c2 = code + " Strategy *p[3] = { new Strategy( Strategy:: \n"; //$NON-NLS-1$
- cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
+ cu = importFile("strategy.cpp", c2); //$NON-NLS-1$
- results = getResults( cu, c2.indexOf( "::" ) + 2 ); //$NON-NLS-1$
- assertEquals( 4, results.length );
- assertEquals( "CHEAT", results[0].getDisplayString() ); //$NON-NLS-1$
- assertEquals( "IDIOT", results[1].getDisplayString() ); //$NON-NLS-1$
- assertEquals( "NORMAL", results[2].getDisplayString() ); //$NON-NLS-1$
+ results = getResults(cu, c2.indexOf("::") + 2); //$NON-NLS-1$
+ assertEquals(4, results.length);
+ assertEquals("CHEAT", results[0].getDisplayString()); //$NON-NLS-1$
+ assertEquals("IDIOT", results[1].getDisplayString()); //$NON-NLS-1$
+ assertEquals("NORMAL", results[2].getDisplayString()); //$NON-NLS-1$
// "_Ability" is here due to fix for bug 199598
// Difficult to differentiate between declaration and expression context
- assertEquals( "_Ability", results[3].getDisplayString() ); //$NON-NLS-1$
+ assertEquals("_Ability", results[3].getDisplayString()); //$NON-NLS-1$
// in a method definition context, constructors and methods should be proposed
c2 = code + "return 0;}\nStrategy::\n"; //$NON-NLS-1$
- cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
+ cu = importFile("strategy.cpp", c2); //$NON-NLS-1$
- results = getResults( cu, c2.indexOf( "::" ) + 2 ); //$NON-NLS-1$
- assertEquals( 3, results.length );
- assertEquals( "getAbility(void) : enum _Ability", results[1].getDisplayString() ); //$NON-NLS-1$
- assertEquals( "Strategy(enum _Ability a)", results[0].getDisplayString() ); //$NON-NLS-1$
- assertEquals( "_Ability", results[2].getDisplayString() ); //$NON-NLS-1$
-}
+ results = getResults(cu, c2.indexOf("::") + 2); //$NON-NLS-1$
+ assertEquals(3, results.length);
+ assertEquals("getAbility(void) : enum _Ability", results[1].getDisplayString()); //$NON-NLS-1$
+ assertEquals("Strategy(enum _Ability a)", results[0].getDisplayString()); //$NON-NLS-1$
+ assertEquals("_Ability", results[2].getDisplayString()); //$NON-NLS-1$
+ }
public void testBug72559() throws Exception {
- StringWriter writer = new StringWriter();
- writer.write("void foo(){ \n"); //$NON-NLS-1$
- writer.write(" int var; \n"); //$NON-NLS-1$
- writer.write(" { \n"); //$NON-NLS-1$
- writer.write(" float var; \n"); //$NON-NLS-1$
- writer.write(" v \n"); //$NON-NLS-1$
- writer.write(" } \n"); //$NON-NLS-1$
- writer.write("} \n"); //$NON-NLS-1$
+ StringBuilder buf = new StringBuilder();
+ buf.append("void foo(){ \n"); //$NON-NLS-1$
+ buf.append(" int var; \n"); //$NON-NLS-1$
+ buf.append(" { \n"); //$NON-NLS-1$
+ buf.append(" float var; \n"); //$NON-NLS-1$
+ buf.append(" v \n"); //$NON-NLS-1$
+ buf.append(" } \n"); //$NON-NLS-1$
+ buf.append("} \n"); //$NON-NLS-1$
- String code = writer.toString();
- IFile cu = importFile( "t.cpp", code ); //$NON-NLS-1$
- ICompletionProposal [] results = getResults( cu, code.indexOf( "v " ) + 1 ); //$NON-NLS-1$
+ String code = buf.toString();
+ IFile cu = importFile("t.cpp", code); //$NON-NLS-1$
+ ICompletionProposal[] results = getResults(cu, code.indexOf("v ") + 1); //$NON-NLS-1$
- assertEquals( results.length, 3 );
- assertEquals( results[0].getDisplayString(), "var : float" ); //$NON-NLS-1$
- assertEquals( results[1].getDisplayString(), "virtual" ); //$NON-NLS-1$
- assertEquals( results[2].getDisplayString(), "volatile" ); //$NON-NLS-1$
+ assertEquals(results.length, 3);
+ assertEquals(results[0].getDisplayString(), "var : float"); //$NON-NLS-1$
+ assertEquals(results[1].getDisplayString(), "virtual"); //$NON-NLS-1$
+ assertEquals(results[2].getDisplayString(), "volatile"); //$NON-NLS-1$
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ProposalFilterPreferencesTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ProposalFilterPreferencesTest.java
index 1016f48e0d1..3b3738b3bb8 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ProposalFilterPreferencesTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ProposalFilterPreferencesTest.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Norbert Ploett (Seimens) - Initial Contribution
+ * Norbert Ploett (Seimens) - Initial Contribution
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist;
@@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
public class ProposalFilterPreferencesTest extends TestCase {
public void testPreferences() {
- // Check that the test filter is among the filternames
+ // Check that the test filter is among the filter names.
String[] filterNames = ProposalFilterPreferencesUtil.getProposalFilterNames();
int index = -1 ;
for (int i = 0; i < filterNames.length; i++) {
@@ -44,7 +44,7 @@ public class ProposalFilterPreferencesTest extends TestCase {
String filterComboStateString = store.getString(ContentAssistPreference.PROPOSALS_FILTER);
ProposalFilterPreferencesUtil.ComboState state = ProposalFilterPreferencesUtil.getComboState(filterComboStateString);
StringBuffer newStateText = new StringBuffer();
- newStateText.append(index+1); // First entry is always the
* Subclasses may extend:
* null
, the replacement string will be taken as display string.
+ * If set to {@code null}, the replacement string will be taken as display string.
*/
public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance) {
this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, null);
@@ -99,8 +96,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* @param replacementLength the length of the text to be replaced
* @param image the image to display for this proposal
* @param displayString the string to be displayed for the proposal
- * @param viewer the text viewer for which this proposal is computed, may be null
- * If set to null
, the replacement string will be taken as display string.
+ * @param viewer the text viewer for which this proposal is computed, may be {@code null}
+ * If set to {@code null}, the replacement string will be taken as display string.
*/
public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance, ITextViewer viewer) {
this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, viewer);
@@ -115,8 +112,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* @param image the image to display for this proposal
* @param displayString the string to be displayed for the proposal
* @param idString the string to be uniquely identify this proposal
- * @param viewer the text viewer for which this proposal is computed, may be null
- * If set to null
, the replacement string will be taken as display string.
+ * @param viewer the text viewer for which this proposal is computed, may be {@code null}
+ * If set to {@code null}, the replacement string will be taken as display string.
*/
public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, String idString, int relevance, ITextViewer viewer) {
Assert.isNotNull(replacementString);
@@ -160,7 +157,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
/**
* Sets the proposal info.
- * @param proposalInfo The additional information associated with this proposal or null
+ * @param proposalInfo The additional information associated with this proposal or {@code null}
*/
public void setAdditionalProposalInfo(String proposalInfo) {
fProposalInfo= proposalInfo;
@@ -174,12 +171,9 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
public void setCursorPosition(int cursorPosition) {
Assert.isTrue(cursorPosition >= 0);
fCursorPosition= cursorPosition;
- fContextInformationPosition= (fContextInformation != null ? fCursorPosition : -1);
+ fContextInformationPosition= fContextInformation != null ? fCursorPosition : -1;
}
- /*
- * @see ICompletionProposalExtension#apply(IDocument, char, int)
- */
@Override
public void apply(IDocument document, char trigger, int offset) {
try {
@@ -192,7 +186,7 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
if (trigger == (char) 0) {
string= fReplacementString;
} else {
- StringBuffer buffer= new StringBuffer(fReplacementString);
+ StringBuilder buffer= new StringBuilder(fReplacementString);
// fix for PR #5533. Assumes that no eating takes place.
if ((fCursorPosition > 0 && fCursorPosition <= buffer.length() && buffer.charAt(fCursorPosition - 1) != trigger)) {
@@ -233,9 +227,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
ui.enter();
}
}
-
} catch (BadLocationException x) {
- // ignore
+ // Ignore
}
}
@@ -243,7 +236,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* A class to simplify tracking a reference position in a document.
*/
private static final class ReferenceTracker {
-
/** The reference position category name. */
private static final String CATEGORY= "reference_position"; //$NON-NLS-1$
/** The position updater of the reference position. */
@@ -255,7 +247,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* Called before document changes occur. It must be followed by a call to postReplace().
*
* @param document the document on which to track the reference position.
- *
*/
public void preReplace(IDocument document, int offset) throws BadLocationException {
fPosition.setOffset(offset);
@@ -263,9 +254,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
document.addPositionCategory(CATEGORY);
document.addPositionUpdater(fPositionUpdater);
document.addPosition(CATEGORY, fPosition);
-
} catch (BadPositionCategoryException e) {
- // should not happen
+ // Should not happen
CUIPlugin.log(e);
}
}
@@ -280,9 +270,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
document.removePosition(CATEGORY, fPosition);
document.removePositionUpdater(fPositionUpdater);
document.removePositionCategory(CATEGORY);
-
} catch (BadPositionCategoryException e) {
- // should not happen
+ // Should not happen
CUIPlugin.log(e);
}
return fPosition.getOffset();
@@ -290,19 +279,14 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
protected static class ExitPolicy implements IExitPolicy {
-
final char fExitCharacter;
public ExitPolicy(char exitCharacter) {
fExitCharacter= exitCharacter;
}
- /*
- * @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
- */
@Override
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {
-
if (event.character == fExitCharacter) {
if (environment.anyPositionContains(offset))
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
@@ -318,7 +302,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return null;
}
}
-
}
// #6410 - File unchanged but dirtied by code assist
@@ -335,33 +318,21 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
apply(document, (char) 0, fReplacementOffset + fReplacementLength);
}
- /*
- * @see ICompletionProposal#getSelection
- */
@Override
public Point getSelection(IDocument document) {
return new Point(fReplacementOffset + fCursorPosition, 0);
}
- /*
- * @see ICompletionProposal#getContextInformation()
- */
@Override
public IContextInformation getContextInformation() {
return fContextInformation;
}
- /*
- * @see ICompletionProposal#getImage()
- */
@Override
public Image getImage() {
return fImage;
}
- /*
- * @see ICompletionProposal#getDisplayString()
- */
@Override
public String getDisplayString() {
return fDisplayString;
@@ -377,9 +348,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return fIdString;
}
- /*
- * @see ICompletionProposal#getAdditionalProposalInfo()
- */
@Override
public String getAdditionalProposalInfo() {
if (fProposalInfo != null) {
@@ -388,17 +356,11 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return null;
}
- /*
- * @see ICompletionProposalExtension#getTriggerCharacters()
- */
@Override
public char[] getTriggerCharacters() {
return fTriggerCharacters;
}
- /*
- * @see ICompletionProposalExtension#getContextInformationPosition()
- */
@Override
public int getContextInformationPosition() {
return fReplacementOffset + fContextInformationPosition;
@@ -412,9 +374,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return fReplacementOffset;
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getCompletionOffset()
- */
@Override
public int getPrefixCompletionStart(IDocument document, int completionOffset) {
return getReplacementOffset();
@@ -454,9 +413,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return fReplacementString;
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getReplacementText()
- */
@Override
public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
String string= getReplacementString();
@@ -482,27 +438,20 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
fImage= image;
}
- /*
- * @see ICompletionProposalExtension#isValidFor(IDocument, int)
- */
@Override
public boolean isValidFor(IDocument document, int offset) {
return validate(document, offset, null);
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
- */
@Override
public boolean validate(IDocument document, int offset, DocumentEvent event) {
-
if (offset < fReplacementOffset)
return false;
boolean validated= match(document, offset, fReplacementString);
if (validated && event != null) {
- // adapt replacement range to document change
+ // Adapt replacement range to document change
int delta= (event.fText == null ? 0 : event.fText.length()) - event.fLength;
fReplacementLength += delta;
}
@@ -528,8 +477,8 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
/**
- * Returns true
if a words matches the code completion prefix in the document,
- * false
otherwise.
+ * Returns {@code true} if a words matches the code completion prefix in the document,
+ * {@code false} otherwise.
*/
protected boolean match(IDocument document, int offset, String word) {
if (word == null)
@@ -554,15 +503,11 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return preference.getBoolean(ContentAssistPreference.AUTOINSERT);
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension1#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
- */
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
-
IDocument document= viewer.getDocument();
- // don't eat if not in preferences, XOR with modifier key 1 (Ctrl)
+ // Don't eat if not in preferences, XOR with modifier key 1 (Ctrl)
// but: if there is a selection, replace it!
Point selection= viewer.getSelectedRange();
fToggleEating= (stateMask & SWT.MOD1) != 0;
@@ -574,7 +519,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
private static Color getForegroundColor(StyledText text) {
-
IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
RGB rgb= PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_FOREGROUND);
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
@@ -582,7 +526,6 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
}
private static Color getBackgroundColor(StyledText text) {
-
IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
RGB rgb= PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_BACKGROUND);
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
@@ -592,27 +535,24 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
private void repairPresentation(ITextViewer viewer) {
if (fRememberedStyleRange != null) {
if (viewer instanceof ITextViewerExtension2) {
- // attempts to reduce the redraw area
+ // Attempts to reduce the redraw area
ITextViewerExtension2 viewer2= (ITextViewerExtension2) viewer;
if (viewer instanceof ITextViewerExtension5) {
-
ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
IRegion widgetRange= extension.modelRange2WidgetRange(new Region(fRememberedStyleRange.start, fRememberedStyleRange.length));
if (widgetRange != null)
viewer2.invalidateTextPresentation(widgetRange.getOffset(), widgetRange.getLength());
-
} else {
viewer2.invalidateTextPresentation(fRememberedStyleRange.start + viewer.getVisibleRegion().getOffset(), fRememberedStyleRange.length);
}
-
- } else
+ } else {
viewer.invalidateTextPresentation();
+ }
}
}
private void updateStyle(ITextViewer viewer) {
-
StyledText text= viewer.getTextWidget();
if (text == null || text.isDisposed())
return;
@@ -649,36 +589,27 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
try {
text.setStyleRange(fRememberedStyleRange);
} catch (IllegalArgumentException x) {
- // catching exception as offset + length might be outside of the text widget
+ // Catching exception as offset + length might be outside of the text widget
fRememberedStyleRange= null;
}
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(ITextViewer, boolean)
- */
@Override
public void selected(ITextViewer viewer, boolean smartToggle) {
- if (!insertCompletion() ^ smartToggle)
+ if (!insertCompletion() ^ smartToggle) {
updateStyle(viewer);
- else {
+ } else {
repairPresentation(viewer);
fRememberedStyleRange= null;
}
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(ITextViewer)
- */
@Override
public void unselected(ITextViewer viewer) {
repairPresentation(viewer);
fRememberedStyleRange= null;
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
- */
@Override
public IInformationControlCreator getInformationControlCreator() {
return null;
@@ -692,22 +623,15 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
setReplacementLength(length);
}
- /*
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
return fIdString.hashCode();
}
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object other) {
if(!(other instanceof ICCompletionProposal))
return false;
return fIdString.equalsIgnoreCase(((ICCompletionProposal)other).getIdString());
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
index 5845ff6eb32..72db7a0dbec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
@@ -38,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IPointerType;
-
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
@@ -55,17 +54,17 @@ import org.eclipse.cdt.internal.ui.text.Symbols;
public class CContentAssistProcessor extends ContentAssistProcessor {
private static class ActivationSet {
- private final String theSet;
+ private final String set;
ActivationSet(String s) {
- theSet = s;
+ set = s;
}
boolean contains(char c) {
- return -1 != theSet.indexOf(c);
+ return -1 != set.indexOf(c);
}
}
-
+
/**
* A wrapper for {@link ICompetionProposal}s.
*/
@@ -76,65 +75,41 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
fWrappedProposal= proposal;
}
- /*
- * @see org.eclipse.cdt.ui.text.ICCompletionProposal#getIdString()
- */
@Override
public String getIdString() {
return fWrappedProposal.getDisplayString();
}
- /*
- * @see org.eclipse.cdt.ui.text.ICCompletionProposal#getRelevance()
- */
@Override
public int getRelevance() {
return RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
@Override
public void apply(IDocument document) {
throw new UnsupportedOperationException();
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
@Override
public String getAdditionalProposalInfo() {
return fWrappedProposal.getAdditionalProposalInfo();
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
@Override
public IContextInformation getContextInformation() {
return fWrappedProposal.getContextInformation();
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
@Override
public String getDisplayString() {
return fWrappedProposal.getDisplayString();
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
@Override
public Image getImage() {
return fWrappedProposal.getImage();
}
- /*
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
@Override
public Point getSelection(IDocument document) {
return fWrappedProposal.getSelection(document);
@@ -158,9 +133,6 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
fEditor= editor;
}
- /*
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
@Override
public IContextInformationValidator getContextInformationValidator() {
if (fValidator == null) {
@@ -169,43 +141,40 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
return fValidator;
}
- /*
- * @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#filterAndSort(List, IProgressMonitor)
- */
@Override
protected Listnull
if none specified. */
+ /** The image descriptor for this category, or {@code null} if none specified. */
private final ImageDescriptor fImage;
private boolean fIsSeparateCommand= true;
@@ -57,7 +57,7 @@ public final class CompletionProposalCategory {
private final CompletionProposalComputerRegistry fRegistry;
private int fSortOrder= 0x10000;
- private String fLastError= null;
+ private String fLastError;
CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException {
fElement= element;
@@ -66,10 +66,11 @@ public final class CompletionProposalCategory {
fId= parent.getUniqueIdentifier();
checkNotNull(fId, "id"); //$NON-NLS-1$
String name= parent.getLabel();
- if (name == null)
+ if (name == null) {
fName= fId;
- else
+ } else {
fName= name;
+ }
String icon= element.getAttribute(ICON);
ImageDescriptor img= null;
@@ -100,11 +101,11 @@ public final class CompletionProposalCategory {
}
/**
- * Checks that the given attribute value is not null
.
+ * Checks that the given attribute value is not {@code null}.
*
* @param value the element to be checked
* @param attribute the attribute
- * @throws CoreException if value
is null
+ * @throws CoreException if {@code value} is {@code null}
*/
private void checkNotNull(Object obj, String attribute) throws CoreException {
if (obj == null) {
@@ -195,10 +196,10 @@ public final class CompletionProposalCategory {
}
/**
- * Returns true
if the category contains any computers, false
+ * Returns {@code true} if the category contains any computers, {@code false}
* otherwise.
*
- * @return true
if the category contains any computers, false
+ * @return {@code true} if the category contains any computers, {@code false}
* otherwise
*/
public boolean hasComputers() {
@@ -211,12 +212,11 @@ public final class CompletionProposalCategory {
}
/**
- * Returns true
if the category contains any computers in the given partition, false
- * otherwise.
+ * Returns {@code true} if the category contains any computers in the given partition,
+ * {@code false} otherwise.
*
* @param partition the partition
- * @return true
if the category contains any computers, false
- * otherwise
+ * @return {@code true} if the category contains any computers, {@code false} otherwise
*/
public boolean hasComputers(String partition) {
Listorg.eclipse.cdt.ui.completionProposalComputer
extension point.
+ * {@link org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer}s contributed via
+ * the {@code org.eclipse.cdt.ui.completionProposalComputer} extension point.
*
- *
- * createContext
to provide the context object passed to the computerscreateProgressMonitor
to change the way progress is reportedfilterAndSort
to add sorting and filteringgetContextInformationValidator
to add context validation (needed if any
+ * getErrorMessage
to change error reporting
- * The default implementation always returns true
.
- *
true
if auto activation is allowed
+ * @return {@code true} if auto activation is allowed
*/
protected boolean verifyAutoActivation(ITextViewer viewer, int offset) {
return true;
@@ -254,7 +252,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
}
private List
- * The default implementation creates a
- * NullProgressMonitor
.
- *
null
if no completion is possible
+ * @return the context to be passed to the computers,
+ * or {@code null} if no completion is possible
*/
protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset, boolean isCompletion) {
return new ContentAssistInvocationContext(viewer, offset);
@@ -397,7 +390,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
/**
* Test whether the current session was auto-activated.
*
- * @return true
if the current session was auto-activated.
+ * @return {@code true} if the current session was auto-activated.
*/
protected boolean isAutoActivated() {
return fIsAutoActivated;
@@ -418,7 +411,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
}
private List