|
Lines 1037-1046
Link Here
|
| 1037 |
if (isTryWithResources()) { |
1037 |
if (isTryWithResources()) { |
| 1038 |
fIndent= fPrefs.prefContinuationIndent; |
1038 |
fIndent= fPrefs.prefContinuationIndent; |
| 1039 |
return fPosition; |
1039 |
return fPosition; |
| 1040 |
} else { |
|
|
| 1041 |
fPosition= pos; |
| 1042 |
return skipToStatementStart(danglingElse, false); |
| 1043 |
} |
1040 |
} |
|
|
1041 |
fPosition= pos; |
| 1042 |
if (isSemicolonPartOfEnumBodyDeclaration()) { |
| 1043 |
fIndent= getBlockIndent(false, true); |
| 1044 |
return fPosition; |
| 1045 |
} |
| 1046 |
fPosition= pos; |
| 1047 |
return skipToStatementStart(danglingElse, false); |
| 1044 |
} |
1048 |
} |
| 1045 |
// scope introduction: special treat who special is |
1049 |
// scope introduction: special treat who special is |
| 1046 |
case Symbols.TokenLPAREN: |
1050 |
case Symbols.TokenLPAREN: |
|
Lines 1537-1542
Link Here
|
| 1537 |
case Symbols.TokenRBRACE: |
1541 |
case Symbols.TokenRBRACE: |
| 1538 |
case Symbols.TokenGREATERTHAN: |
1542 |
case Symbols.TokenGREATERTHAN: |
| 1539 |
skipScope(); |
1543 |
skipScope(); |
|
|
1544 |
startLine= fLine; |
| 1545 |
startPosition= fPosition; |
| 1540 |
break; |
1546 |
break; |
| 1541 |
|
1547 |
|
| 1542 |
// scope introduction: special treat who special is |
1548 |
// scope introduction: special treat who special is |
|
Lines 1687-1699
Link Here
|
| 1687 |
pos= fPosition; // store |
1693 |
pos= fPosition; // store |
| 1688 |
|
1694 |
|
| 1689 |
// special: array initializer |
1695 |
// special: array initializer |
| 1690 |
if (looksLikeArrayInitializerIntro()) |
1696 |
if (looksLikeArrayInitializerIntro()) { |
| 1691 |
if (fPrefs.prefArrayDeepIndent) |
1697 |
if (fPrefs.prefArrayDeepIndent) { |
| 1692 |
return setFirstElementAlignment(pos, bound); |
1698 |
return setFirstElementAlignment(pos, bound); |
| 1693 |
else |
1699 |
} else { |
| 1694 |
fIndent= fPrefs.prefArrayIndent; |
1700 |
fIndent= fPrefs.prefArrayIndent; |
| 1695 |
else |
1701 |
return pos; |
|
|
1702 |
} |
| 1703 |
} else { |
| 1696 |
fIndent= fPrefs.prefBlockIndent; |
1704 |
fIndent= fPrefs.prefBlockIndent; |
|
|
1705 |
} |
| 1697 |
|
1706 |
|
| 1698 |
// normal: skip to the statement start before the scope introducer |
1707 |
// normal: skip to the statement start before the scope introducer |
| 1699 |
// opening braces are often on differently ending indents than e.g. a method definition |
1708 |
// opening braces are often on differently ending indents than e.g. a method definition |
|
Lines 1743-1769
Link Here
|
| 1743 |
|
1752 |
|
| 1744 |
|
1753 |
|
| 1745 |
/** |
1754 |
/** |
| 1746 |
* Returns <code>true</code> if the next token received after calling |
1755 |
* Returns <code>true</code> if the next token received after calling <code>nextToken</code> is |
| 1747 |
* <code>nextToken</code> is either an equal sign or an array designator ('[]'). |
1756 |
* either an equal sign or an array designator ('[]') preceded by array creation. |
| 1748 |
* |
1757 |
* |
| 1749 |
* @return <code>true</code> if the next elements look like the start of an array definition |
1758 |
* @return <code>true</code> if the next elements look like the start of an array definition |
| 1750 |
*/ |
1759 |
*/ |
| 1751 |
private boolean looksLikeArrayInitializerIntro() { |
1760 |
private boolean looksLikeArrayInitializerIntro() { |
| 1752 |
nextToken(); |
1761 |
nextToken(); |
| 1753 |
if (fToken == Symbols.TokenEQUAL || skipBrackets()) { |
1762 |
if (fToken == Symbols.TokenEQUAL) { |
| 1754 |
return true; |
1763 |
return true; |
|
|
1764 |
} |
| 1765 |
|
| 1766 |
if (!skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET)) { |
| 1767 |
return false; |
| 1768 |
} |
| 1769 |
nextToken(); |
| 1770 |
if (fToken == Symbols.TokenIDENT) { // type name |
| 1771 |
nextToken(); |
| 1772 |
while (fToken == Symbols.TokenOTHER) { // dot of qualification |
| 1773 |
nextToken(); |
| 1774 |
if (fToken != Symbols.TokenIDENT) // qualifying name |
| 1775 |
return false; |
| 1776 |
nextToken(); |
| 1777 |
} |
| 1778 |
return fToken == Symbols.TokenNEW; |
| 1755 |
} |
1779 |
} |
| 1756 |
return false; |
1780 |
return false; |
| 1757 |
} |
1781 |
} |
| 1758 |
|
1782 |
|
| 1759 |
/** |
1783 |
/** |
| 1760 |
* Skips over the next <code>if</code> keyword. The current token when calling |
1784 |
* Returns <code>true</code> if the current position looks like a part of enum declaration |
| 1761 |
* this method must be an <code>else</code> keyword. Returns <code>true</code> |
1785 |
* header. It calls {@link #nextToken} to scan backwards. |
| 1762 |
* if a matching <code>if</code> could be found, <code>false</code> otherwise. |
|
|
| 1763 |
* The cursor (<code>fPosition</code>) is set to the offset of the <code>if</code> |
| 1764 |
* token. |
| 1765 |
* |
1786 |
* |
| 1766 |
* @return <code>true</code> if a matching <code>if</code> token was found, <code>false</code> otherwise |
1787 |
* @return <code>true</code> if the current position looks like a part of enum declaration |
|
|
1788 |
* header |
| 1789 |
* @since 3.11 |
| 1790 |
*/ |
| 1791 |
private boolean looksLikeEnumDeclaration() { |
| 1792 |
while (true) { |
| 1793 |
nextToken(); |
| 1794 |
switch (fToken) { |
| 1795 |
case Symbols.TokenENUM: |
| 1796 |
return true; |
| 1797 |
case Symbols.TokenIDENT: |
| 1798 |
case Symbols.TokenCOMMA: |
| 1799 |
case Symbols.TokenAT: |
| 1800 |
break; |
| 1801 |
case Symbols.TokenOTHER: |
| 1802 |
try { |
| 1803 |
if (fDocument.getChar(fPosition) != '.') { |
| 1804 |
return false; |
| 1805 |
} |
| 1806 |
} catch (BadLocationException e) { |
| 1807 |
return false; |
| 1808 |
} |
| 1809 |
break; |
| 1810 |
case Symbols.TokenRPAREN: |
| 1811 |
case Symbols.TokenRBRACKET: |
| 1812 |
case Symbols.TokenRBRACE: |
| 1813 |
case Symbols.TokenGREATERTHAN: |
| 1814 |
skipScope(); |
| 1815 |
break; |
| 1816 |
case Symbols.TokenEOF: |
| 1817 |
return false; |
| 1818 |
default: |
| 1819 |
return false; |
| 1820 |
} |
| 1821 |
} |
| 1822 |
} |
| 1823 |
|
| 1824 |
/** |
| 1825 |
* Checks if the semicolon at the current position is part of enum body declaration. |
| 1826 |
* |
| 1827 |
* @return returns <code>true</code> if the semicolon at the current position is part of enum |
| 1828 |
* body declaration |
| 1829 |
* @since 3.11 |
| 1830 |
*/ |
| 1831 |
private boolean isSemicolonPartOfEnumBodyDeclaration() { |
| 1832 |
while (true) { |
| 1833 |
nextToken(); |
| 1834 |
switch (fToken) { |
| 1835 |
case Symbols.TokenLBRACE: |
| 1836 |
return looksLikeEnumDeclaration(); |
| 1837 |
case Symbols.TokenIDENT: |
| 1838 |
case Symbols.TokenCOMMA: |
| 1839 |
break; |
| 1840 |
case Symbols.TokenRPAREN: |
| 1841 |
case Symbols.TokenRBRACKET: |
| 1842 |
case Symbols.TokenRBRACE: |
| 1843 |
case Symbols.TokenGREATERTHAN: |
| 1844 |
skipScope(); |
| 1845 |
break; |
| 1846 |
case Symbols.TokenEOF: |
| 1847 |
return false; |
| 1848 |
default: |
| 1849 |
return false; |
| 1850 |
} |
| 1851 |
} |
| 1852 |
} |
| 1853 |
|
| 1854 |
/** |
| 1855 |
* Skips over the next <code>if</code> keyword. The current token when calling this method must |
| 1856 |
* be an <code>else</code> keyword. Returns <code>true</code> if a matching <code>if</code> |
| 1857 |
* could be found, <code>false</code> otherwise. The cursor (<code>fPosition</code>) is set to |
| 1858 |
* the offset of the <code>if</code> token. |
| 1859 |
* |
| 1860 |
* @return <code>true</code> if a matching <code>if</code> token was found, <code>false</code> |
| 1861 |
* otherwise |
| 1767 |
*/ |
1862 |
*/ |
| 1768 |
private boolean skipNextIF() { |
1863 |
private boolean skipNextIF() { |
| 1769 |
Assert.isTrue(fToken == Symbols.TokenELSE); |
1864 |
Assert.isTrue(fToken == Symbols.TokenELSE); |