Ignore lib folder.
This commit is contained in:
parent
345f0cf14b
commit
38ce317aad
@ -2,3 +2,4 @@
|
|||||||
/.settings/
|
/.settings/
|
||||||
/bin/
|
/bin/
|
||||||
*.iml
|
*.iml
|
||||||
|
/lib/
|
||||||
|
1
JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/JavaCompilerPlugin.Plugin/.gitignore
vendored
Normal file
1
JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/JavaCompilerPlugin.Plugin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/lib/
|
@ -0,0 +1,89 @@
|
|||||||
|
package typinferenzplugin.editor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
import org.eclipse.jface.text.contentassist.CompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformation;
|
||||||
|
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
|
||||||
|
|
||||||
|
public class JafCompletionProcess implements IContentAssistProcessor {
|
||||||
|
private final IContextInformation[] NO_CONTEXTS = {};
|
||||||
|
private final char[] PROPOSAL_ACTIVATION_CHARS = { 's', 'f', 'p', 'n', 'm', };
|
||||||
|
private ICompletionProposal[] NO_COMPLETIONS = {};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
|
||||||
|
try {
|
||||||
|
IDocument document = viewer.getDocument();
|
||||||
|
ArrayList<ICompletionProposal> result = new ArrayList<>();
|
||||||
|
String prefix = lastWord(document, offset);
|
||||||
|
String indent = lastIndent(document, offset);
|
||||||
|
|
||||||
|
result.add(new CompletionProposal("replace", offset - prefix.length(), prefix.length(), "replace".length()));
|
||||||
|
|
||||||
|
return (ICompletionProposal[]) result.toArray(new ICompletionProposal[result.size()]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ... log the exception ...
|
||||||
|
return NO_COMPLETIONS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String lastWord(IDocument doc, int offset) {
|
||||||
|
try {
|
||||||
|
for (int n = offset - 1; n >= 0; n--) {
|
||||||
|
char c = doc.getChar(n);
|
||||||
|
if (!Character.isJavaIdentifierPart(c))
|
||||||
|
return doc.get(n + 1, offset - n - 1);
|
||||||
|
}
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
// ... log the exception ...
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String lastIndent(IDocument doc, int offset) {
|
||||||
|
try {
|
||||||
|
int start = offset - 1;
|
||||||
|
while (start >= 0 && doc.getChar(start) != '\n')
|
||||||
|
start--;
|
||||||
|
int end = start;
|
||||||
|
while (end > offset && Character.isSpaceChar(doc.getChar(end)))
|
||||||
|
end++;
|
||||||
|
return doc.get(start + 1, end - start - 1);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IContextInformation[] computeContextInformation(ITextViewer arg0, int arg1) {
|
||||||
|
return NO_CONTEXTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char[] getCompletionProposalAutoActivationCharacters() {
|
||||||
|
return PROPOSAL_ACTIVATION_CHARS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char[] getContextInformationAutoActivationCharacters() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IContextInformationValidator getContextInformationValidator() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,4 +14,25 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>JavaCompilerPlugin.Plugin</module>
|
<module>JavaCompilerPlugin.Plugin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>install</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.basedir}/JavaCompilerPlugin.Plugin/lib</outputDirectory>
|
||||||
|
<stripVersion>true</stripVersion>
|
||||||
|
<overWriteIfNewer>true</overWriteIfNewer>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
@ -63,21 +63,7 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>install</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.basedir}/bundles/JavaCompilerPlugin.Plugin/lib</outputDirectory>
|
|
||||||
<stripVersion>true</stripVersion>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.tycho</groupId>
|
<groupId>org.eclipse.tycho</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user