You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-06-15 15:24:05
|
Revision: 2622
http://svn.sourceforge.net/rubyeclipse/?rev=2622&view=rev
Author: cawilliams
Date: 2007-06-15 08:24:00 -0700 (Fri, 15 Jun 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/UnecessaryElseVisitor.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/UnecessaryElseVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/UnecessaryElseVisitor.java 2007-06-15 15:12:21 UTC (rev 2621)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/UnecessaryElseVisitor.java 2007-06-15 15:24:00 UTC (rev 2622)
@@ -50,6 +50,7 @@
}
private boolean alwaysExplicitReturn(Node body) {
+ if (body == null) return false;
ReturnVisitor visitor = new ReturnVisitor();
body.accept(visitor);
return visitor.alwaysExplicit();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-15 15:12:24
|
Revision: 2621
http://svn.sourceforge.net/rubyeclipse/?rev=2621&view=rev
Author: cawilliams
Date: 2007-06-15 08:12:21 -0700 (Fri, 15 Jun 2007)
Log Message:
-----------
Trac ticket #4366 - Auto de-indent else, when, ensure, rescue, end, elsif
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-06-14 21:36:41 UTC (rev 2620)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-06-15 15:12:21 UTC (rev 2621)
@@ -17,7 +17,6 @@
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.corext.util.CodeFormatterUtil;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
-import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
import org.rubypeople.rdt.internal.ui.text.RubyHeuristicScanner;
import org.rubypeople.rdt.internal.ui.text.RubyIndenter;
import org.rubypeople.rdt.ui.PreferenceConstants;
@@ -94,14 +93,29 @@
ITypedRegion region= TextUtilities.getPartition(d, fPartitioning, start, true);
// if (IRubyPartitions.RUBY_DOC.equals(region.getType()))
// start= d.getLineInformationOfOffset(region.getOffset()).getOffset();
- // If we're hitting return at the end of the line of a new block, add indent
- if (atStartOfBlock(getTrimmedLine(d, start, c.offset))) {
+ // if
+ String trimmed = getTrimmedLine(d, start, c.offset);
+ if (shouldDeIndent(trimmed)) {
+ IRegion previousLineRegion = d.getLineInformation(line - 1);
+ String previousIndent= indenter.computeIndentation(previousLineRegion.getOffset()).toString();
+ // FIXME This all assumes spaces!
+ String unindented = previousIndent.substring(0, previousIndent.length() - CodeFormatterUtil.createIndentString(1, fProject).length());
+ if (!unindented.equals(indent.toString())) {
+ d.replace(start, c.offset - start, unindented + trimmed);
+ int shift = previousIndent.length() - unindented.length();
+ c.offset = c.offset - shift;
+ if (trimmed.equals(BLOCK_CLOSER)) // if we're closing the block, remove an indent unit
+ buf.delete(buf.length() - shift, buf.length());
+ }
+ }
+// If we're hitting return at the end of the line of a new block, add indent
+ if (atStartOfBlock(trimmed)) {
buf.append(CodeFormatterUtil.createIndentString(1, fProject));
c.caretOffset= c.offset + buf.length();
c.shiftsCaret= false;
}
// insert closing "end" on new line after an unclosed block
- if (closeBlock() && unclosedBlock(d, start, c.offset)) {
+ if (closeBlock() && unclosedBlock(d, trimmed, c.offset)) {
// copy old content of line behind insertion point to new line
if (c.offset == 0) {
if (lineEnd - contentStart > 0) {
@@ -121,14 +135,16 @@
}
}
- private boolean unclosedBlock(IDocument d, int start, int offset) {
+ private boolean shouldDeIndent(String trimmed) {
+ if (trimmed == null || trimmed.length() == 0) return false;
+ return trimmed.equals("rescue") || trimmed.equals("else") || trimmed.equals("ensure") || trimmed.equals(BLOCK_CLOSER)
+ || trimmed.startsWith("when ") || trimmed.startsWith("elsif ");
+ }
+
+ private boolean unclosedBlock(IDocument d, String trimmed, int offset) {
// FIXME wow is this ugly! There has to be an easier way to tell if there's an unclosed block besides parsing and catching a syntaxError!
- try {
- if (!atStartOfBlock(getTrimmedLine(d, start, offset))) {
- return false;
- }
- } catch (BadLocationException e1) {
- RubyPlugin.log(e1);
+ if (!atStartOfBlock(trimmed)) {
+ return false;
}
RubyParser parser = new RubyParser();
@@ -140,7 +156,7 @@
return true;
try {
StringBuffer buffer = new StringBuffer(d.get());
- buffer.insert(offset, "\n" + BLOCK_CLOSER);
+ buffer.insert(offset, TextUtilities.getDefaultLineDelimiter(d) + BLOCK_CLOSER);
parser.parse(buffer.toString());
} catch (SyntaxException syntaxException) {
return false;
@@ -152,8 +168,7 @@
private String getTrimmedLine(IDocument d, int start, int offset) throws BadLocationException {
String line = d.get(start, offset - start);
- line = line.trim();
- return line;
+ return line.trim();
}
private boolean atStartOfBlock(String line) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-14 21:36:43
|
Revision: 2620
http://svn.sourceforge.net/rubyeclipse/?rev=2620&view=rev
Author: cawilliams
Date: 2007-06-14 14:36:41 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyPartitions.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyPartitions.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyPartitions.java 2007-06-14 19:35:27 UTC (rev 2619)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyPartitions.java 2007-06-14 21:36:41 UTC (rev 2620)
@@ -26,4 +26,14 @@
* The identifier multi-line comment partition content type.
*/
String RUBY_MULTI_LINE_COMMENT= "__ruby_multiline_comment"; //$NON-NLS-1$
+
+ /**
+ * The identifier regular expression partition content type.
+ */
+ String RUBY_REGULAR_EXPRESSION= "__ruby_regular_expression"; //$NON-NLS-1$
+
+ /**
+ * The identifier string partition content type.
+ */
+ String RUBY_STRING= "__ruby_string"; //$NON-NLS-1$
}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyScanner.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SingleTokenRubyScanner.java 2007-06-14 21:36:41 UTC (rev 2620)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.rubypeople.rdt.ui.text.IColorManager;
+
+
+/**
+ *
+ */
+public final class SingleTokenRubyScanner extends AbstractRubyScanner {
+
+ private String[] fProperty;
+
+ public SingleTokenRubyScanner(IColorManager manager, IPreferenceStore store, String property) {
+ super(manager, store);
+ fProperty= new String[] { property };
+ initialize();
+ }
+
+ /*
+ * @see AbstractRubyScanner#getTokenProperties()
+ */
+ protected String[] getTokenProperties() {
+ return fProperty;
+ }
+
+ /*
+ * @see AbstractRubyScanner#createRules()
+ */
+ protected List createRules() {
+ setDefaultReturnToken(getToken(fProperty[0]));
+ return null;
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-14 19:35:37
|
Revision: 2619
http://svn.sourceforge.net/rubyeclipse/?rev=2619&view=rev
Author: cawilliams
Date: 2007-06-14 12:35:27 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
remove default visibility
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/MembersOrderPreferenceCache.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/MembersOrderPreferenceCache.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/MembersOrderPreferenceCache.java 2007-06-14 19:18:46 UTC (rev 2618)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/MembersOrderPreferenceCache.java 2007-06-14 19:35:27 UTC (rev 2619)
@@ -34,8 +34,7 @@
private static final int PUBLIC_INDEX= 0;
private static final int PRIVATE_INDEX= 1;
private static final int PROTECTED_INDEX= 2;
- private static final int DEFAULT_INDEX= 3;
- private static final int N_VISIBILITIES= DEFAULT_INDEX + 1;
+ private static final int N_VISIBILITIES= PROTECTED_INDEX + 1;
private int[] fCategoryOffsets= null;
@@ -130,7 +129,7 @@
if (fVisibilityOffsets == null) {
fVisibilityOffsets= getVisibilityOffsets();
}
- int kind= DEFAULT_INDEX;
+ int kind= PUBLIC_INDEX;
if (Flags.isPublic(modifierFlags)) {
kind= PUBLIC_INDEX;
} else if (Flags.isProtected(modifierFlags)) {
@@ -165,9 +164,7 @@
offsets[PRIVATE_INDEX]= i++;
} else if ("R".equals(token)) { //$NON-NLS-1$
offsets[PROTECTED_INDEX]= i++;
- } else if ("D".equals(token)) { //$NON-NLS-1$
- offsets[DEFAULT_INDEX]= i++;
- }
+ }
}
return i == N_VISIBILITIES;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-14 19:18:48
|
Revision: 2618
http://svn.sourceforge.net/rubyeclipse/?rev=2618&view=rev
Author: cawilliams
Date: 2007-06-14 12:18:46 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
renamed old CodeComplexityVisitor to TooManyLocalsVisitor since it's been split/gutted out to only do that now
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java
trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_CodeComplexity.java
Added Paths:
-----------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLocalsVisitor.java
Removed Paths:
-------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java
Deleted: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java 2007-06-14 19:16:55 UTC (rev 2617)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java 2007-06-14 19:18:46 UTC (rev 2618)
@@ -1,77 +0,0 @@
-package com.aptana.rdt.internal.parser.warnings;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jruby.ast.DefnNode;
-import org.jruby.ast.DefsNode;
-import org.jruby.ast.LocalAsgnNode;
-import org.jruby.evaluator.Instruction;
-import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
-
-import com.aptana.rdt.AptanaRDTPlugin;
-
-public class CodeComplexityVisitor extends RubyLintVisitor {
-
-
- private int maxLocals;
- private Set locals;
- private Map fOptions;
-
- public CodeComplexityVisitor(String contents) {
- this(AptanaRDTPlugin.getDefault().getOptions(), contents);
- }
-
- public CodeComplexityVisitor(Map options, String contents) {
- super(contents);
- fOptions = options;
- maxLocals = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_LOCALS, 4);
- }
- private int getInt(String key, int defaultValue) {
- try {
- return Integer.parseInt((String) fOptions.get(key));
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- @Override
- protected String getOptionKey() {
- return AptanaRDTPlugin.COMPILER_PB_MAX_LOCALS;
- }
-
- @Override
- public Instruction visitDefsNode(DefsNode iVisited) {
- locals = new HashSet();
- return super.visitDefsNode(iVisited);
- }
-
- @Override
- public Instruction visitDefnNode(DefnNode iVisited) {
- locals = new HashSet();
- return super.visitDefnNode(iVisited);
- }
-
- @Override
- public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
- locals.add(iVisited.getName());
- return super.visitLocalAsgnNode(iVisited);
- }
-
- public void exitDefnNode(DefnNode iVisited) {
- if (locals.size() > maxLocals) {
- createProblem(iVisited.getNameNode().getPosition(), "Too many local variables: " + locals.size());
- }
- locals.clear();
- }
-
- @Override
- public void exitDefsNode(DefsNode iVisited) {
- if (locals.size() > maxLocals) {
- createProblem(iVisited.getNameNode().getPosition(), "Too many local variables: " + locals.size());
- }
- locals.clear();
- super.exitDefsNode(iVisited);
- }
-}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java 2007-06-14 19:16:55 UTC (rev 2617)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java 2007-06-14 19:18:46 UTC (rev 2618)
@@ -72,7 +72,7 @@
visitors.add(new LocalsMaskingMethodsVisitor(contents));
visitors.add(new UnusedParameterVisitor(contents));
visitors.add(new UnecessaryElseVisitor(contents));
- visitors.add(new CodeComplexityVisitor(contents));
+ visitors.add(new TooManyLocalsVisitor(contents));
visitors.add(new TooManyLinesVisitor(contents));
visitors.add(new TooManyBranchesVisitor(contents));
visitors.add(new TooManyArgumentsVisitor(contents));
Copied: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLocalsVisitor.java (from rev 2617, trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java)
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLocalsVisitor.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLocalsVisitor.java 2007-06-14 19:18:46 UTC (rev 2618)
@@ -0,0 +1,77 @@
+package com.aptana.rdt.internal.parser.warnings;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.LocalAsgnNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
+
+import com.aptana.rdt.AptanaRDTPlugin;
+
+public class TooManyLocalsVisitor extends RubyLintVisitor {
+
+
+ private int maxLocals;
+ private Set locals;
+ private Map fOptions;
+
+ public TooManyLocalsVisitor(String contents) {
+ this(AptanaRDTPlugin.getDefault().getOptions(), contents);
+ }
+
+ public TooManyLocalsVisitor(Map options, String contents) {
+ super(contents);
+ fOptions = options;
+ maxLocals = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_LOCALS, 4);
+ }
+ private int getInt(String key, int defaultValue) {
+ try {
+ return Integer.parseInt((String) fOptions.get(key));
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ protected String getOptionKey() {
+ return AptanaRDTPlugin.COMPILER_PB_MAX_LOCALS;
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ locals = new HashSet();
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ locals = new HashSet();
+ return super.visitDefnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
+ locals.add(iVisited.getName());
+ return super.visitLocalAsgnNode(iVisited);
+ }
+
+ public void exitDefnNode(DefnNode iVisited) {
+ if (locals.size() > maxLocals) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many local variables: " + locals.size());
+ }
+ locals.clear();
+ }
+
+ @Override
+ public void exitDefsNode(DefsNode iVisited) {
+ if (locals.size() > maxLocals) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many local variables: " + locals.size());
+ }
+ locals.clear();
+ super.exitDefsNode(iVisited);
+ }
+}
Modified: trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_CodeComplexity.java
===================================================================
--- trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_CodeComplexity.java 2007-06-14 19:16:55 UTC (rev 2617)
+++ trunk/com.aptana.rdt.tests/src/com/aptana/rdt/internal/core/parser/warnings/TC_CodeComplexity.java 2007-06-14 19:18:46 UTC (rev 2618)
@@ -2,7 +2,7 @@
import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
-import com.aptana.rdt.internal.parser.warnings.CodeComplexityVisitor;
+import com.aptana.rdt.internal.parser.warnings.TooManyLocalsVisitor;
public class TC_CodeComplexity extends WarningVisitorTest {
@@ -11,7 +11,7 @@
@Override
protected RubyLintVisitor createVisitor(String code) {
- return new CodeComplexityVisitor(code);
+ return new TooManyLocalsVisitor(code);
}
// TODO Add tests for max branches
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-14 19:16:57
|
Revision: 2617
http://svn.sourceforge.net/rubyeclipse/?rev=2617&view=rev
Author: cawilliams
Date: 2007-06-14 12:16:55 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
break out each thing we track in code complexity into separate visitor. This way the getOptionKey() method works and all of them aren't pegged to the severity of one key.
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java
Added Paths:
-----------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyArgumentsVisitor.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyBranchesVisitor.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLinesVisitor.java
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyReturnsVisitor.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java 2007-06-13 19:09:54 UTC (rev 2616)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/CodeComplexityVisitor.java 2007-06-14 19:16:55 UTC (rev 2617)
@@ -4,29 +4,18 @@
import java.util.Map;
import java.util.Set;
-import org.jruby.ast.CaseNode;
import org.jruby.ast.DefnNode;
-import org.jruby.ast.IfNode;
+import org.jruby.ast.DefsNode;
import org.jruby.ast.LocalAsgnNode;
-import org.jruby.ast.ReturnNode;
-import org.jruby.ast.WhenNode;
import org.jruby.evaluator.Instruction;
-import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
-import org.rubypeople.rdt.internal.core.util.ASTUtil;
import com.aptana.rdt.AptanaRDTPlugin;
public class CodeComplexityVisitor extends RubyLintVisitor {
- private int maxArgLength;
- private int maxLines;
- private int maxReturns;
- private int maxBranches;
+
private int maxLocals;
- private int returnCount;
- private int branchCount;
private Set locals;
private Map fOptions;
@@ -37,13 +26,7 @@
public CodeComplexityVisitor(Map options, String contents) {
super(contents);
fOptions = options;
- maxArgLength = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_ARGUMENTS, 5);
- maxLines = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_LINES, 20);
- maxReturns = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_RETURNS, 5);
- maxBranches = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_BRANCHES, 5);
maxLocals = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_LOCALS, 4);
- returnCount = 0;
- branchCount = 0;
}
private int getInt(String key, int defaultValue) {
try {
@@ -55,75 +38,40 @@
@Override
protected String getOptionKey() {
- // TODO Break this visitor up into multiple! One for each key.
- return AptanaRDTPlugin.COMPILER_PB_MAX_ARGUMENTS;
+ return AptanaRDTPlugin.COMPILER_PB_MAX_LOCALS;
}
@Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ locals = new HashSet();
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
public Instruction visitDefnNode(DefnNode iVisited) {
- returnCount = 0;
- branchCount = 0;
locals = new HashSet();
-
- String[] args = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
- if (args != null && args.length > maxArgLength) {
- createProblem(iVisited.getArgsNode().getPosition(), "Too many method arguments: " + args.length);
- }
- ISourcePosition pos = iVisited.getPosition();
- int lines = (pos.getEndLine() - pos.getStartLine()) - 1;
- if (lines > maxLines) {
- createProblem(iVisited.getNameNode().getPosition(), "Too many lines in method: " + lines);
- }
return super.visitDefnNode(iVisited);
}
@Override
- public Instruction visitIfNode(IfNode iVisited) {
- // TODO Make sure this doesn't count modifiers
- if (iVisited.getThenBody() != null) {
- branchCount++;
- }
- if (iVisited.getElseBody() != null) {
- branchCount++;
- }
- return super.visitIfNode(iVisited);
- }
-
- @Override
- public Instruction visitCaseNode(CaseNode iVisited) {
- WhenNode when = (WhenNode) iVisited.getFirstWhenNode();
- while (when != null) {
- branchCount++;
- when = (WhenNode) when.getNextCase();
- }
- return super.visitCaseNode(iVisited);
- }
-
- @Override
public Instruction visitLocalAsgnNode(LocalAsgnNode iVisited) {
locals.add(iVisited.getName());
return super.visitLocalAsgnNode(iVisited);
}
public void exitDefnNode(DefnNode iVisited) {
- if (returnCount > maxReturns) {
- createProblem(iVisited.getNameNode().getPosition(), "Too many explicit returns: " + returnCount);
- }
- if (branchCount > maxBranches) {
- createProblem(iVisited.getNameNode().getPosition(), "Too many branches: " + branchCount);
- }
if (locals.size() > maxLocals) {
createProblem(iVisited.getNameNode().getPosition(), "Too many local variables: " + locals.size());
}
- returnCount = 0;
- branchCount = 0;
locals.clear();
}
-
+
@Override
- public Instruction visitReturnNode(ReturnNode iVisited) {
- returnCount++;
- return super.visitReturnNode(iVisited);
+ public void exitDefsNode(DefsNode iVisited) {
+ if (locals.size() > maxLocals) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many local variables: " + locals.size());
+ }
+ locals.clear();
+ super.exitDefsNode(iVisited);
}
-
}
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java 2007-06-13 19:09:54 UTC (rev 2616)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/RubyRedLint.java 2007-06-14 19:16:55 UTC (rev 2617)
@@ -73,6 +73,10 @@
visitors.add(new UnusedParameterVisitor(contents));
visitors.add(new UnecessaryElseVisitor(contents));
visitors.add(new CodeComplexityVisitor(contents));
+ visitors.add(new TooManyLinesVisitor(contents));
+ visitors.add(new TooManyBranchesVisitor(contents));
+ visitors.add(new TooManyArgumentsVisitor(contents));
+ visitors.add(new TooManyReturnsVisitor(contents));
visitors.add(new SimilarVariableNameVisitor(contents));
visitors.add(new SubclassCallsSuper(contents));
visitors.add(new ComparableInclusionVisitor(contents));
Added: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyArgumentsVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyArgumentsVisitor.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyArgumentsVisitor.java 2007-06-14 19:16:55 UTC (rev 2617)
@@ -0,0 +1,57 @@
+package com.aptana.rdt.internal.parser.warnings;
+
+import java.util.Map;
+
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
+import org.rubypeople.rdt.internal.core.util.ASTUtil;
+
+import com.aptana.rdt.AptanaRDTPlugin;
+
+public class TooManyArgumentsVisitor extends RubyLintVisitor {
+
+ private int maxArgLength;
+ private Map fOptions;
+
+ public TooManyArgumentsVisitor(String contents) {
+ this(AptanaRDTPlugin.getDefault().getOptions(), contents);
+ }
+
+ public TooManyArgumentsVisitor(Map options, String contents) {
+ super(contents);
+ fOptions = options;
+ maxArgLength = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_ARGUMENTS, 5);
+ }
+ private int getInt(String key, int defaultValue) {
+ try {
+ return Integer.parseInt((String) fOptions.get(key));
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ protected String getOptionKey() {
+ return AptanaRDTPlugin.COMPILER_PB_MAX_ARGUMENTS;
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ String[] args = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
+ if (args != null && args.length > maxArgLength) {
+ createProblem(iVisited.getArgsNode().getPosition(), "Too many method arguments: " + args.length);
+ }
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ String[] args = ASTUtil.getArgs(iVisited.getArgsNode(), iVisited.getScope());
+ if (args != null && args.length > maxArgLength) {
+ createProblem(iVisited.getArgsNode().getPosition(), "Too many method arguments: " + args.length);
+ }
+ return super.visitDefnNode(iVisited);
+ }
+}
Added: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyBranchesVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyBranchesVisitor.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyBranchesVisitor.java 2007-06-14 19:16:55 UTC (rev 2617)
@@ -0,0 +1,93 @@
+package com.aptana.rdt.internal.parser.warnings;
+
+import java.util.Map;
+
+import org.jruby.ast.CaseNode;
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.IfNode;
+import org.jruby.ast.WhenNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
+
+import com.aptana.rdt.AptanaRDTPlugin;
+
+public class TooManyBranchesVisitor extends RubyLintVisitor {
+
+ private int maxBranches;
+ private int branchCount;
+ private Map fOptions;
+
+ public TooManyBranchesVisitor(String contents) {
+ this(AptanaRDTPlugin.getDefault().getOptions(), contents);
+ }
+
+ public TooManyBranchesVisitor(Map options, String contents) {
+ super(contents);
+ fOptions = options;
+ maxBranches = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_BRANCHES, 5);
+ branchCount = 0;
+ }
+ private int getInt(String key, int defaultValue) {
+ try {
+ return Integer.parseInt((String) fOptions.get(key));
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ protected String getOptionKey() {
+ return AptanaRDTPlugin.COMPILER_PB_MAX_BRANCHES;
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ branchCount = 0;
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ branchCount = 0;
+ return super.visitDefnNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitIfNode(IfNode iVisited) {
+ // TODO Make sure this doesn't count modifiers
+ if (iVisited.getThenBody() != null) {
+ branchCount++;
+ }
+ if (iVisited.getElseBody() != null) {
+ branchCount++;
+ }
+ return super.visitIfNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitCaseNode(CaseNode iVisited) {
+ WhenNode when = (WhenNode) iVisited.getFirstWhenNode();
+ while (when != null) {
+ branchCount++;
+ when = (WhenNode) when.getNextCase();
+ }
+ return super.visitCaseNode(iVisited);
+ }
+
+ public void exitDefnNode(DefnNode iVisited) {
+ if (branchCount > maxBranches) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many branches: " + branchCount);
+ }
+ branchCount = 0;
+ }
+
+ @Override
+ public void exitDefsNode(DefsNode iVisited) {
+ if (branchCount > maxBranches) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many branches: " + branchCount);
+ }
+ branchCount = 0;
+ super.exitDefsNode(iVisited);
+ }
+}
Added: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLinesVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLinesVisitor.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyLinesVisitor.java 2007-06-14 19:16:55 UTC (rev 2617)
@@ -0,0 +1,59 @@
+package com.aptana.rdt.internal.parser.warnings;
+
+import java.util.Map;
+
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.evaluator.Instruction;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
+
+import com.aptana.rdt.AptanaRDTPlugin;
+
+public class TooManyLinesVisitor extends RubyLintVisitor {
+
+ private int maxLines;
+ private Map fOptions;
+
+ public TooManyLinesVisitor(String contents) {
+ this(AptanaRDTPlugin.getDefault().getOptions(), contents);
+ }
+
+ public TooManyLinesVisitor(Map options, String contents) {
+ super(contents);
+ fOptions = options;
+ maxLines = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_LINES, 20);
+ }
+ private int getInt(String key, int defaultValue) {
+ try {
+ return Integer.parseInt((String) fOptions.get(key));
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ protected String getOptionKey() {
+ return AptanaRDTPlugin.COMPILER_PB_MAX_LINES;
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ ISourcePosition pos = iVisited.getPosition();
+ int lines = (pos.getEndLine() - pos.getStartLine()) - 1;
+ if (lines > maxLines) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many lines in method: " + lines);
+ }
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ ISourcePosition pos = iVisited.getPosition();
+ int lines = (pos.getEndLine() - pos.getStartLine()) - 1;
+ if (lines > maxLines) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many lines in method: " + lines);
+ }
+ return super.visitDefnNode(iVisited);
+ }
+}
Added: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyReturnsVisitor.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyReturnsVisitor.java (rev 0)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/parser/warnings/TooManyReturnsVisitor.java 2007-06-14 19:16:55 UTC (rev 2617)
@@ -0,0 +1,76 @@
+package com.aptana.rdt.internal.parser.warnings;
+
+import java.util.Map;
+
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.ReturnNode;
+import org.jruby.evaluator.Instruction;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
+
+import com.aptana.rdt.AptanaRDTPlugin;
+
+public class TooManyReturnsVisitor extends RubyLintVisitor {
+
+ private int maxReturns;
+ private int returnCount;
+ private Map fOptions;
+
+ public TooManyReturnsVisitor(String contents) {
+ this(AptanaRDTPlugin.getDefault().getOptions(), contents);
+ }
+
+ public TooManyReturnsVisitor(Map options, String contents) {
+ super(contents);
+ fOptions = options;
+ maxReturns = getInt(AptanaRDTPlugin.COMPILER_PB_MAX_RETURNS, 5);
+ returnCount = 0;
+ }
+ private int getInt(String key, int defaultValue) {
+ try {
+ return Integer.parseInt((String) fOptions.get(key));
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ protected String getOptionKey() {
+ return AptanaRDTPlugin.COMPILER_PB_MAX_RETURNS;
+ }
+
+ @Override
+ public Instruction visitDefsNode(DefsNode iVisited) {
+ returnCount = 0;
+ return super.visitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitDefnNode(DefnNode iVisited) {
+ returnCount = 0;
+ return super.visitDefnNode(iVisited);
+ }
+
+ public void exitDefnNode(DefnNode iVisited) {
+ if (returnCount > maxReturns) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many explicit returns: " + returnCount);
+ }
+ returnCount = 0;
+ }
+
+ @Override
+ public void exitDefsNode(DefsNode iVisited) {
+ if (returnCount > maxReturns) {
+ createProblem(iVisited.getNameNode().getPosition(), "Too many explicit returns: " + returnCount);
+ }
+ returnCount = 0;
+ super.exitDefsNode(iVisited);
+ }
+
+ @Override
+ public Instruction visitReturnNode(ReturnNode iVisited) {
+ returnCount++;
+ return super.visitReturnNode(iVisited);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-13 19:09:57
|
Revision: 2616
http://svn.sourceforge.net/rubyeclipse/?rev=2616&view=rev
Author: cawilliams
Date: 2007-06-13 12:09:54 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
add interface for other plugins to get constants used in plugin (like ID of wizard for new test cases).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF
Added Paths:
-----------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/ITestUnitConstants.java
Modified: trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF 2007-06-13 19:04:52 UTC (rev 2615)
+++ trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF 2007-06-13 19:09:54 UTC (rev 2616)
@@ -8,7 +8,8 @@
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.rubypeople.rdt.testunit.launcher,
- org.rubypeople.rdt.testunit.wizards
+ org.rubypeople.rdt.testunit.wizards,
+ org.rubypeople.rdt.testunit
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.debug.core,
Added: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/ITestUnitConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/ITestUnitConstants.java (rev 0)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/ITestUnitConstants.java 2007-06-13 19:09:54 UTC (rev 2616)
@@ -0,0 +1,5 @@
+package org.rubypeople.rdt.testunit;
+
+public interface ITestUnitConstants {
+ public static final String ID_NEW_TESTCASE_WIZARD = "org.rubypeople.rdt.testunit.wizards.RubyNewTestCaseWizard";
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-13 19:05:07
|
Revision: 2615
http://svn.sourceforge.net/rubyeclipse/?rev=2615&view=rev
Author: cawilliams
Date: 2007-06-13 12:04:52 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
add id of new ruby class wizard
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IRubyConstants.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IRubyConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IRubyConstants.java 2007-06-13 18:46:11 UTC (rev 2614)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IRubyConstants.java 2007-06-13 19:04:52 UTC (rev 2615)
@@ -4,7 +4,7 @@
package org.rubypeople.rdt.ui;
/**
- * Externally facing inetrface holding constants for various UI elements. Helps
+ * Externally facing interface holding constants for various UI elements. Helps
* people extend our plugin!
*
*/
@@ -14,5 +14,6 @@
public static final String EDITOR_ID = "org.rubypeople.rdt.ui.EditorRubyFile"; //$NON-NLS-1$
public static final String EXTERNAL_FILES_EDITOR_ID = "org.rubypeople.rdt.ui.ExternalRubyEditor"; //$NON-NLS-1$
public static final String RI_VIEW_ID = "org.rubypeople.rdt.ui.views.RIView"; //$NON-NLS-1$
+ public static final String ID_NEW_CLASS_WIZARD = "org.rubypeople.rdt.ui.wizards.RubyNewClassWizard"; //$NON-NLS-1$
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-13 18:46:14
|
Revision: 2614
http://svn.sourceforge.net/rubyeclipse/?rev=2614&view=rev
Author: cawilliams
Date: 2007-06-13 11:46:11 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
Fix #4818 - we were setting the title using toString on an IRubyElement which spits out ugly info. We should just use the fully qualified name if we have a type, or just call getElementName() if it's not a type.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java 2007-06-13 13:29:14 UTC (rev 2613)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java 2007-06-13 18:46:11 UTC (rev 2614)
@@ -501,8 +501,8 @@
setViewPartTitle(type);
if (type instanceof IType)
setTitleToolTip(((IType)type).getFullyQualifiedName());
-// else
-// setTitleToolTip(type.getElementName());
+ else
+ setTitleToolTip(type.getElementName());
}
protected void aboutToLaunch() {
@@ -596,8 +596,12 @@
String title;
if (type == null)
title = " "; //$NON-NLS-1$
- else
- title = type.toString();
+ else {
+ if (type instanceof IType) {
+ title = ((IType) type).getFullyQualifiedName();
+ } else
+ title = type.getElementName();
+ }
setContentDescription(title);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-13 13:29:16
|
Revision: 2613
http://svn.sourceforge.net/rubyeclipse/?rev=2613&view=rev
Author: cawilliams
Date: 2007-06-13 06:29:14 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
Fix Trac # 4822 - Pressing enter after class definition doesn't indent automatically (on an already closed block, we should still indent)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-06-13 13:10:38 UTC (rev 2612)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-06-13 13:29:14 UTC (rev 2613)
@@ -94,13 +94,14 @@
ITypedRegion region= TextUtilities.getPartition(d, fPartitioning, start, true);
// if (IRubyPartitions.RUBY_DOC.equals(region.getType()))
// start= d.getLineInformationOfOffset(region.getOffset()).getOffset();
-
- // insert closing "end" on new line after an unclosed block
- if (closeBlock() && unclosedBlock(d, start, c.offset)) {
+ // If we're hitting return at the end of the line of a new block, add indent
+ if (atStartOfBlock(getTrimmedLine(d, start, c.offset))) {
buf.append(CodeFormatterUtil.createIndentString(1, fProject));
c.caretOffset= c.offset + buf.length();
c.shiftsCaret= false;
-
+ }
+ // insert closing "end" on new line after an unclosed block
+ if (closeBlock() && unclosedBlock(d, start, c.offset)) {
// copy old content of line behind insertion point to new line
if (c.offset == 0) {
if (lineEnd - contentStart > 0) {
@@ -123,10 +124,7 @@
private boolean unclosedBlock(IDocument d, int start, int offset) {
// FIXME wow is this ugly! There has to be an easier way to tell if there's an unclosed block besides parsing and catching a syntaxError!
try {
- String line = d.get(start, offset - start);
- line = line.trim();
- if (!line.startsWith("class ") && !line.startsWith("if ") && !line.startsWith("module ") && !line.startsWith("unless ")
- && !line.startsWith("def ") && !line.equals("begin") && !openBlockPattern.matcher(line).matches()) {
+ if (!atStartOfBlock(getTrimmedLine(d, start, offset))) {
return false;
}
} catch (BadLocationException e1) {
@@ -152,6 +150,18 @@
return false;
}
+ private String getTrimmedLine(IDocument d, int start, int offset) throws BadLocationException {
+ String line = d.get(start, offset - start);
+ line = line.trim();
+ return line;
+ }
+
+ private boolean atStartOfBlock(String line) {
+ return line.startsWith("class ") || line.startsWith("if ") || line.startsWith("module ")
+ || line.startsWith("unless ") || line.startsWith("def ") || line.equals("begin")
+ || openBlockPattern.matcher(line).matches();
+ }
+
private boolean closeBlock() {
return endStatements;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-13 13:10:39
|
Revision: 2612
http://svn.sourceforge.net/rubyeclipse/?rev=2612&view=rev
Author: cawilliams
Date: 2007-06-13 06:10:38 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
fix Trac ticket #4817 - Background color settings not being applied to syntax coloring of ruby tokens
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorColoringConfigurationBlock.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorColoringConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorColoringConfigurationBlock.java 2007-06-13 13:10:08 UTC (rev 2611)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/RubyEditorColoringConfigurationBlock.java 2007-06-13 13:10:38 UTC (rev 2612)
@@ -367,6 +367,7 @@
for (int i= 0, n= fListModel.size(); i < n; i++) {
HighlightingColorListItem item= (HighlightingColorListItem) fListModel.get(i);
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, item.getColorKey()));
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, item.getBackgroundKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getBoldKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getItalicKey()));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getStrikethroughKey()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-13 13:10:14
|
Revision: 2611
http://svn.sourceforge.net/rubyeclipse/?rev=2611&view=rev
Author: cawilliams
Date: 2007-06-13 06:10:08 -0700 (Wed, 13 Jun 2007)
Log Message:
-----------
remove references to single line comment stuff
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-06-12 19:00:47 UTC (rev 2610)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-06-13 13:10:08 UTC (rev 2611)
@@ -34,7 +34,7 @@
private static String[] fgTokenProperties = { IRubyColorConstants.RUBY_KEYWORD, IRubyColorConstants.RUBY_DEFAULT,
IRubyColorConstants.RUBY_FIXNUM, IRubyColorConstants.RUBY_CHARACTER, IRubyColorConstants.RUBY_SYMBOL,
IRubyColorConstants.RUBY_INSTANCE_VARIABLE, IRubyColorConstants.RUBY_GLOBAL, IRubyColorConstants.RUBY_STRING,
- IRubyColorConstants.RUBY_REGEXP, IRubyColorConstants.RUBY_ERROR, IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT
+ IRubyColorConstants.RUBY_REGEXP, IRubyColorConstants.RUBY_ERROR
// TODO Add Ability to set colors for return and operators
// IRubyColorConstants.RUBY_METHOD_NAME,
// IRubyColorConstants.RUBY_KEYWORD_RETURN,
@@ -107,8 +107,6 @@
}
private Token doGetToken(String key) {
- if (key.equals(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT)) // if we know it's a comment, force it!
- return super.getToken(key);
if (isInSymbol)
return super.getToken(IRubyColorConstants.RUBY_SYMBOL);
if (isInRegexp)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 19:00:49
|
Revision: 2610
http://svn.sourceforge.net/rubyeclipse/?rev=2610&view=rev
Author: cawilliams
Date: 2007-06-12 12:00:47 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
when traversing AST nodes for elements in local script (for completiosn with empty prefix) include constants as well as instance and class variables
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-06-12 18:56:45 UTC (rev 2609)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-06-12 19:00:47 UTC (rev 2610)
@@ -20,6 +20,7 @@
import org.jruby.ast.ClassVarDeclNode;
import org.jruby.ast.ClassVarNode;
import org.jruby.ast.Colon2Node;
+import org.jruby.ast.ConstDeclNode;
import org.jruby.ast.ConstNode;
import org.jruby.ast.DefnNode;
import org.jruby.ast.DefsNode;
@@ -602,7 +603,7 @@
// Get instance and class variables available in the enclosing type
List<Node> instanceAndClassVars = ScopedNodeLocator.Instance().findNodesInScope(typeNode, new INodeAcceptor() {
public boolean doesAccept(Node node) {
- return (node instanceof InstVarNode || node instanceof InstAsgnNode || node instanceof ClassVarNode || node instanceof ClassVarDeclNode || node instanceof ClassVarAsgnNode);
+ return (node instanceof ConstDeclNode || node instanceof InstVarNode || node instanceof InstAsgnNode || node instanceof ClassVarNode || node instanceof ClassVarDeclNode || node instanceof ClassVarAsgnNode);
}
});
Set<String> fields = new HashSet<String>();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 18:56:47
|
Revision: 2609
http://svn.sourceforge.net/rubyeclipse/?rev=2609&view=rev
Author: cawilliams
Date: 2007-06-12 11:56:45 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
when syntax is broken and we're trying to complete a method call, we fall back to parsing corrected source and traversing nodes for method suggestions if there's a matching type in the file (in addition to asking the RubyElementRequestor to find the type).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java 2007-06-12 16:32:02 UTC (rev 2608)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java 2007-06-12 18:56:45 UTC (rev 2609)
@@ -112,6 +112,14 @@
return correctedSource;
}
+ public boolean isBroken() {
+ try {
+ return !getCorrectedSource().equals(script.getSource());
+ } catch (RubyModelException e) {
+ return true;
+ }
+ }
+
public boolean hasReceiver() {
return getFullPrefix().indexOf('.') > 1;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-06-12 16:32:02 UTC (rev 2608)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-06-12 18:56:45 UTC (rev 2609)
@@ -93,7 +93,7 @@
for (int i = 0; i < types.length; i++) {
IType type = types[i];
suggestTypesConstants(type);
-// Suggest nested types
+ // Suggest nested types
suggestNestedTypes(type);
// Suggest class level methods
Map<String, CompletionProposal> map = suggestMethods(100, type, false);
@@ -120,8 +120,35 @@
List<CompletionProposal> list = new ArrayList<CompletionProposal>();
RubyElementRequestor requestor = new RubyElementRequestor(script);
for (ITypeGuess guess : guesses) {
- String name = guess.getType();
- IType[] types = requestor.findType(name); // FIXME When syntax is broken, grabbing type that is defined in same script like this just doesn't work!
+ final String name = guess.getType();
+ if (fContext.isBroken()) {
+ Node rootNode = new RubyParser().parse(fContext.getCorrectedSource());
+ List<Node> typeNodes = ScopedNodeLocator.Instance().findNodesInScope(rootNode, new INodeAcceptor() {
+
+ public boolean doesAccept(Node node) {
+ if ((node instanceof ClassNode) || (node instanceof ModuleNode)) {
+ return ASTUtil.getNameReflectively(node).equals(name);
+ }
+ return false;
+ }
+
+ });
+ for (Node typeNode : typeNodes) {
+ List<Node> methods = ScopedNodeLocator.Instance().findNodesInScope(typeNode, new INodeAcceptor() {
+
+ public boolean doesAccept(Node node) {
+ return (node instanceof DefnNode) || (node instanceof DefsNode);
+ }
+
+ });
+ for (Node methodNode : methods) {
+ MethodDefNode methodDef = (MethodDefNode) methodNode;
+ NodeMethod method = new NodeMethod(methodDef);
+ list.add(suggestMethod(method, name, 100));
+ }
+ }
+ }
+ IType[] types = requestor.findType(name);
for (int i = 0; i < types.length; i++) {
Map<String, CompletionProposal> map = suggestMethods(guess.getConfidence(), types[i], true);
list.addAll(map.values());
@@ -178,6 +205,7 @@
private List<CompletionProposal> suggestAllMethodsMatchingPrefix(IRubyScript script) {
List< CompletionProposal> list = new ArrayList<CompletionProposal>();
+ if (fContext.getPartialPrefix() == null || fContext.getPartialPrefix().trim().length() == 0) return list;
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {script.getRubyProject()});
SearchParticipant participant = BasicSearchEngine.getDefaultSearchParticipant();
CollectingSearchRequestor searchRequestor = new CollectingSearchRequestor();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 16:32:05
|
Revision: 2608
http://svn.sourceforge.net/rubyeclipse/?rev=2608&view=rev
Author: cawilliams
Date: 2007-06-12 09:32:02 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
don't expand methods by default. remove unused code
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java 2007-06-12 16:19:34 UTC (rev 2607)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java 2007-06-12 16:32:02 UTC (rev 2608)
@@ -384,7 +384,7 @@
Item i= (Item) node;
if (i.getData() instanceof IRubyElement) {
IRubyElement je= (IRubyElement) i.getData();
- if (je.getElementType() == IRubyElement.IMPORT_CONTAINER) {
+ if (je.getElementType() == IRubyElement.IMPORT_CONTAINER || je.getElementType() == IRubyElement.METHOD) {
if (i != fReusedExpandedItem) {
setExpanded(i, false);
return;
@@ -1192,30 +1192,6 @@
}
/**
- * Checks whether a given Ruby element is an inner type.
- *
- * @param element the ruby element
- * @return <code>true</code> iff the given element is an inner type
- */
- private boolean isInnerType(IRubyElement element) {
-
- if (element != null && element.getElementType() == IRubyElement.TYPE) {
- IType type= (IType)element;
- try {
- return type.isMember();
- } catch (RubyModelException e) {
- IRubyElement parent= type.getParent();
- if (parent != null) {
- int parentElementType= parent.getElementType();
- return (parentElementType != IRubyElement.SCRIPT);
- }
- }
- }
-
- return false;
- }
-
- /**
* Returns the <code>IShowInSource</code> for this view.
*
* @return the {@link IShowInSource}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 16:19:36
|
Revision: 2607
http://svn.sourceforge.net/rubyeclipse/?rev=2607&view=rev
Author: cawilliams
Date: 2007-06-12 09:19:34 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
change how we find types. Just ask teh search engine by passing in teh fully qualified name. This doesn't take imports into account at all anymore, but solves some weird issues.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-06-12 16:18:48 UTC (rev 2606)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-06-12 16:19:34 UTC (rev 2607)
@@ -2,26 +2,22 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
-import org.eclipse.core.runtime.IPath;
-import org.rubypeople.rdt.core.IImportDeclaration;
-import org.rubypeople.rdt.core.IParent;
+import org.eclipse.core.runtime.CoreException;
import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.ISourceFolder;
-import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.core.search.SearchMatch;
+import org.rubypeople.rdt.core.search.SearchParticipant;
+import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.internal.core.search.BasicSearchEngine;
-import org.rubypeople.rdt.internal.core.util.Util;
+import org.rubypeople.rdt.internal.core.search.CollectingSearchRequestor;
public class RubyElementRequestor {
- private static final String SEPARATOR_CHARS = "\\/";
- private static final String RUBY_FILE_EXTENSION = ".rb";
private IRubyScript script;
public RubyElementRequestor(IRubyScript script) {
@@ -29,100 +25,21 @@
}
public IType[] findType(String fullyQualifiedName) {
- IType[] types = findTypeWithSimpleName(Util.getSimpleName(fullyQualifiedName));
- List<IType> matches = new ArrayList<IType>();
- for (int i = 0; i < types.length; i++) {
- if (Util.parentsMatch(types[i], fullyQualifiedName)) matches.add(types[i]);
- }
- return matches.toArray(new IType[matches.size()]);
- }
-
- private IType[] findTypeWithSimpleName(String typeName) {
List<IType> types = new ArrayList<IType>();
- IRubyProject rubyProject = script.getRubyProject();
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, fullyQualifiedName, IRubySearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
+ SearchParticipant[] participants = new SearchParticipant[] { BasicSearchEngine.getDefaultSearchParticipant() };
+ IRubySearchScope scope = BasicSearchEngine.createRubySearchScope( new IRubyElement[] { script.getRubyProject() } );
+ CollectingSearchRequestor requestor = new CollectingSearchRequestor();
try {
- // FIXME Search the roots in a particular order? Return first match?
- ISourceFolderRoot[] roots = rubyProject.getSourceFolderRoots();
- for (int i = 0; i < roots.length; i++) {
- types.addAll(getImportedTypesInSourceFolderRoot(roots[i], typeName));
- }
- if (types.size() == 0) { // Couldn't find any!
- // Do a full search
- types.addAll(BasicSearchEngine.findType(typeName));
- }
- } catch (RubyModelException e) {
+ new BasicSearchEngine().search(pattern, participants, scope, requestor, null);
+ } catch (CoreException e) {
RubyCore.log(e);
+ } // TODO check the result locations and prefer those that are imported by this script.
+ List<SearchMatch> matches = requestor.getResults();
+ for (SearchMatch match : matches) {
+ IType type = (IType) match.getElement();
+ types.add(type);
}
- return types.toArray(new IType[types.size()]);
+ return types.toArray(new IType[types.size()]);
}
-
- private List<IType> filterToMatches(String typeName, List<IType> types) {
- List<IType> matches = new ArrayList<IType>();
- for (IType type : types) {
- if (type.getElementName().equals(typeName)) matches.add(type);
- }
- return matches;
- }
-
- private List<IType> getImportedTypesInSourceFolderRoot(ISourceFolderRoot root, String typeName) {
- List<IType> types = new ArrayList<IType>();
- try {
- IPath rootPath = root.getPath();
-// FIXME this is an ugly hack to search the core library in a special way (no need to look at imports)
- if (rootPath.toString().contains("org.rubypeople.rdt.launching")) {
- types.addAll(getTypesInImport(root, typeName.toLowerCase()));
- } else {
- IImportDeclaration[] imports = script.getImports();
- for (int j = 0; j < imports.length; j++) {
- String path = imports[j].getElementName();
- types.addAll(getTypesInImport(root, path));
- }
- }
- } catch (RubyModelException e) {
- RubyCore.log(e);
- }
-
- return filterToMatches(typeName, types);
- }
-
- /**
- * Searches the root for the path given (and appends the typical ".rb" extension).
- * If we find a match, grab the types inside the script.
- * @param root The ISourceFolderRoot to search
- * @param path The internal path to search.
- * @return a List of ITypes which seem to be a match
- */
- private List<IType> getTypesInImport(ISourceFolderRoot root, String path) {
- StringTokenizer tokenizer = new StringTokenizer(path, SEPARATOR_CHARS);
- List<String> tokens = new ArrayList<String>();
- while(tokenizer.hasMoreTokens()) {
- tokens.add(tokenizer.nextToken());
- }
- if (tokens.isEmpty()) return new ArrayList<IType>();
- String name = tokens.remove(tokens.size() - 1) + RUBY_FILE_EXTENSION;
- String[] pckgs = tokens.toArray(new String[tokens.size()]);
- ISourceFolder folder = root.getSourceFolder(pckgs);
- if (!folder.exists()) return new ArrayList<IType>();
- IRubyScript otherScript = folder.getRubyScript(name);
- if (!otherScript.exists()) return new ArrayList<IType>();
- return getTypes(otherScript);
- }
-
- private List<IType> getTypes(IParent script) {
- List<IType> types = new ArrayList<IType>();
- try {
- IRubyElement[] children = script.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i].isType(IRubyElement.TYPE)) {
- types.add((IType) children[i]);
- }
- if (children[i] instanceof IParent) {
- types.addAll(getTypes((IParent) children[i]));
- }
- }
- } catch (RubyModelException e) {
- // ignore
- }
- return types;
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 16:18:49
|
Revision: 2606
http://svn.sourceforge.net/rubyeclipse/?rev=2606&view=rev
Author: cawilliams
Date: 2007-06-12 09:18:48 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-06-12 16:18:42 UTC (rev 2605)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/search/BasicSearchEngine.java 2007-06-12 16:18:48 UTC (rev 2606)
@@ -266,7 +266,7 @@
return RubyModelManager.getRubyModelManager().getWorkspaceScope();
}
- public static Collection<? extends IType> findType(String simpleTypeName) {
+ public static Collection<IType> findType(String simpleTypeName) {
SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*" + simpleTypeName + "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
SearchParticipant[] participants = new SearchParticipant[] {getDefaultSearchParticipant()};
IRubySearchScope scope = createWorkspaceScope();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 16:18:46
|
Revision: 2605
http://svn.sourceforge.net/rubyeclipse/?rev=2605&view=rev
Author: cawilliams
Date: 2007-06-12 09:18:42 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
try to avoid null pointer
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-06-12 15:37:53 UTC (rev 2604)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java 2007-06-12 16:18:42 UTC (rev 2605)
@@ -1495,6 +1495,7 @@
}
public static int lastIndexOf(String toBeFound, char[] typePart) {
+ if (typePart == null || typePart.length == 0) return -1;
return new String(typePart).lastIndexOf(toBeFound);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 15:37:54
|
Revision: 2604
http://svn.sourceforge.net/rubyeclipse/?rev=2604&view=rev
Author: cawilliams
Date: 2007-06-12 08:37:53 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
fix Trac ticket #4373 - handle code completion after ::
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java 2007-06-12 15:06:01 UTC (rev 2603)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionContext.java 2007-06-12 15:37:53 UTC (rev 2604)
@@ -12,6 +12,7 @@
private String partialPrefix;
private String fullPrefix;
private int replaceStart;
+ private boolean isAfterDoubleSemiColon = false;
public CompletionContext(IRubyScript script, int offset) throws RubyModelException {
this.script = script;
@@ -38,6 +39,21 @@
// TODO What if there is a valid character after this, so syntax isn't broken?
source.deleteCharAt(i);
break;
+ case ':':
+ if (i > 0) {
+ // Check character before this for :
+ char previous = source.charAt(i - 1);
+ if (previous == ':') {
+ isAfterDoubleSemiColon = true;
+ source.deleteCharAt(i);
+ source.deleteCharAt(i - 1);
+ tmpPrefix.insert(0, "::");
+ partialPrefix = "";
+ i--;
+ continue;
+ }
+ }
+ break;
}
}
if (curChar == '.') {
@@ -139,6 +155,10 @@
public boolean isGlobal() {
return !emptyPrefix() && !isExplicitMethodInvokation() && getPartialPrefix().startsWith("$");
}
+
+ public boolean isDoubleSemiColon() {
+ return isAfterDoubleSemiColon;
+ }
public boolean fullPrefixIsConstant() {
if (getFullPrefix() == null || getFullPrefix().length() == 0) return false;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-06-12 15:06:01 UTC (rev 2603)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-06-12 15:37:53 UTC (rev 2604)
@@ -85,6 +85,27 @@
suggestMethodsForEnclosingType(script);
getDocumentsRubyElementsInScope();
} else {
+ if (fContext.isDoubleSemiColon()) {
+ String prefix = fContext.getFullPrefix();
+ prefix = prefix.substring(0, prefix.length() - 2);
+ RubyElementRequestor requestor = new RubyElementRequestor(script);
+ IType[] types = requestor.findType(prefix);
+ for (int i = 0; i < types.length; i++) {
+ IType type = types[i];
+ suggestTypesConstants(type);
+// Suggest nested types
+ suggestNestedTypes(type);
+ // Suggest class level methods
+ Map<String, CompletionProposal> map = suggestMethods(100, type, false);
+ for (CompletionProposal proposal : map.values()) {
+ fRequestor.accept(proposal);
+ }
+ }
+
+ this.fRequestor.endReporting();
+ fContext = null;
+ return;
+ }
if (fContext.isConstant()) { // type or constant
suggestTypeNames();
suggestConstantNames();
@@ -102,7 +123,7 @@
String name = guess.getType();
IType[] types = requestor.findType(name); // FIXME When syntax is broken, grabbing type that is defined in same script like this just doesn't work!
for (int i = 0; i < types.length; i++) {
- Map<String, CompletionProposal> map = suggestMethods(guess.getConfidence(), types[i]);
+ Map<String, CompletionProposal> map = suggestMethods(guess.getConfidence(), types[i], true);
list.addAll(map.values());
}
}
@@ -127,6 +148,34 @@
fContext = null;
}
+ private void suggestTypesConstants(IType type) throws RubyModelException {
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.CONSTANT, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {type});
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
+ IRubyElement element = (IRubyElement) match.getElement();
+ if (element.getElementType() != IRubyElement.CONSTANT) continue; // XXX we shouldn't have to do this
+ // Add proposal
+ CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.FIELD_REF, element.getElementName());
+ proposal.setType(type.getFullyQualifiedName());
+ fRequestor.accept(proposal);
+ }
+ }
+
+ private void suggestNestedTypes(IType type) throws RubyModelException {
+ SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
+ IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {type});
+ List<SearchMatch> results = search(pattern, scope);
+ for (SearchMatch match: results) {
+ IType aType = (IType) match.getElement();
+ if (!aType.getFullyQualifiedName().startsWith(type.getFullyQualifiedName()) || aType.getFullyQualifiedName().equals(type.getFullyQualifiedName())) continue;
+ // Add proposal
+ CompletionProposal proposal = createProposal(fContext.getReplaceStart(), CompletionProposal.TYPE_REF, aType.getElementName());
+ proposal.setType(aType.getFullyQualifiedName());
+ fRequestor.accept(proposal);
+ }
+ }
+
private List<CompletionProposal> suggestAllMethodsMatchingPrefix(IRubyScript script) {
List< CompletionProposal> list = new ArrayList<CompletionProposal>();
IRubySearchScope scope = BasicSearchEngine.createRubySearchScope(new IRubyElement[] {script.getRubyProject()});
@@ -167,7 +216,7 @@
type = element.getDeclaringType();
}
if (type == null) return;
- List<CompletionProposal> list = sort(suggestMethods(100, type));
+ List<CompletionProposal> list = sort(suggestMethods(100, type, true));
for (CompletionProposal proposal : list) {
fRequestor.accept(proposal);
}
@@ -243,19 +292,22 @@
}
}
- private Map<String, CompletionProposal> suggestMethods(int confidence, IType type) throws RubyModelException {
+ private Map<String, CompletionProposal> suggestMethods(int confidence, IType type, boolean includeInstanceMethods) throws RubyModelException {
Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
if (type == null)
return proposals;
IMethod[] methods = type.getMethods();
for (int k = 0; k < methods.length; k++) {
+ if (!includeInstanceMethods && !methods[k].isSingleton()) {
+ continue;
+ }
CompletionProposal proposal = suggestMethod(methods[k], type.getElementName(), confidence);
if (proposal != null && !proposals.containsKey(proposal.getName())) {
proposals.put(proposal.getName(), proposal); // If a method name matches an existing suggestion (i.e. its overriden in the subclass), don't suggest it again!
}
}
proposals.putAll(addModuleMethods(confidence - 1, type)); // Decrement confidence by one as a hack to make sure as we move up the inheritance chain we suggest "closer" parents methods first
- if (!type.isModule()) proposals.putAll(addSuperClassMethods(confidence - 1, type));
+ if (!type.isModule()) proposals.putAll(addSuperClassMethods(confidence - 1, type, includeInstanceMethods));
return proposals;
}
@@ -274,7 +326,7 @@
for (int j = 0; j < moduleTypes.length; j++) {
try {
IType moduleType = moduleTypes[j];
- proposals.putAll(suggestMethods(confidence, moduleType));
+ proposals.putAll(suggestMethods(confidence, moduleType, true));
} catch (RubyModelException e) {
// ignore
}
@@ -283,7 +335,7 @@
return proposals;
}
- private Map<String, CompletionProposal> addSuperClassMethods(int confidence, IType type) throws RubyModelException {
+ private Map<String, CompletionProposal> addSuperClassMethods(int confidence, IType type, boolean includeInstanceMethods) throws RubyModelException {
Map<String, CompletionProposal> proposals = new HashMap<String, CompletionProposal>();
String superClass = type.getSuperclassName();
if (superClass == null) return proposals;
@@ -291,7 +343,7 @@
IType[] supers = requestor.findType(superClass);
for (int i = 0; i < supers.length; i++) {
IType superType = supers[i];
- proposals.putAll(suggestMethods(confidence, superType));
+ proposals.putAll(suggestMethods(confidence, superType, includeInstanceMethods));
}
return proposals;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 15:06:05
|
Revision: 2603
http://svn.sourceforge.net/rubyeclipse/?rev=2603&view=rev
Author: cawilliams
Date: 2007-06-12 08:06:01 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
fix null pointers
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java 2007-06-12 14:58:05 UTC (rev 2602)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java 2007-06-12 15:06:01 UTC (rev 2603)
@@ -534,9 +534,11 @@
* @see org.eclipse.jdt.core.IElementChangedListener#elementChanged(org.eclipse.jdt.core.ElementChangedEvent)
*/
public void elementChanged(ElementChangedEvent e) {
- IRubyElementDelta delta = findElement(fInput, e.getDelta());
- if (delta.getRubyScriptAST() == null) return;
- if (delta != null) processDelta(delta);
+ IRubyElementDelta delta = findElement(fInput, e.getDelta());
+ if (delta != null) {
+ if (delta.getRubyScriptAST() == null) return;
+ processDelta(delta);
+ }
}
private IRubyElementDelta findElement(IRubyElement target, IRubyElementDelta delta) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 14:58:08
|
Revision: 2602
http://svn.sourceforge.net/rubyeclipse/?rev=2602&view=rev
Author: cawilliams
Date: 2007-06-12 07:58:05 -0700 (Tue, 12 Jun 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-06-12 03:12:21 UTC (rev 2601)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-06-12 14:58:05 UTC (rev 2602)
@@ -280,8 +280,6 @@
beginRescueAction.update(selection);
provider.addSelectionChangedListener(beginRescueAction);
setAction(SurroundWithBeginRescueAction.SURROUND_WTH_BEGIN_RESCUE, beginRescueAction);
-
- fActionGroups.addGroup(new RubyActionGroup(this, ITextEditorActionConstants.GROUP_EDIT));
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 03:12:24
|
Revision: 2601
http://svn.sourceforge.net/rubyeclipse/?rev=2601&view=rev
Author: cawilliams
Date: 2007-06-11 20:12:21 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
include dynamic variables as part of model. Make their image same as local variable.
this allows us to resolve a dynamic variable to its assignment.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -18,6 +18,8 @@
import org.jruby.ast.Colon2Node;
import org.jruby.ast.ConstDeclNode;
import org.jruby.ast.ConstNode;
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.DVarNode;
import org.jruby.ast.DefnNode;
import org.jruby.ast.DefsNode;
import org.jruby.ast.FCallNode;
@@ -53,6 +55,7 @@
import org.rubypeople.rdt.internal.ti.ITypeGuess;
import org.rubypeople.rdt.internal.ti.ITypeInferrer;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
+import org.rubypeople.rdt.internal.ti.util.FirstPrecursorNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
import org.rubypeople.rdt.internal.ti.util.OffsetNodeLocator;
@@ -82,6 +85,18 @@
RubyElementRequestor completer = new RubyElementRequestor(script);
return completer.findType(fullyQualifiedName);
}
+ if (selected instanceof DVarNode) {
+ final String name = ((DVarNode) selected).getName();
+ Node assignment = FirstPrecursorNodeLocator.Instance().findFirstPrecursor(root, start, new INodeAcceptor() {
+
+ public boolean doesAccept(Node node) {
+ // TODO Auto-generated method stub
+ return (node instanceof DAsgnNode) && ((DAsgnNode) node).getName().equals(name);
+ }
+
+ });
+ return new IRubyElement[] { script.getElementAt(assignment.getPosition().getStartOffset()) };
+ }
if (selected instanceof ConstNode) {
ConstNode constNode = (ConstNode) selected;
String name = constNode.getName();
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/ISourceElementRequestor.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -30,6 +30,7 @@
public int declarationStart;
// public String type; TODO Pre populate our guesses at type?
public String name;
+ public boolean isDynamic;
public int nameSourceStart;
public int nameSourceEnd;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyDynamicVar.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -31,13 +31,13 @@
* RubyDynamicVar is a dynamic variable which is scoped to an iterator or loop
*
*/
-public class RubyDynamicVar extends RubyField {
+public class RubyDynamicVar extends LocalVariable {
/**
* @param name
*/
- public RubyDynamicVar(RubyElement parent, String name) {
- super(parent, name);
+ public RubyDynamicVar(RubyElement parent, String name, int start, int end) {
+ super(parent, name, start, end);
}
/* (non-Javadoc)
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -202,13 +202,17 @@
} else {
int start = field.declarationStart - field.name.length() + 1;
int end = start + field.name.length();
- handle = new LocalVariable(modelStack.peek(), field.name, start, end);
+ if (field.isDynamic) {
+ handle = new RubyDynamicVar(modelStack.peek(), field.name, start, end);
+ } else {
+ handle = new LocalVariable(modelStack.peek(), field.name, start, end);
+ }
}
modelStack.push(handle);
// Add to enclosing type
RubyElementInfo parentInfo;
- if (handle instanceof LocalVariable) {
+ if (handle instanceof LocalVariable || handle instanceof RubyDynamicVar) {
parentInfo = infoStack.peek();
} else if (handle instanceof RubyGlobal){
parentInfo = scriptInfo; // FIXME Grab the project info?
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceElementParser.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -365,6 +365,11 @@
@Override
public Instruction visitDAsgnNode(DAsgnNode iVisited) {
// RubyDynamicVar var = new RubyDynamicVar(modelStack.peek(), iVisited.getName()); FIXME Notify like a normal local var?
+ FieldInfo field = createFieldInfo(iVisited);
+ field.name = iVisited.getName();
+ field.isDynamic = true;
+ requestor.enterField(field);
+ exitField(iVisited);
return super.visitDAsgnNode(iVisited);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2007-06-12 03:11:17 UTC (rev 2600)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2007-06-12 03:12:21 UTC (rev 2601)
@@ -186,6 +186,7 @@
return RubyPluginImages.DESC_OBJS_CONSTANT;
case IRubyElement.LOCAL_VARIABLE:
+ case IRubyElement.DYNAMIC_VAR: // FIXME Make dynamic var have it's own image?
return RubyPluginImages.DESC_OBJS_LOCAL_VAR;
case IRubyElement.INSTANCE_VAR:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-12 03:11:18
|
Revision: 2600
http://svn.sourceforge.net/rubyeclipse/?rev=2600&view=rev
Author: cawilliams
Date: 2007-06-11 20:11:17 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
change wording of members sort order. change fields to instance variables?
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-06-11 21:00:56 UTC (rev 2599)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-06-12 03:11:17 UTC (rev 2600)
@@ -15,6 +15,7 @@
import org.rubypeople.rdt.internal.core.pmd.Match;
import org.rubypeople.rdt.internal.core.pmd.TokenEntry;
+// XXX Either use this in some way, or remove it!
public class CodeDuplicationDetector implements MultipleFileCompiler {
private IMarkerManager markerManager;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-11 21:01:00
|
Revision: 2599
http://svn.sourceforge.net/rubyeclipse/?rev=2599&view=rev
Author: cawilliams
Date: 2007-06-11 14:00:56 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
fix Trac ticket #4592 - Code folding breaks while you type
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElementDelta.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDelta.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElementDelta.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElementDelta.java 2007-06-11 20:37:30 UTC (rev 2598)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElementDelta.java 2007-06-11 21:00:56 UTC (rev 2599)
@@ -11,7 +11,7 @@
package org.rubypeople.rdt.core;
import org.eclipse.core.resources.IResourceDelta;
-import org.rubypeople.rdt.internal.core.RubyScript;
+import org.jruby.ast.Node;
/**
* A Java element delta describes changes in Java element between two discrete
@@ -348,7 +348,7 @@
* @see #F_AST_AFFECTED
* @since 3.2
*/
- public RubyScript getRubyScriptAST();
+ public Node getRubyScriptAST();
/**
* Returns deltas for the children which have changed.
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java 2007-06-11 20:37:30 UTC (rev 2598)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java 2007-06-11 21:00:56 UTC (rev 2599)
@@ -125,8 +125,8 @@
this.problems = new HashMap();
this.ast = workingCopy.makeConsistent(true, this.problems, this.progressMonitor);
this.deltaBuilder.buildDeltas();
- // if (this.ast != null && this.deltaBuilder.delta != null)
- // this.deltaBuilder.delta.changedAST(this.ast);
+ if (this.ast != null && this.deltaBuilder.delta != null)
+ this.deltaBuilder.delta.changedAST(this.ast);
return this.ast;
}
if (this.ast != null)
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDelta.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDelta.java 2007-06-11 20:37:30 UTC (rev 2598)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDelta.java 2007-06-11 21:00:56 UTC (rev 2599)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import org.eclipse.core.resources.IResourceDelta;
+import org.jruby.ast.Node;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyElementDelta;
@@ -32,7 +33,7 @@
* reconcile operation - the changed element is an IRubyScript in
* working copy mode
*/
- protected RubyScript ast = null;
+ protected Node ast = null;
/*
* The element that this delta describes the change to.
@@ -264,7 +265,7 @@
/*
* Records the last changed AST .
*/
- public void changedAST(RubyScript changedAST) {
+ public void changedAST(Node changedAST) {
this.ast = changedAST;
changed(F_AST_AFFECTED);
}
@@ -397,7 +398,7 @@
return parents;
}
- public RubyScript getRubyScriptAST() {
+ public Node getRubyScriptAST() {
return this.ast;
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java 2007-06-11 20:37:30 UTC (rev 2598)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/folding/DefaultRubyFoldingStructureProvider.java 2007-06-11 21:00:56 UTC (rev 2599)
@@ -535,6 +535,7 @@
*/
public void elementChanged(ElementChangedEvent e) {
IRubyElementDelta delta = findElement(fInput, e.getDelta());
+ if (delta.getRubyScriptAST() == null) return;
if (delta != null) processDelta(delta);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-06-11 20:37:31
|
Revision: 2598
http://svn.sourceforge.net/rubyeclipse/?rev=2598&view=rev
Author: cawilliams
Date: 2007-06-11 13:37:30 -0700 (Mon, 11 Jun 2007)
Log Message:
-----------
fix Trac #4349 - Expand inner types by default in outline view
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java 2007-06-11 17:35:10 UTC (rev 2597)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyOutlinePage.java 2007-06-11 20:37:30 UTC (rev 2598)
@@ -384,7 +384,7 @@
Item i= (Item) node;
if (i.getData() instanceof IRubyElement) {
IRubyElement je= (IRubyElement) i.getData();
- if (je.getElementType() == IRubyElement.IMPORT_CONTAINER || isInnerType(je)) {
+ if (je.getElementType() == IRubyElement.IMPORT_CONTAINER) {
if (i != fReusedExpandedItem) {
setExpanded(i, false);
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|